Skip to content

[flutter_svg] Add a byte budget for the compiled SVG cache - #13596

Merged
auto-submit[bot] merged 5 commits into
flutter:mainfrom
palmoni5:codex/upstream-svg-cache-budget
Nov 12, 2026
Merged

auto-submit[bot] merged 5 commits into
flutter:mainfrom
palmoni5:codex/upstream-svg-cache-budget

Conversation

@palmoni5

@palmoni5 palmoni5 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the AI contribution guidelines and understand my responsibilities, or I am not using AI tools.
  • I read the Tree Hygiene page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter.
  • I signed the CLA.
  • The title starts with the package name in square brackets.
  • I linked to at least one related issue above.
  • I followed the version and CHANGELOG instructions.
  • I updated relevant API documentation.
  • I added regression tests.
  • All existing and new tests are passing.

This draft was prepared with AI assistance and remains pending the contributor's human review and confirmation of the unchecked checklist items.

@github-actions github-actions Bot added p: flutter_svg triage-engine Should be looked at in engine triage labels Nov 9, 2026
@palmoni5
palmoni5 marked this pull request as ready for review November 9, 2026 13:45

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a configurable byte budget for the compiled SVG cache in flutter_svg, defaulting to 32 MiB, along with least-recently-used (LRU) eviction based on both entry count and byte size. It also updates the cache lifecycle management to prevent failed or invalidated pending loads from incorrectly repopulating the cache. Comprehensive unit tests have been added to verify these cache lifecycle and memory budget behaviors. There are no review comments, so I have no additional feedback to provide.

@gaaclarke

Copy link
Copy Markdown
Member

@flar can you take a look here please?

@flar flar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for a comment, but otherwise LGTM

@gaaclarke gaaclarke added the CICD Run CI/CD label Nov 9, 2026
@gaaclarke
gaaclarke self-requested a review November 9, 2026 22:35
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 9, 2026
@gaaclarke gaaclarke added the CICD Run CI/CD label Nov 9, 2026

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly looking good, I'll refrain from reviewing it until its base PR is landed. Please "rerequest review" after that one lands.

@flar
flar requested a review from gaaclarke November 10, 2026 00:59
@flar

flar commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

This is mostly looking good, I'll refrain from reviewing it until its base PR is landed. Please "rerequest review" after that one lands.

Oh, sorry, I requested a re-review before I saw your note.

@flar
flar removed the request for review from gaaclarke November 10, 2026 01:00
@flar

flar commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

This is mostly looking good, I'll refrain from reviewing it until its base PR is landed. Please "rerequest review" after that one lands.

Oh, sorry, I requested a re-review before I saw your note.

I restored it back to its previous "request changes".

@palmoni5
palmoni5 force-pushed the codex/upstream-svg-cache-budget branch from a41a86c to a8ee27e Compare November 11, 2026 08:21
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 11, 2026
@palmoni5
palmoni5 force-pushed the codex/upstream-svg-cache-budget branch from a8ee27e to f0f907f Compare November 11, 2026 19:05
auto-submit Bot pushed a commit that referenced this pull request Nov 11, 2026
…3595)

Rebased on current main (`8041ccab1`), preserving the failed-load fix and its regression test from #13604. This PR adds invalidation of pending loads on `Cache.clear` and `Cache.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 analyze` clean; full `flutter test` suite: 77 passed, 1 existing skip; formatting and `git diff --check` passed. 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.
@palmoni5
palmoni5 requested a review from gaaclarke November 11, 2026 21:11

@gaaclarke gaaclarke left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase this? it still has the changes from your previous PR in it (like the addition of _PendingLoad. (or merging main is actually probably better to keep the history)

@palmoni5
palmoni5 requested a review from gaaclarke November 12, 2026 08:25
@flar flar added the CICD Run CI/CD label Nov 12, 2026

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit
auto-submit Bot merged commit 05f828f into flutter:main Nov 12, 2026
14 checks passed
@palmoni5
palmoni5 deleted the codex/upstream-svg-cache-budget branch November 12, 2026 23:14
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Nov 13, 2026
…lutter#196558)

Manually rolls flutter/packages from 14f9933a8cd6 to 015df97cbc3f (5
revisions). This is the same one-line change the [flutter/packages →
flutter/flutter
autoroller](https://autoroll.skia.org/r/flutter-packages-flutter-autoroll)
makes.

Today's two automatic rolls, flutter#196527 and flutter#196547, failed on presubmit
jobs that don't use the packages pin (`Windows tool_integration_tests_5`
and `Linux_android_emu android_engine_opengles_tests`). The roller
closed the second one after its roll window ended. It only rolls on
weekdays and doesn't support manual rolls, so its next roll would be on
Monday.

flutter/packages@14f9933...015df97

2026-11-13 [camera_windows] Fall back to temp dir for capture path.
(flutter/packages#12755)
2026-11-13 [video_player] Convert event channel to Swift and Pigeon
(flutter/packages#13375)
2026-11-13 [material_ui] Document and demonstrate safe MaterialBanner
dismissal across routes (flutter/packages#13267)
2026-11-12 [flutter_svg] Add a byte budget for the compiled SVG cache
(flutter/packages#13596)
2026-11-12 Roll Flutter from b98afb5 to 9c427b5 (29 revisions)
(flutter/packages#13636)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: flutter_svg triage-engine Should be looked at in engine triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants