feat: optimize raster performance on Animated images. #513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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