Unverified Commit 4ead92cf authored by fzyzcjy's avatar fzyzcjy Committed by GitHub

Fix UiKitView which wrongly unconditionally repaints (#111790)

parent 88707f7c
......@@ -320,10 +320,13 @@ class RenderUiKitView extends RenderBox {
/// must have been created by calling [PlatformViewsService.initUiKitView].
UiKitViewController get viewController => _viewController;
UiKitViewController _viewController;
set viewController(UiKitViewController viewController) {
assert(viewController != null);
final bool needsSemanticsUpdate = _viewController.id != viewController.id;
_viewController = viewController;
set viewController(UiKitViewController value) {
assert(value != null);
if (_viewController == value) {
return;
}
final bool needsSemanticsUpdate = _viewController.id != value.id;
_viewController = value;
markNeedsPaint();
if (needsSemanticsUpdate) {
markNeedsSemanticsUpdate();
......
......@@ -260,6 +260,42 @@ void main() {
expect(renderBox.debugLayer, isNull);
});
});
test('markNeedsPaint does not get called when setting the same viewController', () {
FakeAsync().run((FakeAsync async) {
final Completer<void> viewCreation = Completer<void>();
const MethodChannel channel = MethodChannel('flutter/platform_views');
binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
assert(methodCall.method == 'create', 'Unexpected method call');
await viewCreation.future;
return /*textureId=*/ 0;
});
bool futureCallbackRan = false;
PlatformViewsService.initUiKitView(id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr).then((UiKitViewController viewController) {
final RenderUiKitView renderBox = RenderUiKitView(
viewController: viewController,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{},
);
layout(renderBox);
pumpFrame(phase: EnginePhase.paint);
expect(renderBox.debugNeedsPaint, isFalse);
renderBox.viewController = viewController;
expect(renderBox.debugNeedsPaint, isFalse);
futureCallbackRan = true;
});
viewCreation.complete();
async.flushMicrotasks();
expect(futureCallbackRan, true);
});
});
}
ui.PointerData _pointerData(
......
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