Fix Rect::ExpandToMinTransformedSize to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification - #189808
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the rectangle expansion logic in rect.h to return the original rectangle without modification if its current size already meets or exceeds the minimum local size. Additionally, a unit test has been renamed and a new regression test has been added in rect_unittests.cc to verify this behavior with fractional sizes. There are no review comments, and I have no feedback to provide.
There was a problem hiding this comment.
Code Review
This pull request modifies the rectangle expansion logic in Impeller's geometry library to return the unmodified rectangle when its current dimensions are already greater than or equal to the minimum required size. Additionally, a regression test has been added to verify this behavior with fractional dimensions. There are no review comments, and I have no feedback to provide.
|
@flar PTAL. I went with your suggestion in #189807 (comment) and also removed the 1-pixel roundrect to rect simplification. The golden results show a very subtle reduction in opacity of pixels at the end of sub-pixel-width roundrects. That is what we expect from this change: https://flutter-gold.skia.org/search?crs=github&issue=189808&patchsets=2 |
Rect::ExpandToMinTransformedSize to return the input rectangle when no expansion is neededRect::ExpandToMinTransformedSize to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification
…rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (#189885) This was a manual cherry pick of #189808. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #189807 ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping of production apps (the app crashes on launch). This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick. Rounded rectangles are sometimes incorrectly rendered as non-rounded rectangles. This issue is present when impeller is enabled Impeller with SDF rendering. In the beta channel, Impeller with SDF rendering is the default when building apps for desktop platforms: macOS, Linux, and Windows. ### Changelog Description: Explain this cherry pick: * In one line that is accessible to most Flutter developers. * That describes the state prior to the fix. * That includes which platforms are impacted. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples. < Replace with changelog description here > [flutter/189807](#189807): Rounded rectangles are sometimes incorrectly rendered as non-rounded rectangles. ### Workaround: Is there a workaround for this issue? Disable Impeller, falling back to Skia rendering. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? The demo app at #189807 should render two rounded rectangles, rather than one normal rectangle and one rounded rectangle.
flutter/flutter@2a2a79d...b65f4d9 2026-07-24 jason-simmons@users.noreply.github.com Add dart_runtime_service_vm_aot.dart.snapshot to the snapshot list in the macOS code signing configuration (flutter/flutter#189981) 2026-07-24 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from wLST_A-xfOeGT_5mj... to E8hJ1AfK8CtGtaES0... (flutter/flutter#189956) 2026-07-23 chingjun@google.com Consolidate AndroidArch and DarwinArch into CpuArch (flutter/flutter#189315) 2026-07-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 9258584f98b8 to e3fc57eae9eb (7 revisions) (flutter/flutter#189949) 2026-07-23 jason-simmons@users.noreply.github.com [flutter_tools] Do not always wait for the full timeout when running Spotlight to locate Android Studio on macOS (flutter/flutter#189952) 2026-07-23 engine-flutter-autoroll@skia.org Roll Skia from 1d8bf9270d8c to 6e9c4687c001 (15 revisions) (flutter/flutter#189954) 2026-07-23 jason-simmons@users.noreply.github.com [flutter_tools] Initialize Cache.flutterRoot at the start of the upgrade_test suite (flutter/flutter#189937) 2026-07-23 faheemabbas766@gmail.com Parse AndroidX property in gradle.properties (flutter/flutter#188372) 2026-07-23 60122246+xiaowei-guan@users.noreply.github.com [Impeller]Use the IO context for OpenGL program setup (flutter/flutter#185723) 2026-07-23 43089218+chika3742@users.noreply.github.com Allow building projects lacking Runner.xcworkspace (flutter/flutter#186239) 2026-07-23 bkonyi@google.com [flutter_tools] Invalidate WebEntrypointTarget when plugin set changes (flutter/flutter#189460) 2026-07-23 srawlins@google.com Bump devtools_shared to 13.1.0 (flutter/flutter#189507) 2026-07-23 matt.boetger@gmail.com forceNdkDownload should skip configuring cmake when ndk-build is used (flutter/flutter#187201) 2026-07-23 jason-simmons@users.noreply.github.com Disable execution order shuffling for the flutter_tools upgrade_test suite (flutter/flutter#189920) 2026-07-23 matej.knopp@gmail.com Move WindowManager outside of WidgetsApp (flutter/flutter#188866) 2026-07-23 engine-flutter-autoroll@skia.org Roll Skia from 3424966b8a2b to 1d8bf9270d8c (3 revisions) (flutter/flutter#189901) 2026-07-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from GswhlPRO-D1qSNclx... to 9org0yL3yZkp80x5S... (flutter/flutter#189898) 2026-07-23 116356835+AbdeMohlbi@users.noreply.github.com Remove outdated logs that were added to track #172636 (flutter/flutter#189282) 2026-07-23 engine-flutter-autoroll@skia.org Roll Skia from 5e183e5aeac5 to 3424966b8a2b (33 revisions) (flutter/flutter#189890) 2026-07-23 srawlins@google.com [examples] Use super parameters in missed spots (flutter/flutter#186194) 2026-07-23 bkonyi@google.com [flutter_tools] Bound Spotlight mdfind execution with timeout on macOS (flutter/flutter#189461) 2026-07-23 codedoctor@linwood.dev Fix non primary buttons not being captured on windows (flutter/flutter#188394) 2026-07-22 matt.boetger@gmail.com Listen to log reader before VM Service and make delay configurable (flutter/flutter#187202) 2026-07-22 engine-flutter-autoroll@skia.org Roll Dart SDK from 1e65011ee004 to 9258584f98b8 (7 revisions) (flutter/flutter#189883) 2026-07-22 30870216+gaaclarke@users.noreply.github.com Adds skill for generating engine diffs for new releases. (flutter/flutter#189869) 2026-07-22 chris@bracken.jp [ios,macos] Add Swift Sourcekit LSP support (flutter/flutter#189761) 2026-07-22 chris@bracken.jp [iOS] Mark DisplayLinkManager.shared and init() @mainactor (flutter/flutter#189815) 2026-07-22 97480502+b-luk@users.noreply.github.com Fix `Rect::ExpandToMinTransformedSize` to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (flutter/flutter#189808) 2026-07-22 15619084+vashworth@users.noreply.github.com Skip emulator.getEmulators test (flutter/flutter#189879) 2026-07-22 codedoctor@linwood.dev Fix null terminator in input truncates clipboard (flutter/flutter#188652) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
Fixes #189807
See the issue for more context.
Adds a unit test that fails without this change, and passes with this change.
Verified the demo app in the issue renders properly with this change.
From the issue:
Root cause and fix
Rect::ExpandToMinTransformedSize always constructs a new expanded rectangle from the input Rect from its center point and half-extents.
If the input rectangle is already large enough and does not need expansion, this should return an identical rectangle. The returned rectangle is equality-checked against the input in Canvas::DrawRoundRect to determine whether expansion happened. That code assumes that if the output does not equal the input, pixel-expansion happened, which means that the rounded rect had sub-pixel dimensions and can be safely drawn as a non-rounded rectangle.
The issue is that for certain cases, particularly with non-integer sizes, ExpandToMinTransformedSize returns a different rectangle even if no expansion happened. This is due to small floating point imprecisions when constructing the new rectangle using the input rectangle's center and half-extents.
To fix this, ExpandToMinTransformedSize should not construct a new rectangle unless expansion is actually needed.
Removal of 1-pixel roundrect to rect simplification
This PR also removes the 1-pixel roundrect to rect simplification in
Canvas::DrawRoundRect. As described in #189807 (comment), this optimization resulted in slightly different colors at the tips of thin roundrects.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.