Skip to content

WebView touchstart events are invoked even when the WebView is not hit tested on iOS #30143

@amirh

Description

@amirh

Internal: b/126614142
Internal: b/285315999

Sample repro app:

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(MaterialApp(home: WebViewExample()));

class WebViewExample extends StatelessWidget {
  final Completer<WebViewController> _controller =
      Completer<WebViewController>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: WebView(
        initialUrl: 'https://master-docs-flutter-io.firebaseapp.com/',
        javascriptMode: JavascriptMode.unrestricted,
        onWebViewCreated: (WebViewController webViewController) {
          _controller.complete(webViewController);
        },
        onPageFinished: (String url) {
          injectTouchListener();
        },
        javascriptChannels: <JavascriptChannel> [
          JavascriptChannel(name: 'Log', onMessageReceived: (JavascriptMessage msg) { print(msg.message); })
        ].toSet() ,
      ),
      floatingActionButton: FloatingActionButton(
        child: Container(color: Colors.orange,),
          onPressed: () {}
          ),
    );
  }
  Future<void> injectTouchListener() async {
    final WebViewController controller = await _controller.future;
    controller.evaluateJavascript("document.addEventListener('touchstart', (event) => { Log.postMessage(String(event)); }, true);");
  }
}

On iOS the message is printing even when tapping the FAB.

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: platform-viewsEmbedding Android/iOS views in Flutter appscustomer: money (g3)found in release: 2.2Found to occur in 2.2found in release: 2.5Found to occur in 2.5p: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

Status

Engineer reviewed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions