Skip to content

Fix Rect::ExpandToMinTransformedSize to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification - #189808

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
b-luk:expandmintotransformedsizefix
Jul 22, 2026

Conversation

@b-luk

@b-luk b-luk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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-assist bot 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.

@b-luk

b-luk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 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.

@b-luk
b-luk marked this pull request as ready for review July 21, 2026 23:17
@b-luk
b-luk requested a review from flar July 21, 2026 23:17
@b-luk b-luk added the CICD Run CI/CD label Jul 21, 2026

@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 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.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jul 21, 2026
@b-luk

b-luk commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@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

@b-luk b-luk changed the title Fix Rect::ExpandToMinTransformedSize to return the input rectangle when no expansion is needed Fix Rect::ExpandToMinTransformedSize to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification Jul 22, 2026

@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.

LGTM

@b-luk b-luk added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 22, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 22, 2026
Merged via the queue into flutter:master with commit de177df Jul 22, 2026
21 of 22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 22, 2026
@b-luk b-luk added the cp: beta cherry pick this pull request to beta release candidate branch label Jul 22, 2026
auto-submit Bot pushed a commit that referenced this pull request Jul 23, 2026
…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.
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 24, 2026
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
@b-luk
b-luk deleted the expandmintotransformedsizefix branch August 4, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UberSDF round rectangles are sometimes incorrectly drawn as non-rounded rectangles

2 participants