Apply rect clipping to surface views#184471
Conversation
…_surfaceviews' into again_we_try_to_fix_surfaceviews
|
Note in the image that there is a small green bar on the right in the clipped image. Some thoughts on the source: onDisplayPlatformView uses an int, when the actual position has sub-pixel values. Perhaps there is a rounding error there. I'm of the opinion we can fix this in a follow up issue, as it is pretty minor and this is a strict improvement to the clipping for surfaceviews, but let me know if you feel otherwise. |
There was a problem hiding this comment.
Code Review
This pull request introduces clipping support for SurfaceView platform views on Android API 34 and above by applying crops to the SurfaceControl based on the mutator stack. It also adds a corresponding integration test with screenshot comparison. Review feedback highlights that SurfaceControl transactions are currently not being applied or closed, which is critical for functionality and resource management. Additionally, the implementation should be updated to prevent redundant SurfaceHolder callback registrations and to remove unnecessary coordinate validation logic.
| if (screenRect.width() < 0 || screenRect.height() < 0) { | ||
| screenRect.setEmpty(); | ||
| } |
There was a problem hiding this comment.
This check is redundant. The screenRect is initialized from a RectF using roundOut, which ensures right >= left and bottom >= top. Subsequent intersect operations either maintain this property or result in an empty rect (where width and height are 0) via the setEmpty() call on line 570. The offset operation does not change the dimensions of the rectangle.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces clipping support for SurfaceView platform views on Android (API 34+) by applying crops via SurfaceControl transactions and adds a new integration test. Feedback identifies that the SurfaceControl transactions are missing the required apply() call and should be managed using try-with-resources for proper resource disposal. Additionally, it is recommended to use the Flutter-assigned viewId rather than the Android View ID to track pending surface callbacks reliably.
I don't think surpressing is helpful here, and the test is only failing because the gold images weren't approved. I approved them when the pr was initially put up (when the bot made this comment) but for some reason this seems to have been undone after the pr landed All that needs to be done is for the images to be approved, which looks like it has happened. |
|
Reason for revert: Skia gold seems seriously confused about this PR (likely a bug). I think the only solution we can easily come up with is to just revert and re land |
This reverts commit a488da3.
|
Unable to create the revert pull request due to ProcessException: Standard error |
This reverts commit a488da3.
flutter/flutter@9cd60b5...a0924c7 2026-04-07 [email protected] Reland "[data_assets] Cleanup tests" (flutter/flutter#184714) 2026-04-07 [email protected] Use the WindowRegistry in the multiple_windows example app (flutter/flutter#184579) 2026-04-07 [email protected] Introduce command to build a swift package for SwiftPM add to app integration (flutter/flutter#184660) 2026-04-07 [email protected] Have `flutter create` create a pubspec.lock to ensure pinned versions are being used. (flutter/flutter#175352) 2026-04-07 [email protected] [widgets/raw_menu_anchor.dart] Always call onClose and onCloseRequested on descendants before parent. (flutter/flutter#182357) 2026-04-07 [email protected] `WindowsPlugin` should not crash when ffiPlugin enabled (flutter/flutter#184695) 2026-04-06 [email protected] Use full goto.google.com hostname for go/ links (flutter/flutter#184679) 2026-04-06 [email protected] Apply rect clipping to surface views (flutter/flutter#184471) 2026-04-06 [email protected] [A11y] Allow percentage strings like "50%" as `SemanticsValue` for `ProgressIndicator` (flutter/flutter#183670) 2026-04-06 [email protected] Fix invisible accessibility element before scroll view (flutter/flutter#184155) 2026-04-06 [email protected] Roll Skia from 163dfdf500c7 to e264d870a380 (2 revisions) (flutter/flutter#184674) 2026-04-06 [email protected] Keep last character obscured when toggling obscureText (flutter/flutter#183488) 2026-04-06 [email protected] Parse scheme file with XML parser for SwiftPM migrator (flutter/flutter#184525) 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 [email protected],[email protected] 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
…ter#184728) This reverts commit b213589.
Fixes flutter#175546 Upper image is unclipped, bottom is clipped: <table width="100%"> <thead> <tr> <th align="center">With Change</th> <th align="center">Without Change</th> </tr> </thead> <tbody> <tr> <td align="center" width="50%"> <img src="https://github.com/user-attachments/assets/c713dd0f-8cfd-4e7d-9070-3bf51a89f50a" style="max-width: 50%;"></img> </td> <td align="center" width="50%"> <img src="https://github.com/user-attachments/assets/fc23ff88-bd64-44d0-a840-e7ba58638943" style="max-width: 50%;"></img> </td> </tr> <tr> <td align="center"> <img src="https://github.com/user-attachments/assets/fef237f1-9e4f-4376-a251-22335cf7a324" style="max-width: 50%;"></img> </td> <td align="center"> <img src="https://github.com/user-attachments/assets/db707bf1-2bd8-4c39-a510-ca45f7730a0a" style="max-width: 50%;"></img> </td> </tr> </tbody> </table>
…er#184728) This reverts commit a488da3 because the bot is failing to do so in flutter#184724 Revert because skia gold seems bugged w.r.t. the original pr, so try relanding it to reset skia gold state
Relands flutter#184471 which [was reverted](flutter#184728) because of suspected skia gold bug where the triage button was not working for the created digests. I also changed the names of the output files just in case, to make sure the state doesn't collide with old.
Fixes #175546
Upper image is unclipped, bottom is clipped: