Repository navigation
[flutter_svg] Invalidate pending cache entries on clear and evict - #13595
Merged
auto-submit[bot] merged 2 commits intoNov 11, 2026
Merged
Conversation
11 tasks done
palmoni5
marked this pull request as ready for review
November 9, 2026 13:45
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the flutter_svg package to version 2.3.3, introducing a _PendingLoad wrapper class in Cache to track the identity of in-flight loads. This change prevents stale or invalidated pending loads from repopulating the cache after a clear or evict operation, and ensures failed loads are removed from the pending cache to allow retries. Unit tests have been added to verify these cache lifecycle behaviors. There are no review comments, and I have no feedback to provide.
This was referenced Nov 9, 2026
Merged
zxdan-git
reviewed
Nov 11, 2026
zxdan-git
reviewed
Nov 11, 2026
zxdan-git
reviewed
Nov 11, 2026
gaaclarke
self-requested a review
November 11, 2026 01:05
palmoni5
force-pushed
the
codex/upstream-svg-cache-lifecycle
branch
from
November 11, 2026 08:20
8757ae9 to
a3d2a70
Compare
gaaclarke
requested changes
Nov 11, 2026
gaaclarke
left a comment
Member
There was a problem hiding this comment.
Mostly looking good. I think when you rebased you duplicated a test and I'm not sure why you've added _PendingLoad.
Comment on lines
+173
to
+194
| test('failed loads are removed from the pending cache and can be retried', () async { | ||
| final cache = Cache(); | ||
| final firstLoad = Completer<ByteData>(); | ||
| final Future<ByteData> pending = cache.putIfAbsent('icon', () => firstLoad.future); | ||
|
|
||
| expect( | ||
| identical(pending, cache.putIfAbsent('icon', () => throw StateError('duplicate load'))), | ||
| isTrue, | ||
| ); | ||
|
|
||
| final Future<void> expectedFailure = expectLater(pending, throwsStateError); | ||
| firstLoad.completeError(StateError('temporarily unavailable')); | ||
| await expectedFailure; | ||
|
|
||
| final recovered = ByteData(2); | ||
| final ByteData result = await cache.putIfAbsent( | ||
| 'icon', | ||
| () => Future<ByteData>.value(recovered), | ||
| ); | ||
| expect(identical(result, recovered), isTrue); | ||
| expect(cache.count, 1); | ||
| }); |
Member
There was a problem hiding this comment.
Contributor
Author
palmoni5
force-pushed
the
codex/upstream-svg-cache-lifecycle
branch
from
November 11, 2026 19:05
a3d2a70 to
16c7e6d
Compare
11 tasks done
b-luk
pushed a commit
to b-luk/flutter
that referenced
this pull request
Nov 12, 2026
…r#196450) flutter/packages@653628e...14f9933 2026-11-12 [email protected] [material_ui] Fix SnackBarThemeData.lerp dropping showCloseIcon (flutter/packages#13449) 2026-11-11 [email protected] [ci] Update repo for 3.50 stable release (flutter/packages#13628) 2026-11-11 [email protected] [vector_graphics] Use font-family lists as a family with fallbacks (flutter/packages#13552) 2026-11-11 [email protected] Roll Flutter (stable) from c197ca5 to ab29120 (1647 revisions) (flutter/packages#13625) 2026-11-11 [email protected] [shared_prferences] Adopts mockito-kotlin in tests (flutter/packages#13624) 2026-11-11 [email protected] [cupertino_ui] Dim disabled CupertinoSlider controls (flutter/packages#13419) 2026-11-11 [email protected] [flutter_svg] Invalidate pending cache entries on clear and evict (flutter/packages#13595) 2026-11-11 [email protected] [cupertino_ui] Fix the tinted button's fill opacity (flutter/packages#13436) 2026-11-11 [email protected] [various] Support SVG filters (blur, offset, feMerge) (flutter/packages#11909) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit Bot
pushed a commit
that referenced
this pull request
Nov 12, 2026
Merged main (14f9933) in d01b5b2, preserving branch history. Main now contains the pending-load changes from #13595. The Files changed tab shows the byte-budget implementation, tests, and release metadata. Adds a byte budget to the compiled SVG cache: Cache.maximumByteSize defaults to 32 MiB, Cache.currentByteSize reports retained compiled-data bytes, and completed entries obey both the existing count limit and the byte limit using LRU eviction. Oversized results are returned to callers without displacing cached entries. Reducing a limit evicts immediately; zero disables retention. Adds API documentation, regression tests, version 2.4.0 and changelog. Related memory report: flutter/flutter#184564. This proposal bounds retained compiled cache data; it does not claim to solve the report's peak memory during compilation or memory retained by live widgets. Validation on Windows: flutter analyze (no issues); complete flutter test suite (84 passed, 1 pre-existing skip); formatting and git diff --check. Tests cover byte/count LRU, changing limits, oversized results, out-of-order completions, and disabling/re-enabling during pending loads. Small platform golden differences are accepted by the existing comparator; no goldens were updated. ## Pre-Review Checklist This draft was prepared with AI assistance and remains pending the contributor's human review and confirmation of the unchecked checklist items.
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.
Rebased on current main (
8041ccab1), preserving the failed-load fix and its regression test from #13604. This PR adds invalidation of pending loads onCache.clearandCache.evict: an obsolete completion cannot repopulate the cache or remove a replacement request, even when loaders reuse the same Future.Documents pending-load invalidation on both methods. The cache lifecycle tests live in
cache_test.dart. The shared-Future regression checks that an evicted request does not populate the cache before the replacement's completion callback runs. Preserves synchronous cache hits, coalescing and entry-count LRU. Bumps the package to 2.3.4 with a changelog entry.Related: flutter/flutter#182486 (failed-load cleanup is already on main via #13604).
Validation on Windows:
flutter analyzeclean; fullflutter testsuite: 77 passed, 1 existing skip; formatting andgit diff --checkpassed. No golden files changed.Overlapping proposals: #13613 also concerns failed pending loads; main already includes #13604. This PR retains that fix and focuses on clear/evict invalidation. #13596 is stacked on this branch and was rebased with it.
Pre-Review Checklist
This draft was prepared with AI assistance and remains pending the contributor's human review and confirmation of the unchecked checklist items.