Skip to content

[web] Gestures inside iframe doesn't work on iOS #70858

@otopba

Description

@otopba

FlatButton inside iframe doesn't work at iOS safari. I can't click FlatButton. But everything works great at desktop web and Android.

Tested on iOS 14.1 iPhone 7

source code here: https://github.com/otopba/flutter-iframe-sample
web site here: https://web-ios-links.000webhostapp.com/

image2020-11-19 22-06-16

main.dart

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _clicked = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Row(
          children: [
            Text("clicked = $_clicked"),
            SizedBox(
              width: 200,
              height: 200,
              child: FlatButton(
                color: Colors.yellow,
                child: Center(
                  child: Text("Open https://google.com"),
                ),
                onPressed: _openUrl,
              ),
            ),
          ],
        ),
      ),
    );
  }

  Future<bool> _openUrl() async {
    print("Click");
    setState(() {
      _clicked = true;
    });
    final url = "https://www.google.com/";
    if (await canLaunch(url)) {
      final success = await launch(url, webOnlyWindowName: "_blank");
      if (success) {
        return true;
      }
    }
    return false;
  }
}

index.html

<!DOCTYPE html>
<html>
<body>
 <h1>iframe:</h1>
<iframe src="flutter.html"></iframe>
</body>
</html>

flutter.html

<!DOCTYPE html>
<html>
<head>
  <base href="/">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="iosurl">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png"/>

  <title>iosurl</title>
  <link rel="manifest" href="manifest.json">
</head>
<body>
  <!-- This script installs service_worker.js to provide PWA functionality to
       application. For more information, see:
       https://developers.google.com/web/fundamentals/primers/service-workers -->
  <script>
    if ('serviceWorker' in navigator) {
      window.addEventListener('flutter-first-frame', function () {
        navigator.serviceWorker.register('flutter_service_worker.js');
      });
    }
  </script>
  <script src="main.dart.js" type="application/javascript"></script>
</body>
</html>

pubspec.yaml

name: iosurl
description: A new Flutter project.

publish_to: none
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.1
  url_launcher: ^5.7.10
  url_launcher_web: ^0.1.5+1

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

flutter doctor -v

[✓] Flutter (Channel master, 1.24.0-8.0.pre.255, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-RU)
    • Flutter version 1.24.0-8.0.pre.255 at /Users/yuriy.dorofeev/flutter
    • Framework revision 5f56db0a03 (3 days ago), 2020-11-16 13:23:05 -0500
    • Engine revision fae92ed574
    • Dart version 2.12.0 (build 2.12.0-46.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/yuriy.dorofeev/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6858069/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6858069/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3 EAP)
    • IntelliJ at /Users/yuriy.dorofeev/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 51.0.4
    • Dart plugin version 203.5251.27

[✓] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (5 available)
    • JNY LX1 (mobile)              • EPHUT20221023832                         • android-arm64  • Android 10 (API 29)
    • ONEPLUS A6010 (mobile)        • ae52d68a                                 • android-arm64  • Android 10 (API 29)
    • iPhone Uyra Dorofeev (mobile) • 3e70e18f1b851fa442c436cda31756eb196a0a91 • ios            • iOS 14.1
    • Web Server (web)              • web-server                               • web-javascript • Flutter Tools
    • Chrome (web)                  • chrome                                   • web-javascript • Google Chrome 86.0.4240.198
    ! Error: iPhone Uyra Dorofeev is busy: Copying cache files from device. Xcode will continue when iPhone Uyra Dorofeev is finished. (code -10)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listbrowser: safari-iosonly manifests in Safari on iOSengineflutter/engine related. See also e: labels.f: gesturesflutter/packages/flutter/gestures repository.found in release: 1.24Found to occur in 1.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions