Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer position shifts in scaled Platform Views in Flutter 3.19 Android #144278

Open
toda-bps opened this issue Feb 28, 2024 · 6 comments
Open
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: regression It was better in the past than it is now found in release: 3.19 Found to occur in 3.19 found in release: 3.20 Found to occur in 3.20 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team

Comments

@toda-bps
Copy link

toda-bps commented Feb 28, 2024

Steps to reproduce

  1. Run code sample.
  2. Click some links on the page.

Expected results

Click at the same location as the cursor.

example: 3.13.9.mp4, 3.16.9.mp4, 3.19.1_ios.mp4

  • note
    • There is no problem with 3.13.9/3.16.9/3.19.1 on iOS.
    • webview_flutter: 4.5.0

Actual results

Click at a different position than the cursor.

example: 3.19.1.mp4

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(const _App());

class _App extends StatelessWidget {
  const _App();

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: _Home());
  }
}

class _Home extends StatefulWidget {
  const _Home();

  @override
  State<_Home> createState() => _HomeState();
}

class _HomeState extends State<_Home> {
  final _controller = WebViewController();

  @override
  void initState() {
    super.initState();
    _controller
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..loadRequest(Uri.https('api.flutter.dev'));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Scaled WebView Tester'),
      ),
      body: Transform.scale(
        scale: 0.75,
        child: WebViewWidget(controller: _controller),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
3.13.9.mp4
3.16.9.mp4
3.19.1_ios.mp4
3.19.1.mp4

Flutter Doctor output

Doctor output

3.13.9

HEAD is now at d211f42860 [flutter_releases] Flutter stable 3.13.9 Framework Cherrypicks (#137284)
+ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.13.9, on macOS 14.3.1 23D60 darwin-x64, locale ja-JP)
    ! Flutter version 3.13.9 on channel [user-branch] at /System/Volumes/Data/buildroot/flutter_3.13
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (2 available)
[✓] Network resources

3.16.9

[!] Flutter (Channel [user-branch], 3.16.9, on macOS 14.3.1 23D60 darwin-x64, locale ja-JP)
    ! Flutter version 3.16.9 on channel [user-branch] at /System/Volumes/Data/buildroot/flutter_3.16
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (3 available)
[✓] Network resources

3.19.1

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.1, on macOS 14.3.1 23D60 darwin-x64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (3 available)
[✓] Network resources
@huycozy huycozy added the in triage Presently being triaged by the triage team label Feb 28, 2024
@huycozy
Copy link
Member

huycozy commented Feb 28, 2024

Thanks for the report. Reproduced the issue using the latest package version webview_flutter: ^4.7.0.

Checking this with pure platform view (Hybrid composition and Virtual display modes), the issue is reproduced as well. The pure platform view sample code: position_shifted_144278

Demo (Pure platform view and webview)
Pure platform view Webview
flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.19.1, on macOS 14.1 23B74 darwin-x64, locale en-VN)
    • Flutter version 3.19.1 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision abb292a07e (29 hours ago), 2024-02-20 14:35:05 -0800
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio Hedgehog.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 17.0.7+0-17.0.7b1000.6-10550314)

[✓] Android Studio (version 2022.2)
    • 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
    • android-studio-dir = /Applications/Android Studio.app/
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 14.1 23B74 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 121.0.6167.184

[✓] Network resources
    • All expected network resources are available.

• No issues found!
[!] Flutter (Channel master, 3.20.0-15.0.pre.20, on macOS 14.1 23B74 darwin-x64, locale en-VN)
    • Flutter version 3.20.0-15.0.pre.20 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 71fd015d05 (33 minutes ago), 2024-02-28 02:26:59 +0000
    • Engine revision fe7ea6d9c3
    • Dart version 3.4.0 (build 3.4.0-180.0.dev)
    • DevTools version 2.33.0-dev.11
    • 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 34.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.1)
    • 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
    • android-studio-dir = /Applications/Android Studio.app/
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

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

[✓] Connected device (4 available)
    • Pixel 7 (mobile) • 2B171FDH20084L                           • android-arm64  • Android 14 (API 34)
    • iPhone (mobile)  • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios            • iOS 15.8 19H370
    • macOS (desktop)  • macos                                    • darwin-x64     • macOS 14.1 23B74 darwin-x64
    • Chrome (web)     • chrome                                   • web-javascript • Google Chrome 122.0.6261.69

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@huycozy huycozy added platform-android Android applications specifically p: webview The WebView plugin package flutter/packages repository. See also p: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-android Owned by Android platform team fyi-ecosystem For the attention of Ecosystem team found in release: 3.19 Found to occur in 3.19 found in release: 3.20 Found to occur in 3.20 a: platform-views Embedding Android/iOS views in Flutter apps and removed in triage Presently being triaged by the triage team p: webview The WebView plugin package flutter/packages repository. See also p: labels. fyi-ecosystem For the attention of Ecosystem team labels Feb 28, 2024
@huycozy huycozy changed the title Pointer position shifts in scaled WebView in Flutter 3.19 Android Pointer position shifts in scaled Platform Views in Flutter 3.19 Android Feb 28, 2024
@S-ecki
Copy link

S-ecki commented Mar 1, 2024

We have the same issue in a production application.
We are depending on https://pub.dev/packages/aad_oauth, which internally uses webview_flutter.
We are not scaling the platform views ourselves, but strictly using the package linked above. If I understand this correctly, this means that all applications using the plugin and flutter 3.19 will have the same issue. I will open a ticket on the plugin GitHub as well for transparency.

@toda-bps
Copy link
Author

toda-bps commented Mar 4, 2024

I found the commit that caused the problem by manual bisect:

By the way, @huycozy the shifted click position that I raised as an issue and the incorrect position of the text selection toolbar that is displayed after clicking may be independent issues.
Incorrect position of the text selection toolbar and handles seems to occur in 3.13.9 as well.

text selection toolbar with 3.13.9
3.13.9_text-selection-toolbar.mp4

@huycozy
Copy link
Member

huycozy commented Mar 5, 2024

Incorrect position of the text selection toolbar and handles seems to occur in 3.13.9 as well.

Thanks for checking. I also see this issue on Flutter 3.13.9 as well. I haven't found any filed issues before, please help to file a separate issue for this (and tag me on it)


With the shifted click position issue, it doesn't occur on Flutter 3.13.9 and 3.16.9 but on 3.19.1 and 3.20.0 as reported above. Based on your bisect result, adding regression label.

@toda-bps
Copy link
Author

toda-bps commented Mar 6, 2024

@huycozy I made new issue: #144685

@reidbaker reidbaker added the P2 Important issues not at the top of the work list label Mar 28, 2024
@revenpl
Copy link

revenpl commented Apr 18, 2024

We have the same issue in a production application.

We are depending on https://pub.dev/packages/aad_oauth, which internally uses webview_flutter.

We are not scaling the platform views ourselves, but strictly using the package linked above. If I understand this correctly, this means that all applications using the plugin and flutter 3.19 will have the same issue. I will open a ticket on the plugin GitHub as well for transparency.

We are facing the same issue. Flutter from 3.19 and above brakes login flow in our app because it is handled in webview. We have to stick to 3.16.9 where everything works fine.

Edit: But the problem occures with all interactions, not just text selection. Buttons interaction zones are missmatched with ui elemnts too, same as text fields, so user have to click below desired element to interact with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: regression It was better in the past than it is now found in release: 3.19 Found to occur in 3.19 found in release: 3.20 Found to occur in 3.20 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team
Projects
None yet
Development

No branches or pull requests

6 participants