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

feat: optimize raster performance on Animated images. #513

Merged
merged 6 commits into from
Nov 7, 2023

Conversation

andycall
Copy link
Member

@andycall andycall commented Nov 2, 2023

The I/O bottleneck can impact the performance of the raster thread in Flutter.

When WebF pages contain multiple GIF images, each frame of these GIFs requires the I/O thread to fetch its next frame, potentially turning the I/O thread into a bottleneck.

This PR introduces an intersectionObserverLayer for each GIF image, monitoring the visibility of each animated image. If an ImageElement scrolls outside the viewport, the imageFrame event listeners will be detached from the imageStreamListener, and the next frame request for that image will be paused.

With this update, only the animated images visible in the viewport will request the next frame, significantly reducing the load on the I/O thread.

Related issue for Flutter: flutter/flutter#135443

@andycall andycall added this pull request to the merge queue Nov 7, 2023
Merged via the queue into main with commit fd690df Nov 7, 2023
28 checks passed
@andycall andycall deleted the feat/optimize_gif_performance branch November 7, 2023 10:42
andycall added a commit that referenced this pull request Nov 18, 2023
The I/O bottleneck can impact the performance of the raster thread in
Flutter.

When WebF pages contain multiple GIF images, each frame of these GIFs
requires the I/O thread to fetch its next frame, potentially turning the
I/O thread into a bottleneck.

This PR introduces an intersectionObserverLayer for each GIF image,
monitoring the visibility of each animated image. If an ImageElement
scrolls outside the viewport, the imageFrame event listeners will be
detached from the imageStreamListener, and the next frame request for
that image will be paused.

With this update, only the animated images visible in the viewport will
request the next frame, significantly reducing the load on the I/O
thread.

Related issue for Flutter:
flutter/flutter#135443
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.

None yet

3 participants