-
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
remove obsolete check on FlutterPlatformViewsController::OnCreate #19819
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -122,15 +122,6 @@ | |||
} | |||
|
|||
void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult& result) { | |||
if (!flutter_view_.get()) { |
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.
Would this race condition be moved to a different part of the code after this change? What about ensuring that flutter_view_
isn't null
in the other parts of the code where it's used?
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.
Based on my own auditing of the code, no. We're no longer creating a FlutterView here, we're creating a different UI view that's delegating based on the VC rather than the View.
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.
+1. I think we should make sure we are confident to say that the flutter_view_
is ready when the platform view is going to be displayed.(when Rasterizer:Draw
happens)
What about we assert that in CompositeWithParams
? Or even earlier in PrerollCompositeEmbeddedView
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 can't have a rasterizer without a surface (which the Flutter View creates).
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.
Right, I meant that since we are confident that if the Rasterizer:Draw is called, the flutter_view_
should not nil, we can assert the flutter_view_
in either CompositeWithParams
or PrerollCompositeEmbeddedView
.
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 the animator won't be started unless you have a surface either - so there won't be any composition/preroll calls without a surface (-> view)
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 read through the code for FlutterPlatformViewsController and didn't see an obvious crash that could result from flutter_view_
being nil. It is usually used in identity comparisons and the target for objc messages.
Amir said we could get rid of the error when flutter/flutter#23787 is addressed, which it isn't addressed yet officially, fwiw.
I find this hard to reason about since we can't know when flutter_view_
is getting set by just reading the code. At some point it shouldn't be nil right? It seems like we should push this assert down lower to things logic that assumes it's not nil.
I've written a test case that passes in headless mode. I'm not clear on what's left toa ddress for that. |
@dnfield you are right. We are not relying on the |
The GetLayer call happens from SubmitFrame, which also only is called if the animator is enabled and the rasterizer is working - which require a view/surface. I thnk that should be safe, but happy to add some DCHECKs to it if that would help. |
@godofredoc @digiter - I'm not sure why the mac builds are failing here. It's https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket.appspot.com/8874586729338893104/+/steps/lint_test/0/stdout - seems like Xcode might not be installed on teh bot(s)? |
A DCheck in any of the places sounds good. It might help future debugging. |
Sprinkled those into the methods that seem to need them :) |
@@ -472,6 +466,7 @@ | |||
bool FlutterPlatformViewsController::SubmitFrame(GrContext* gr_context, | |||
std::shared_ptr<IOSContext> ios_context, | |||
std::unique_ptr<SurfaceFrame> frame) { | |||
FML_DCHECK(flutter_view_); |
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 think this one is good enough, I'm ok with removing the other ones.
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.
My thought is that these are free outside debug mode, and this will help clarify things if we refactor any of this in the future. WDYT?
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.
Sure, SG! We probably don't need the one in PrerollCompositeEmbeddedView
, as it seems this method doesn't use flutter_view_
at all.
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
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
Engine redness is due to bad recipe land that I've reverted. I'm going to land this on red to kick the build. |
Remove obsolete check on FlutterPlatformViewsController::OnCreate (flutter#19819)
* Cherry pick 3d104f4 Remove obsolete check on FlutterPlatformViewsController::OnCreate (#19819) * Migrating web_analysis from Cirrus to LUCI (PART 1) (#19726) * explicitly check out framework rc branch Co-authored-by: nturgut <nurhan@google.com> Co-authored-by: Christopher Fujino <christopherfujino@gmail.com>
Description
When initially landed (92944f7), this check made sense. After #9075 we no longer need to touch the flutter_view_ directly in OnCreate.
A recent change to lifecycle logic means that we sometimes get these calls (particularly on application relaunch for reasons I don't grasp) in different orders sometimes. Specifically, we no longer let
viewDidLayoutSubviews
create the surface unless the application is active - and sometimes get to that point (it's called before applicationBecameActive).I'm not able to make this fail in local app that actually calls it in this order. I have to think about how to test this.
Related Issues
Fixes flutter/flutter#23787
Fixes flutter/flutter#61584
Tests
I added the following tests:
Test that we can successfully create a platform view without a flutter_view_.