-
Notifications
You must be signed in to change notification settings - Fork 6k
The ForwardingGestureRecognizers to have back reference to the PlatformViewsController so it can access FlutterViewController when its available
#20708
Conversation
dnfield
left a 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.
This is fine to fix the immediate issue. We still have some problems if someone creates a headless engine and tries to make a platform view before assigning the VC
We also have problems if someone creates the engine first and the VC doesn't get shown soon enough (e.g. they use initWithEngine).
|
I think nevertheless, this helps the I can also add a fix for headless mode too. Something like I mentioned in flutter/flutter#64228 (comment) |
|
Actually, for initWithEngine, we can set view controller to |
f271130 to
cfe0cd2
Compare
| return pixel[3]; | ||
| } | ||
|
|
||
|
|
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: remove extra newline
| - (void)maybeSetupPlatformViewChannels { | ||
| if (_shell && self.shell.IsSetup()) { | ||
| if ([self platformViewsController] != nullptr) { | ||
| [self platformViewsController]->SetFlutterViewController([self viewController]); |
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.
If this gets called from headless, we're toast :)
We could consider calling this from setViewController in here. In fact, I'm not clear on why we wouldn't.
But we could still run into the issue where the PlatformViewsController is created after the shell is, and the VC isn't attached until some later point in time.
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.
Why would this fail on headless? Unless they call this as private API, maybeSetupPlatformViewChannels is only called in 2 places in this class and both places look fine.
If the PlatformViewsController is created after the shell, maybeSetupPlatformViewChannels should be called in setViewController when FlutterViewController is available, which then it is possible for the platform views to receive touch events.
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.
It's called here:
| [self maybeSetupPlatformViewChannels]; |
And we don't necessarily have a view controller yet.
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 that is called by runEngine, which is public API. And it's normal to call that before adding a VC to the engine or add to app.
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 guess we can't fix this way then. Probably better to go back to the fix that we discussed in the issue.
PlatformViewsController gets FlutterViewController as early as possiblePlatformViewsController gets FlutterViewController as early as possible, PlatformViewsController update FlutterViewController when available
a2d2782 to
4b4be43
Compare
|
@dnfield Updated so that |
| #include "flutter/shell/platform/darwin/ios/ios_context.h" | ||
| #include "third_party/skia/include/core/SkPictureRecorder.h" | ||
|
|
||
| @class FlutterTouchInterceptingView; |
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.
Had to forward declare here because now FlutterTouchInterceptingView references to FlutterPlatformViewsController.
LongTerm, we should refactor all the objc class in this file to their own files.
|
@dnfield Ready for another review :) |
dnfield
left a 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.
LGTM
PlatformViewsController gets FlutterViewController as early as possible, PlatformViewsController update FlutterViewController when availableForwardingGestureRecognizers to have back reference to the PlatformViewsController so it can access FlutterViewController when its available
…tformViewsController` so it can access `FlutterViewController` when its available (flutter#20708)
…the `PlatformViewsController` so it can access `FlutterViewController` when its available (flutter/engine#20708)
…the `PlatformViewsController` so it can access `FlutterViewController` when its available (flutter/engine#20708)
* update dart revision * Fix EGL_BAD_SURFACE when app is paused (#20735) * The `ForwardingGestureRecognizers` to have back reference to the `PlatformViewsController` so it can access `FlutterViewController` when its available (#20708) * Remove image sizes from Picture::GetAllocationSize (#20673) * update licenses golden Co-authored-by: Emmanuel Garcia <[email protected]> Co-authored-by: Chris Yang <[email protected]> Co-authored-by: Jason Simmons <[email protected]>
* Update 1.20 engine to use Dart 2.9.2 * update license goldens * Fix EGL_BAD_SURFACE when app is paused (#20735) * The `ForwardingGestureRecognizers` to have back reference to the `PlatformViewsController` so it can access `FlutterViewController` when its available (#20708) * cherry-pick e09af86 * skip linting since this was enabled in CI after this release branch cut commit. Co-authored-by: Emmanuel Garcia <[email protected]> Co-authored-by: Chris Yang <[email protected]>
Description
This PR makes
PlatformViewsControllergetFlutterViewControlleras early as possible when first launch.Related Issues
Fixes flutter/flutter#64228
Tests
I added the following tests:
testViewFlutterViewControllerIsSetForPlatformView
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.