Unverified Commit e82a69a9 authored by Maurice Parrish's avatar Maurice Parrish Committed by GitHub

Create flag to enable/disable FlutterView render surface conversion (#85648)

parent fecf2383
......@@ -179,6 +179,24 @@ class PlatformViewsService {
return controller;
}
/// Whether the render surface of the Android `FlutterView` should be converted to a `FlutterImageView`.
///
/// When adding platform views using
/// [Hybrid Composition](https://flutter.dev/docs/development/platform-integration/platform-views),
/// the engine converts the render surface to a `FlutterImageView` to improve
/// animation synchronization between Flutter widgets and the Android platform
/// views. On Android versions < 10, this can have some performance issues.
/// This flag allows disabling this conversion.
///
/// Defaults to true.
static Future<void> synchronizeToNativeViewHierarchy(bool yes) {
assert(defaultTargetPlatform == TargetPlatform.android);
return SystemChannels.platform_views.invokeMethod<void>(
'synchronizeToNativeViewHierarchy',
yes,
);
}
// TODO(amirh): reference the iOS plugin API for registering a UIView factory once it lands.
/// This is work in progress, not yet ready to be used, and requires a custom engine build. Creates a controller for a new iOS UIView.
///
......
......@@ -141,6 +141,8 @@ class FakeAndroidPlatformViewsController {
int? lastClearedFocusViewId;
bool synchronizeToNativeViewHierarchy = true;
void registerViewType(String viewType) {
_registeredViewTypes.add(viewType);
}
......@@ -166,6 +168,8 @@ class FakeAndroidPlatformViewsController {
return _setDirection(call);
case 'clearFocus':
return _clearFocus(call);
case 'synchronizeToNativeViewHierarchy':
return _synchronizeToNativeViewHierarchy(call);
}
return Future<dynamic>.sync(() => null);
}
......@@ -299,6 +303,11 @@ class FakeAndroidPlatformViewsController {
lastClearedFocusViewId = id;
return Future<dynamic>.sync(() => null);
}
Future<dynamic> _synchronizeToNativeViewHierarchy(MethodCall call) {
synchronizeToNativeViewHierarchy = call.arguments as bool;
return Future<dynamic>.sync(() => null);
}
}
class FakeIosPlatformViewsController {
......
......@@ -218,6 +218,11 @@ void main() {
]),
);
});
test('synchronizeToNativeViewHierarchy', () async {
await PlatformViewsService.synchronizeToNativeViewHierarchy(false);
expect(viewsController.synchronizeToNativeViewHierarchy, false);
});
});
group('iOS', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment