flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.17k stars 26.65k forks source link

[Flutter Web][Android Chrome] ListView freeze after scroll in IFrame #118558

Open prtrifun opened 1 year ago

prtrifun commented 1 year ago

Steps to Reproduce

  1. Execute flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0 on the ListView code sample
  2. Replace X.X.X.X in IFrame code sample with your IP address (Use ipconfig getifaddr en1 for wireless, or ipconfig getifaddr en0 for ethernet to fetch you IP address)
  3. Execute flutter run -d web-server --web-port 8081 --web-hostname 0.0.0.0 on the IFrame code sample
  4. Open chrome on android device or emulator and go to 'http://X.X.X.X:8081' (replace X.X.X.X with your IP address)
  5. Scroll immediately after the page loads, then tap on a text filed

Expected results: Expceted that I can focus text field after scroll.

Actual results: Nothing can gain focus after scroll.

ListView code sample ``` import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( body: ListView( children: [ for (int i = 0; i < 20; i++) Padding( padding: const EdgeInsets.all(8.0), child: TextFormField(), ), ], ), ), ); } } ```
IFrame code sample ``` import 'package:flutter/material.dart'; import 'dart:html'; import 'dart:ui' as ui; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const IframeView(source: 'http://X.X.X.X:8080'), ); } } class IframeView extends StatefulWidget { final String source; const IframeView({Key? key, required this.source}) : super(key: key); @override _IframeViewState createState() => _IframeViewState(); } class _IframeViewState extends State { // Widget _iframeWidget; final IFrameElement _iframeElement = IFrameElement(); @override void initState() { super.initState(); _iframeElement.src = widget.source; _iframeElement.style.border = 'none'; //ignore: undefined_prefixed_name ui.platformViewRegistry.registerViewFactory( 'iframeElement', (int viewId) => _iframeElement, ); } @override Widget build(BuildContext context) { return HtmlElementView( key: UniqueKey(), viewType: 'iframeElement', ); } } ```

So far, I only managed to reproduce this on Android on chrome browser.

huycozy commented 1 year ago

@prtrifun Thanks for filing the issue. I tested this on the latest stable 3.3.10 and master 3.7.0-21.0.pre.44 channels. It seems the issue is only reproduced on the master channel.

Which channel are you facing this issue with? Can you retry on these channels and confirm the same behavior?

flutter doctor -v (stable and master) ```bash [✓] Flutter (Channel stable, 3.3.10, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) • Flutter version 3.3.10 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 135454af32 (13 hours ago), 2022-12-15 07:36:55 -0800 • Engine revision 3316dd8728 • Dart version 2.18.6 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/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 11.0.13+0-b1751.21-8125866) [✓] IntelliJ IDEA Community Edition (version 2022.1.1) • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app • 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 [✓] VS Code (version 1.73.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.54.0 [✓] Connected device (3 available) • SM T225 (mobile) • R9JT3004VRJ • android-arm64 • Android 12 (API 31) • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ``` ```bash [!] Flutter (Channel master, 3.7.0-21.0.pre.44, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) • Flutter version 3.7.0-21.0.pre.44 on channel master at /Users/huynq/Documents/GitHub/flutter_master ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 8c2fdb803e (14 hours ago), 2023-01-16 11:51:11 +0000 • Engine revision f790304409 • Dart version 3.0.0 (build 3.0.0-122.0.dev) • DevTools version 2.20.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio Dolphin 2021.3.1.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/Android Studio Dolphin 2021.3.1.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 11.0.13+0-b1751.21-8125866) [!] Android Studio (version 2022.1) • Android Studio at /Applications/Android Studio Electric Eel 2022.1.1.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 ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio. [✓] IntelliJ IDEA Community Edition (version 2022.1.1) • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app • 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 [✓] VS Code (version 1.74.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.56.0 [✓] Connected device (3 available) • SM T225 (mobile) • R9JT3004VRJ • android-arm64 • Android 13 (API 33) • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.87 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 2 categories. ```
prtrifun commented 1 year ago

@huycozy Bug report was created with stable version 3.3.7, and I just tested with latest stable 3.3.10, and bug still persists and I can reproduce it.

flutter doctor -v ``` [✓] Flutter (Channel stable, 3.3.10, on macOS 13.0.1 22A400 darwin-arm, locale en-GB) • Flutter version 3.3.10 on channel stable at /Users/trifke/Documents/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 135454af32 (5 weeks ago), 2022-12-15 07:36:55 -0800 • Engine revision 3316dd8728 • Dart version 2.18.6 • DevTools version 2.15.0 [!] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/trifke/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/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 11.0.13+0-b1751.21-8125866) [✓] VS Code (version 1.74.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-arm64 • macOS 13.0.1 22A400 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
huycozy commented 1 year ago

@prtrifun I retried on the latest stable 3.3.10 and master 3.7.0-22.0.pre.9 channels and can not reproduce the issue on both of them.

In my demo, I used Python to start web server instead of Flutter tool (due to for some reason, it can not be opened on my Android device when web server hosted by Flutter tool)

https://user-images.githubusercontent.com/104349824/213078239-803b1e4b-5958-48f0-8734-4c4e9e13148d.mp4

Can you retry using Python or your another preferred one to check this?

prtrifun commented 1 year ago

@huycozy For some reason everything is fine if you first click on text field. Please try to scroll first and then tap on something.

huycozy commented 1 year ago

@prtrifun Yes, I can see the issue now when scrolling a bit before touching on a TextField, the TextField can not gain focus.

The issue is reproducible on the latest stable and master channels.

Demo https://user-images.githubusercontent.com/104349824/213362100-6b162395-6a32-4bd1-8610-dcd6c0e2edd4.mp4
flutter doctor -v (stable and master) ```bash [✓] Flutter (Channel stable, 3.3.10, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) • Flutter version 3.3.10 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 135454af32 (13 hours ago), 2022-12-15 07:36:55 -0800 • Engine revision 3316dd8728 • Dart version 2.18.6 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/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 11.0.13+0-b1751.21-8125866) [✓] IntelliJ IDEA Community Edition (version 2022.1.1) • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app • 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 [✓] VS Code (version 1.73.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.54.0 [✓] Connected device (3 available) • SM T225 (mobile) • R9JT3004VRJ • android-arm64 • Android 12 (API 31) • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ``` ```bash [!] Flutter (Channel master, 3.7.0-23.0.pre.21, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) • Flutter version 3.7.0-23.0.pre.21 on channel master at /Users/huynq/Documents/GitHub/flutter_master ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6a9b2db4ac (39 minutes ago), 2023-01-18 21:03:37 -0500 • Engine revision 95b0c151f7 • Dart version 3.0.0 (build 3.0.0-136.0.dev) • DevTools version 2.20.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio Dolphin 2021.3.1.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/Android Studio Dolphin 2021.3.1.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 11.0.13+0-b1751.21-8125866) [!] Android Studio (version 2022.1) • Android Studio at /Applications/Android Studio Electric Eel 2022.1.1.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 ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio. [✓] IntelliJ IDEA Community Edition (version 2022.1.1) • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app • 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 [✓] VS Code (version 1.74.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.56.0 [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.87 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 2 categories. ```
iamzhibo commented 10 months ago

Hello, is this problem solved?

dinb1242 commented 2 weeks ago

even though gesture event is broken, I found that floating button and bottom navigation bar are work.

I think this issue is related in "Scrolling" event, since I've reproduced it using SingleChildScrollView and ListView and when I use SingleChildScrollView in Stack widget and it has siblings, I can click the sibling widgets, but can't click any widget in SingleChildScrollView.

for example:

Stack(
              children: [
                SingleChildScrollView(
                  child: Column(      <----- I can't click anything in SingleChildScrollView
                    children: [
                       ElevatedButton(onPressed: () => debugPrint('broken'), child: Text('button'))
                    ],
                  ),
                ),
                Positioned(   <-------- I can click ElevatedButton in this widget even though gesture event is broken.
                  bottom: 15,
                  left: 16,
                  right: 16,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: [
                      ElevatedButton(onPressed: () => debugPrint('Clicked!'), child: Text('button'))
                    ],
                  ),
                ),
              ],
            ),

Things that I found to recover the broken gesture event are:

I hope this issue to be fixed as soon as possible.

Added: This issue appears not only in chrome browser but also any other browsers in Android. I'm currently using Flutter 3.19.6 and this issue isn't fixed on this version.