-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Always use texture layer when displaying an Android view #100091
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
Conversation
| /// * [AndroidView] which is a widget that is used to show an Android view. | ||
| /// * [PlatformViewsService] which is a service for controlling platform views. | ||
| class RenderAndroidView extends RenderBox with _PlatformViewGestureMixin { | ||
| class RenderAndroidView extends PlatformViewRenderBox { |
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.
Making RenderAndroidView extend PlatformViewRenderBox allows AndroidViewSurface to continue to extend PlatformViewSurface due to the updateRenderObject override.
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| controller = viewController; | ||
| viewController.addOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| viewController.pointTransformer = (Offset offset) => globalToLocal(offset); |
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 seems to be bug currently. pointTransformer is set in the controller during initialization, but it's not set again if the controller is changed.
| _viewController = viewController; | ||
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| controller = 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.
this calls the setter in the parent class. I don't like this API, but I'm trying to make this PR a non-breaking change.
| _viewController.removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| _viewController = viewController; | ||
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); |
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.
Is (controller as AndroidViewController) just the getter viewController? (Not the parameter)
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 cleaned this up. I removed viewController and overrode controller.
| /// Sets a new Android view controller. | ||
| /// | ||
| /// `viewController` must not be null. | ||
| set viewController(AndroidViewController 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.
Prob better name this paramter so it doesn't conflict with the getter 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.
I removed viewController and overrode controller instead.
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| controller = viewController; | ||
| viewController.addOnPlatformViewCreatedListener(_onPlatformViewCreated); |
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 looks a little confusing changing the property after sets the ivar. How about:
this. viewController.removeOnPlatformViewCreatedListener(_onPlatformViewCreated);
controller = viewController
controller.addOnPlatformViewCreatedListener(_onPlatformViewCreated);
controller.pointTransformer = (Offset offset) => globalToLocal(offset);
...
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
| @override | ||
| Future<void> _sendCreateMessage() async { | ||
| assert(!_initialSize.isEmpty, 'trying to create $TextureAndroidViewController without setting a valid size.'); | ||
| assert(_initialSize != null, 'trying to create $TextureAndroidViewController without setting an initial size.'); |
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.
can we test these 2 asserts?
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. This is guarded by the create() method, which doesn't call super.create unless _initialSize is set. These are tested in services/platform_views_test.dart.
| _viewController.removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| _viewController = viewController; | ||
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); |
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.
can this be tested? e.g. the listener is removed from the old controller. and added to the new controller
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 in a7eeb3a
cyanglaz
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
…iew (flutter#100091)" (flutter#100222)" This reverts commit 1c2c942.
Ensures that Android views are always rendered using a texture layer.
Related issue: #96679