-
Notifications
You must be signed in to change notification settings - Fork 6k
[ios][platform_view] fix platform view clipping path intersection #54820
[ios][platform_view] fix platform view clipping path intersection #54820
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also create multiple CAShape layers instead
It's pretty hard to review the scenario tests, so I made a video. The existing scenarios only clip a single path. So I added a "multi paths" version for each scenario, and made sure the resulting clip is the intersection of the paths (rather than the union). golden.files.walk.through.mp4 |
After some research, it seems the only possible way is to have nested parents, each taking one shape layer as the mask. I don't think it's possible to just have one single mask that is the intersection of multiple shape layers. So this will require much larger change, and make the already complex view hierarchy more complex. |
Verified the scrolling ad banner example still runs smoothly on device, and avoids software rendering related instructions (by looking at the Instruments). |
c75d430
to
f075b4c
Compare
Eagerly waiting for this PR to be merged. Our video player ui broke after we upgraded to 3.24. 🙏🏻 |
@@ -358,14 +358,23 @@ final _skipTestsForImpeller = [ | |||
'ScenariosUITests/MultiplePlatformViewsTest/testPlatformView', | |||
'ScenariosUITests/NonFullScreenFlutterViewPlatformViewUITests/testPlatformView', | |||
'ScenariosUITests/PlatformViewMutationClipPathTests/testPlatformView', | |||
'ScenariosUITests/PlatformViewMutationClipPathMultipleClipsTests/testPlatformView', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't realize these were skipped for impeller... flutter/flutter#131888 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach makes sense. Its unfortunate to lose the hardware acceleration, but in most cases I suspect we'll only ever have rect clips.
Skia paths do have some ability to compute intersections/overlaps via skia path ops, which we definitely have access to: https://api.skia.org/SkPathOps_8h.html
Have you looked at using these methods to compute the path intersections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…154583) flutter/engine@e042202...1e74e9a 2024-09-03 [email protected] [ios][platform_view] fix platform view clipping path intersection (flutter/engine#54820) 2024-09-03 [email protected] [Impeller] Add all requested glyphs if TypographerContextSkia needs to create a new atlas (flutter/engine#54912) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: 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
@hellohuanlin can we cherry-picked this to the current stable channel? As it's most required fixed ASAP |
Yes we should cherry pick this. Thanks for creating the request. |
Failed to create CP due to merge conflicts. |
…utter#54820) It turns out that when there are multiple paths to clip, they are unioned together, rather than intersected. But clipping paths need to be intersected. There isn't any good way to intersect arbitrary paths. However, it is easy to intersect rect paths, which is the most common use case. Then we simply fallback to software rendering if we have to intersect non-rect paths. That is: **Case 1** Only 1 clipping path (either rect path or arbitrary path): Hardware rendering. This should be the most common use case **Case 2** Multiple rect clipping path: Hardware rendering. This is also common, and it's the linked issue that we are fixing. **Case 3** Other complex case (multiple non-rect clipping path) Fallback to software rendering. This should be rare. After flutter#53826, we don't have a working benchmark that measures the main thread anymore. However, this PR shouldn't impact our ad benchmark, since it only has 1 clipping path. I will verify manually by checking Instruments and make sure no software rendering is happening. But we really should make the benchmark working again, not just for performance improvement, but also for monitoring regression. *List which issues are fixed by this PR. You must list at least one issue.* Fixes flutter/flutter#153904 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
#54820 on stable branch. That PR was using some of the symbol changes in #54335, so I had so switch some back: e0a630d Cherry-pick request: flutter/flutter#154712 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
It turns out that when there are multiple paths to clip, they are unioned together, rather than intersected. But clipping paths need to be intersected.
There isn't any good way to intersect arbitrary paths. However, it is easy to intersect rect paths, which is the most common use case. Then we simply fallback to software rendering if we have to intersect non-rect paths. That is:
Case 1 Only 1 clipping path (either rect path or arbitrary path):
Hardware rendering. This should be the most common use case
Case 2 Multiple rect clipping path:
Hardware rendering. This is also common, and it's the linked issue that we are fixing.
Case 3 Other complex case (multiple non-rect clipping path)
Fallback to software rendering. This should be rare.
After #53826, we don't have a working benchmark that measures the main thread anymore. However, this PR shouldn't impact our ad benchmark, since it only has 1 clipping path. I will verify manually by checking Instruments and make sure no software rendering is happening. But we really should make the benchmark working again, not just for performance improvement, but also for monitoring regression.
List which issues are fixed by this PR. You must list at least one issue.
Fixes flutter/flutter#153904
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.