-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
We implemented the iOS platform view clipping by adding extra UIViews in between the platform view and FlutterView and perform one clip on each added UIView.
Implementation details can be found here: flutter/engine#9075
Inevitably, this implementation will cause a gesture bug as follow:
-
Put the finger on top of the platform view and start performing a dragging gesture.
-
If an additional clip is added to the platform view during the dragging gesture(Or a clip is removed), we have to
ReconstructClipViewsChain. It leads to the platform view to be removed from the FlutterView's and then added back. -
This removing and adding will cause the iOS system lost the dragging gesture. Thus sends a "touch cancelled" event to dart in
- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event. -
Since technically, we are still dragging (we have never lifted the finger of the screen during this sequence). we should never cancel this gesture. It will sometimes lead to a very bad visual behavior depends on the implementation of the platform view.
One of the example that I reproduced is here:
In the first half of the video, my finger was on the black area, AKA non platform view area. The scrolling was smooth.
After the pause, I started to touch on the white area, AKA WebView(PlatformView). When the WebView reached the top of the screen, an extra clip was added to the layer tree for the WebView, and the gesture was cancelled. After that, the scrolling looks buggy.
An example code to reproduce the issue:
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: WebViewSample(),
),
);
}
}
class WebViewSample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(child:ListView(
children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints(maxHeight: 500.0),
child: WebView(
initialUrl: Uri.dataFromString(
'<p>Web view sample</p>' * 1000,
).toString(),
),
)
],
),
color: Colors.black,);
}
}We might need to find a better solution to perform clipping, or find a workaround to make the gesture not being cancelled during ReconstructClipViewsChain.
/cc @amirh
