Skip to content

[cupertino_ui] Reuse a single Paint in _CupertinoEdgeShadowPainter - #12304

Closed
fa0311 wants to merge 1 commit into
flutter:mainfrom
fa0311:perf-cupertino-edge-shadow-paint
Closed

[cupertino_ui] Reuse a single Paint in _CupertinoEdgeShadowPainter#12304
fa0311 wants to merge 1 commit into
flutter:mainfrom
fa0311:perf-cupertino-edge-shadow-paint

Conversation

@fa0311

@fa0311 fa0311 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The edge shadow of a Cupertino page transition is drawn as ~20 1px-wide rects per frame, each allocating a fresh Paint. This runs on every frame of every CupertinoPageRoute push/pop and back-swipe. This PR hoists the Paint out of the loop and only updates its color per iteration, matching the pattern already used by _CupertinoActivityIndicatorPainter. Canvas draw calls snapshot paint state, so mutating and reusing a single Paint produces identical output.

Fixes flutter/flutter#190198. (Originally submitted to flutter/flutter as flutter/flutter#190188, redirected here due to the Material/Cupertino decoupling code freeze, flutter/flutter#184093.)

This is a behavior-preserving refactor with no observable output change; existing tests in packages/cupertino_ui/test/route_test.dart cover this code path and pass, so I believe this qualifies as test-exempt.

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

The edge shadow of a Cupertino page transition is drawn as ~20 1px-wide
rects per frame, each allocating a fresh Paint. Hoist the Paint out of
the loop and only update its color, matching the pattern used by
_CupertinoActivityIndicatorPainter.
@github-actions github-actions Bot added triage-framework Should be looked at in framework triage p: cupertino_ui labels Jul 29, 2026
@fa0311
fa0311 marked this pull request as ready for review July 29, 2026 07:57

@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 optimizes the _CupertinoEdgeShadowPainter in route.dart by instantiating a single Paint object outside the loop and reusing it, rather than allocating a new object for each iteration. Additionally, the package version is bumped to 0.0.3 in pubspec.yaml and the change is documented in CHANGELOG.md. There are no review comments, and I have no feedback to provide.

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@Piinks

Piinks commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Hi @fa0311 thank you for the contribution. I am going to close this for now because we are not accepting PRs in these packages currently. We are still in the middle of the migration and ensuring the packages are complete before publishing and accepting contributions. Thank you.

If you would like to re-open the PR you had in flutter/flutter, we'll be helping to port these PRs over when we are ready to start accepting contributions.

@Piinks Piinks closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: cupertino_ui triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal:_CupertinoEdgeShadowPainter allocates ~20 Paint objects per frame during page transitions

2 participants