Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1650: part II: memory footprint in web: remove unnecessary animation and Image.memory in web #1741

Merged
merged 5 commits into from
May 14, 2024

Conversation

sherlockvn
Copy link
Contributor

@sherlockvn sherlockvn commented May 6, 2024

DESC:

#1650

Problem:

  • Currently, we use Image.memory to load image data to view, which required two steps, its need to downloaded to memory first, then pass it to the widget, which make app freezes a lot while scrolling.

  • Moreover, MxcImage use combination of animation and setState when image is downloaded, which is not efficient.
    -Image.network have multiple optimization, and build-in method (loadingBuilder and frameBuilder) which make the rendering in web more efficient. And We don't have to convert to bytes anymore, use the download link, and the browser will help us caching the image.

  • For the case of encrypted chat, we still have to use Image.memory because of we have to decrypte bytes data after downloading done

  • For the case of Avatar, use cacheWidth to reduce the memory usage when decoding image

Reference:

Reference of frameBuilder in Image.network

Compare performance and memory usage between beta.twake.app and current

Screen.Recording.2024-05-06.at.15.18.51.mov

Demo:

Screen.Recording.2024-05-08.at.12.51.37.mov
Screen.Recording.2024-05-08.at.12.46.10.mov
RPReplay_Final1715168002.MP4

Copy link

github-actions bot commented May 6, 2024

This PR has been deployed to https://linagora.github.io/twake-on-matrix/1741

@sherlockvn sherlockvn changed the title TW-1650: remove unnecessary animation and Image.memory in web TW-1650: part II: memory footprint in web: remove unnecessary animation and Image.memory in web May 6, 2024
@sherlockvn sherlockvn force-pushed the TW-1650-part-II-memory-footprint-web branch from 17e41ef to 86ea1aa Compare May 13, 2024 03:29
@sherlockvn sherlockvn force-pushed the TW-1650-part-II-memory-footprint-web branch from 86ea1aa to bcdfde1 Compare May 13, 2024 03:44
@sherlockvn sherlockvn force-pushed the TW-1650-part-II-memory-footprint-web branch from bcdfde1 to f509ced Compare May 13, 2024 04:26
@sherlockvn
Copy link
Contributor Author

  • Hot fix: timestamp is not updated when scroll in chat
    -> move InViewState dispose() in chat controller, because its like a static instance, so we can't dispose it in the message dispose() method
Screen.Recording.2024-05-13.at.17.14.04.mov

@hoangdat hoangdat merged commit 7ffd907 into main May 14, 2024
7 checks passed
@hoangdat hoangdat deleted the TW-1650-part-II-memory-footprint-web branch May 14, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants