Repository navigation
fix: dispose queued animation frame when image completer is disposed - #1065
Merged
rickdijk merged 9 commits intoOct 29, 2026
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Synchronous removal of the final listener during frame delivery can trigger double disposal or invalidate the frame reference before its duration is read.
1 open issue
What changed in this PR
This PR fixes a decoded animation-frame leak in MultiImageStreamCompleter, complementing #1064’s codec subscription cleanup.
Changes:
- Dispose and clear queued frames during final disposal while preserving keep-alive behavior.
- Add three regression tests covering queued frames and final keep-alive release.
- Bump the app-facing package to 4.0.6 and document the fix.
| File | Description |
|---|---|
cached_network_image/test/image_stream_completer_test.dart |
Add queued-frame disposal and keep-alive regression tests. |
cached_network_image/pubspec.yaml |
Bump version to 4.0.6. |
cached_network_image/lib/src/image_provider/multi_image_stream_completer.dart |
Release the queued frame during final disposal. |
cached_network_image/CHANGELOG.md |
Document the animation-frame leak fix. |
Review effort: Balanced
rickdijk
reviewed
Oct 27, 2026
rickdijk
reviewed
Oct 27, 2026
rickdijk
reviewed
Oct 27, 2026
rickdijk
reviewed
Oct 27, 2026
rickdijk
reviewed
Oct 27, 2026
rickdijk
reviewed
Oct 27, 2026
rickdijk
reviewed
Oct 28, 2026
rickdijk
reviewed
Oct 28, 2026
rickdijk
force-pushed
the
fix/dispose-queued-animation-frame
branch
from
October 29, 2026 10:43
4ab9102 to
49f3071
Compare
rickdijk
reviewed
Oct 29, 2026
rickdijk
reviewed
Oct 29, 2026
rickdijk
reviewed
Oct 29, 2026
rickdijk
reviewed
Oct 29, 2026
rickdijk
reviewed
Oct 29, 2026
rickdijk
reviewed
Oct 29, 2026
rickdijk
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bug fix: release animated-image resources and preserve refreshed-image playback.
Removed images can retain decoded frames and codecs. Refreshes can revert to an older image or remain queued after a play-once animation finishes. Synchronous codec replacement during delivery can corrupt the new animation's frame count or shorten the frame just shown.
🆕 What is the new behavior (if this is a feature change)?
Framework disposal releases queued frames and active/pending codecs. Late codec results are drained and disposed without retaining the completer; producer-side cancellation remains a follow-up. A shared helper handles pending-codec ownership, and the constructor documents that ownership.
Refreshes supersede older pending images, activate after finite playback completes, and preserve displayed-frame timing during synchronous replacement. Keep-alive pause/resume behavior is preserved. Version and changelog are updated to 4.0.6.
💥 Does this PR introduce a breaking change?
No.
🐛 Recommendations for testing
flutter test --coverage: all 75 package tests pass.flutter analyzeand formatting checks for changed Dart files pass.📝 Links to relevant issues/docs
Related: #1064. Producer-side cancellation across the IO and web loaders remains a follow-up optimization; draining here avoids dropping undelivered codecs.
🤔 Checklist before submitting