-
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_platform_view] only recycle maskView when the view is applying mutators #41573
Conversation
bac5f99
to
f384936
Compare
auto label is removed for flutter/engine, pr: 41573, due to - The status or check suite Linux mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
auto label is removed for flutter/engine, pr: 41573, due to - The status or check suite Linux mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Yes, I discovered some other bugs in the maskViewPool, which was caused because I had an assumption that all maskView can be recycled every frame. This isn't true because sometimes, a PlatformView doesn't need to be re-composited, thus the I'm working on a fix and should have it ready by EOD today. |
a6ad852
to
9d5d996
Compare
I've seen some failures locally but shouldn't be related to this PR. (They didn't fell in this PR in previous ci runs). |
[maskView reset]; | ||
} | ||
self.availableIndex++; | ||
maskView = [self.pool anyObject]; |
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.
How do you know if this view is available for reuse?
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.
When the view is in use, it is removed from the pool:
See line 493 below.
self.availableIndex = 0; | ||
- (void)insertViewToPool:(FlutterClippingMaskView*)maskView { | ||
FML_DCHECK(![self.pool containsObject:maskView]); | ||
[self.pool addObject:maskView]; |
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.
The user of the maskView decides to insert the view back to the pool when they are done with the maskView
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.
Note: need to add capacity check here.
Updated PR description to reflect the new approach. |
Note to self: |
This seems WIP till @cyanglaz is back. |
remove format revert format change fix typo draft rework recycle pool fix comments and documents
a1c98a6
to
27dbd8c
Compare
// | ||
// The `bounding_rect` is the final bounding rect of the PlatformView | ||
// (EmbeddedViewParams::finalBoundingRect). If a clip mutator's rect contains the final bounding | ||
// rect of the PlatformView, the clip mutator is not applied for performance optimization. | ||
// | ||
// This method is only called when thew `embedded_view` needs to be re-composited at the current |
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.
typo
|
||
@end | ||
|
||
@implementation FlutterClippingMaskViewPool : NSObject | ||
|
||
- (instancetype)initWithCapacity:(NSInteger)capacity { | ||
if (self = [super init]) { | ||
_pool = [[NSMutableArray alloc] initWithCapacity:capacity]; | ||
_pool = [[NSMutableSet alloc] init]; |
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.
nit: initWithCapacity
to save some hash extending operations?
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 have considered it and decided go against it.
For most of the pages, there are only 1 static PlatformViews. And even for scrolling situation, it is rear that many PlatformViews need to be clipped at the same time. So the set would rarely hit the capacity.
Or maybe change it to initWithCapacity:1
during initialization? I think in most cases, the PlatformView would have a clip.
return maskView; | ||
} | ||
|
||
- (void)recycleMaskViews { | ||
self.availableIndex = 0; | ||
- (void)insertViewToPool:(FlutterClippingMaskView*)maskView { |
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.
nit: insertViewToPoolIfNeeded
?
@@ -1473,7 +1651,8 @@ void addPlatformView( | |||
const int valueString = 7; | |||
const int valueUint8List = 8; | |||
const int valueMap = 13; | |||
|
|||
print(_createdPlatformViews); | |||
print(platformViewKey); |
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.
remove
// | ||
// Note that `views_to_recomposite_` does not represent all the views in the view hierarchy, | ||
// if a PlatformView does not change its composition parameter from last frame, it is not | ||
// included in the `views_to_recomposite_`. |
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 we should put this in implementation file instead, since we rarely look at the header file. A large part of them are more helpful to implementors and not callers.
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.
Good point.
…126934) flutter/engine@fe24767...5cf141f 2023-05-16 godofredoc@google.com Add linux_clang_tidy builder. (flutter/engine#41990) 2023-05-16 ychris@google.com [ios_platform_view] only recycle maskView when the view is applying mutators (flutter/engine#41573) 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 rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…sions) (#126961) Manual roll requested by zra@google.com flutter/engine@fe24767...1c775e3 2023-05-16 zanderso@users.noreply.github.com Revert "[ios_platform_view] only recycle maskView when the view is applying mutators" (flutter/engine#42080) 2023-05-16 gspencergoog@users.noreply.github.com [macOS] Wait for binding to be ready before requesting exits from framework (flutter/engine#41753) 2023-05-16 gspencergoog@users.noreply.github.com [linux] Wait for binding to be ready before requesting exits from framework (flutter/engine#41782) 2023-05-16 jacksongardner@google.com Initial support for images in Skwasm (flutter/engine#42019) 2023-05-16 jacksongardner@google.com Use new `unresolvedCodePoints` API from skia. (flutter/engine#41991) 2023-05-16 jason-simmons@users.noreply.github.com Convert public API NativeFieldWrapper classes to abstract interfaces (flutter/engine#41945) 2023-05-16 737941+loic-sharma@users.noreply.github.com [Windows] Add force redraw to the C++ client wrapper (flutter/engine#42061) 2023-05-16 godofredoc@google.com Fix drone_dimension host_engine_builder. (flutter/engine#42068) 2023-05-16 godofredoc@google.com Add linux_clang_tidy builder. (flutter/engine#41990) 2023-05-16 ychris@google.com [ios_platform_view] only recycle maskView when the view is applying mutators (flutter/engine#41573) 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 rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…plying mutators #41573" (#42115) The original PR (#41573) was reverted due to flutter/flutter#126951 The issue will be fixed in #42079 This needs to be landed after #42079 fixes: flutter/flutter#125620 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…plying mutators #41573" (#42231) Reverts #42115 Failing on the framework tree as in https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20platform_views_scroll_perf_ios__timeline_summary/11103/overview
…lutter#126934) flutter/engine@fe24767...5cf141f 2023-05-16 godofredoc@google.com Add linux_clang_tidy builder. (flutter/engine#41990) 2023-05-16 ychris@google.com [ios_platform_view] only recycle maskView when the view is applying mutators (flutter/engine#41573) 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 rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…sions) (flutter#126961) Manual roll requested by zra@google.com flutter/engine@fe24767...1c775e3 2023-05-16 zanderso@users.noreply.github.com Revert "[ios_platform_view] only recycle maskView when the view is applying mutators" (flutter/engine#42080) 2023-05-16 gspencergoog@users.noreply.github.com [macOS] Wait for binding to be ready before requesting exits from framework (flutter/engine#41753) 2023-05-16 gspencergoog@users.noreply.github.com [linux] Wait for binding to be ready before requesting exits from framework (flutter/engine#41782) 2023-05-16 jacksongardner@google.com Initial support for images in Skwasm (flutter/engine#42019) 2023-05-16 jacksongardner@google.com Use new `unresolvedCodePoints` API from skia. (flutter/engine#41991) 2023-05-16 jason-simmons@users.noreply.github.com Convert public API NativeFieldWrapper classes to abstract interfaces (flutter/engine#41945) 2023-05-16 737941+loic-sharma@users.noreply.github.com [Windows] Add force redraw to the C++ client wrapper (flutter/engine#42061) 2023-05-16 godofredoc@google.com Fix drone_dimension host_engine_builder. (flutter/engine#42068) 2023-05-16 godofredoc@google.com Add linux_clang_tidy builder. (flutter/engine#41990) 2023-05-16 ychris@google.com [ios_platform_view] only recycle maskView when the view is applying mutators (flutter/engine#41573) 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 rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…ew is applying mutators flutter#41573" (flutter#42231)" This reverts commit 2586cbe.
…plying mutators #42115" (#42823) Relands #42115, which was reverted in #42231 due to a crash in the framework test. The crash is due to a memory management issue that I fixed it in this PR, I also added a scenario test to catch the crash. fixes: flutter/flutter#125620 See also: orignal PR #41573 for more details. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…plying mutators flutter#42115" (flutter#42823) Relands flutter#42115, which was reverted in flutter#42231 due to a crash in the framework test. The crash is due to a memory management issue that I fixed it in this PR, I also added a scenario test to catch the crash. fixes: flutter/flutter#125620 See also: orignal PR flutter#41573 for more details. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
A mistake was introduced in #39498 where the maskViews are already recycles each frame.
Sometimes a PlatformView does not need to be re-composite: (https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm#L398-L401), so the mask view for such PlatformView should not be recycled.
This PR changed the
recycleMaskViews
API to allow individual maskviews to be recycled.ApplyMutator
then only recycle the maskView for that particular PlatformView.The MaskViewPool is also reworked to be simpler.
applyMutator
, it removes current the maskView, insert the maskView to the pool.fixes: flutter/flutter#125620
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.