-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS PlatformView only sets a maskView when necessary #37434
Conversation
ef2033e
to
b865ee5
Compare
There are scenario test golden failures
|
b865ee5
to
704d519
Compare
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.
Are the failing tests false positives from fragile tests, or is this actually causing unexpected side-effects?
@@ -32,6 +32,16 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |||
} | |||
@end | |||
|
|||
static bool ClipBoundsContainsPlatformViewBoundingRect(const SkRect& clipBounds, |
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.
This needs a declaration comment.
It would be especially helpful to explain what the bounds and rect are supposed to be relative to.
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.
(And what the matrix is applied to.)
const SkRect& platformViewBoundingRect, | ||
const SkMatrix& transformMatrix, | ||
CGFloat screenScale) { | ||
SkRect transformedClipBounds = transformMatrix.mapRect(clipBounds); |
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.
Maybe it's just because I'm not familiar with this code, but the logic here doesn't seem very obvious. E.g., I don't know why there's a reverse screen scale applied to one of the parameters (but not the other). Comments explaining why the code here is doing what it is doing would be good.
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.
I rearranged the code in ApplyMutators so that the reverseScreenScale matrix is added later, which helps eliminate the screen scale factor in this method. Hopefully it is now easier to understand.
@@ -32,6 +32,16 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |||
} | |||
@end | |||
|
|||
static bool ClipBoundsContainsPlatformViewBoundingRect(const SkRect& clipBounds, | |||
const SkRect& platformViewBoundingRect, |
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.
Optional nit for here and the local variables: while either snake_case or camelCase are allowed by style for C(++) functions in ObjC++ code, it looks like most of the surrounding code here is C++ using snake_case, so it seems like snake_case for these would be more consistent.
@@ -280,7 +280,9 @@ class FlutterPlatformViewsController { | |||
// T_1 is applied to C_2, T_3 and T_4 are applied to C_5, and T_6 is applied to PLATFORM_VIEW. | |||
// | |||
// After each clip operation, we update the head to the super view of the current head. |
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.
Could you update the comment here to explain bounding_rect
? It's not clear from immediate context what exactly it is the bounds of.
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.
This is still missing.
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.
done
clipView.maskView = maskView; | ||
embedded_view.layer.transform = | ||
CATransform3DConcat(GetCATransform3DFromSkMatrix(transformMatrix), reverseTranslate); | ||
if (needMask) { |
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.
Optional: You could eliminate needMask
and just call clipView.maskView = maskView
each place you currently have needMask = YES
, so there's less local state to track.
The failing tests are due a bug, I had the matrix concatenation backwards. Will fix it along with other nits in the next few commits. |
686fdb5
to
f2c3d78
Compare
I'm not sure why mac_host_engine keeps failing on a seemingly unrelated impeller unit test.
The same test passed locally. |
The impeller unit test failure is related to flutter/flutter#114872 |
@stuartmorgan Updated per review comments, PTAL. |
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 other than a couple of missing comments (with the caveat that I'm not familiar with the details of this clipping system, so I'm just trusting you and the tests that all the matrix/transform logic is correct 🙂 ).
@@ -280,7 +280,9 @@ class FlutterPlatformViewsController { | |||
// T_1 is applied to C_2, T_3 and T_4 are applied to C_5, and T_6 is applied to PLATFORM_VIEW. | |||
// | |||
// After each clip operation, we update the head to the super view of the current head. |
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.
This is still missing.
@@ -241,6 +241,8 @@ - (NSMutableArray*)backdropFilterSubviews { | |||
|
|||
@interface FlutterClippingMaskView () | |||
|
|||
@property(nonatomic) CATransform3D reverseScreenScale; |
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.
This needs a declaration comment, per style guide.
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.
done
e8a2e84
to
e96abe0
Compare
Added comments to explain the bounding_rect parameter and reverseScreenScale property. |
e96abe0
to
f327175
Compare
The presub failure looks related to this patch but the fix ought to be simple. Should be good go soon! |
Yes, I'm currently working on a different local branch and plan to fix it later today. |
tests fix tests format review fix add scenario tset more scenario tests add docs and comments use offset.zero
8ce1db4
to
bdfe5f3
Compare
…ry (flutter/engine#37434) (#115621) Commit: 9c9f7818ac16b80e030cd101fe050e9e96f5c1eb
* 70b7445 Reland Added Badge.count constructor (flutter/flutter#115566) * 31f8631 fa7e1965e [Impeller] Fix glyph atlas uploads and renders (flutter/engine#37691) (flutter/flutter#115556) * a1ea383 Label should always be aligned with text in filled input decoration (flutter/flutter#115540) * c2b2950 Add selection feedback for both selection area and text field (flutter/flutter#115373) * 0344407 Rev package:pub_semver to the latest version (flutter/flutter#115570) * ac06523 Add Material 3 support for `Slider` - Part 2 (flutter/flutter#114624) * b181d07 a2fa4e9 cirrus to luci (flutter/plugins#6711) (flutter/flutter#115573) * e1efd0d b241e69fd [ui] reland add docs to FragmentShader (flutter/engine#37699) (flutter/flutter#115578) * efb0694 Remove unused flutter_attach_test_fuchsia (flutter/flutter#115515) * a5a368c 487ee66f6 [macOS] Merge FlutterRenderer and implementation (flutter/engine#37696) (flutter/flutter#115581) * 4ff7fc6 Fixes a bug where dragging a collapsed handle in TextField does not vibrate (flutter/flutter#115586) * 20be280 da9534ea6 [macOS] Consolidate external texture classes (flutter/engine#37703) (flutter/flutter#115585) * 8a7102e Roll Flutter Engine from da9534ea6534 to d955a72c5604 (3 revisions) (flutter/flutter#115589) * e1903a2 Roll Flutter Engine from d955a72c5604 to 1e1a4ab3c993 (4 revisions) (flutter/flutter#115592) * 78390a0 Roll Flutter Engine from 1e1a4ab3c993 to b65c24ce621a (2 revisions) (flutter/flutter#115598) * 75a0a72 [devicelab] measure entire release folder size, zipped (flutter/flutter#115597) * 59a01b6 Roll Flutter Engine from b65c24ce621a to 49b52db603cc (3 revisions) (flutter/flutter#115606) * ec03f1c Revert "[devicelab] measure entire release folder size, zipped (#115597)" (flutter/flutter#115609) * 710e708 Improve showSnackBar documentation (flutter/flutter#114612) * 915c3de Roll Flutter Engine from 49b52db603cc to 80b25a302b4c (2 revisions) (flutter/flutter#115608) * 450f162 Roll Flutter Engine from 80b25a302b4c to e812122e4060 (2 revisions) (flutter/flutter#115614) * 0b33b85 [devicelab] measure entire release folder size, zipped (flutter/flutter#115612) * 9379c32 Revert "[devicelab] measure entire release folder size, zipped (#115612)" (flutter/flutter#115617) * b746557 f27666d2f [macOS] Merge FlutterBackingStore implementations (flutter/engine#37730) (flutter/flutter#115616) * 5487a7d Roll Flutter Engine from f27666d2f4da to 39f546585b0b (2 revisions) (flutter/flutter#115618) * f261c2f update comments (flutter/flutter#115603) * 9c9f781 04aea3c47 iOS PlatformView only sets a maskView when necessary (flutter/engine#37434) (flutter/flutter#115621) * 6926960 4ca2c1d78 Roll Skia from 55f654bf5cff to 9d56e506b4df (13 revisions) (flutter/engine#37739) (flutter/flutter#115625) * de4c0b1 Use `double.isNaN` instead of `... == double.nan` (which is always false) (flutter/flutter#115424) * a655f85 a62736769 Roll Skia from 9d56e506b4df to d693b4b9fe5e (5 revisions) (flutter/engine#37741) (flutter/flutter#115640) * 18c8727 f092cd826 Roll Fuchsia Mac SDK from SVtX810D2U_ZgBcpx... to tklUfTsSOVKk49tYq... (flutter/engine#37742) (flutter/flutter#115643)
TL;DR
The maskView reduces the performance, and we should avoid the usage as much as possible, details in: flutter/flutter#107486 (comment)
This PR checks whether the the bounding rect of a clip mutator contains the entire PlatformView. If that is the case, we skip that clip mutator because the visual result will be the same.
This is particular helpful when there are multiple PlatformViews in a list view because there is usually a clipRect layer around the whole list view but the PlatformViews aren't really need to be clipped.
Fixes: flutter/flutter#107486
Performance comparison
Before fix:
After fix:
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.