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

[web] flutter 3.10.0 transforming HtmlElementView malforms hittest behaviour #126754

Closed
2 tasks done
maRci002 opened this issue May 13, 2023 · 14 comments · Fixed by flutter/engine#41870
Closed
2 tasks done
Labels
c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 has reproducible steps The issue has been confirmed reproducible and is ready to work on P1 High-priority issues at the top of the work list platform-web Web applications specifically r: fixed Issue is closed as already fixed in a newer version

Comments

@maRci002
Copy link
Contributor

Is there an existing issue for this?

Steps to reproduce

When using Transform or FittedBox (which also transforms the child widget) as the parent of HtmlElementView, the hit test is malformed in Flutter 3.10.0.

Expected results

3.7.12

flutter.3.7.12.mp4

Actual results

3.10.0

flutter.3.10.mp4

Code sample

Code sample
import 'dart:html';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';

void main() {
  // ignore: undefined_prefixed_name
  ui.platformViewRegistry.registerViewFactory('div_html', (int viewId) {
    final div = DivElement();
    div.style.cssText = 'background-color: #ABBAEA; width: 400px; height: 400px;';
    return div;
  });

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 300,
        height: 300,
        child: ColoredBox(
          color: Colors.red,
          child: Stack(
            children: [
              FittedBox(
                fit: BoxFit.cover,
                child: SizedBox(
                  width: 400,
                  height: 400,
                  child: HtmlElementView(
                    viewType: 'div_html',
                    onPlatformViewCreated: (id) => print('View created: $id'),
                  ),
                ),
              ),
              Positioned(
                left: 90,
                top: 90,
                child: ElevatedButton(
                  onPressed: () => print('button pressed'),
                  child: const Text('BTN'),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.19045.2965], locale hu-HU)
    • Flutter version 3.10.0 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (4 days ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\maRci002\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.4.33403.182
    • Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.6+0-b2043.56-9586694)

[√] VS Code (version 1.77.2)
    • VS Code at C:\Users\maRci002\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.2965]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 113.0.5672.93
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 112.0.1722.64

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

• No issues found!
@huycozy
Copy link
Member

huycozy commented May 15, 2023

Thanks for the report! This issue is reproducible on the latest stable and master channels. Meanwhile, it works as expected on previous Flutter version 3.7.12.

flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.10.0, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
    • Flutter version 3.10.0 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (35 hours ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 32.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 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

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

[✓] 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
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.92

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

• No issues found!
[!] Flutter (Channel master, 3.11.0-6.0.pre.63, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
    • Flutter version 3.11.0-6.0.pre.63 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 7b8f7a2a64 (5 hours ago), 2023-05-14 17:42:29 -0400
    • Engine revision 326de1d849
    • Dart version 3.1.0 (build 3.1.0-110.0.dev)
    • DevTools version 2.23.1
    • 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 32.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 32.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 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

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

[✓] 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
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.92

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

! Doctor found issues in 1 category.

@huycozy huycozy added c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. platform-web Web applications specifically has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 and removed in triage Presently being triaged by the triage team labels May 15, 2023
@jason-simmons
Copy link
Member

Bisected this to flutter/engine@5bae183

@ditman

@ditman
Copy link
Member

ditman commented May 16, 2023

I'll escalate the original issue to reflect this is a crowd issue:

@fhuonder
Copy link
Contributor

Is there any workaround?

@fhuonder
Copy link
Contributor

Found a workaround:
Based on this comment #125948 (comment) I added the following CSS to the index.html

flt-glass-pane * {
      pointer-events: none;
}

and then it behaves correctly. As far as I can test.

@htoor3
Copy link
Contributor

htoor3 commented May 17, 2023

@fhuonder unfortunately that workaround breaks certain functionality like triggering context menus.

@yjbanov
Copy link
Contributor

yjbanov commented May 18, 2023

flutter/engine#41870 doesn't seem to cover this case, so I'm accepting this issue as a new one. Feel free to correct me, @htoor3.

@yjbanov yjbanov added the P1 High-priority issues at the top of the work list label May 18, 2023
@htoor3
Copy link
Contributor

htoor3 commented May 18, 2023

flutter/engine#41870 doesn't seem to cover this case, so I'm accepting this issue as a new one. Feel free to correct me, @htoor3.

You're correct. That PR only fixes the issue for inputs, although hopefully we can use a similar strategy for platform views.

@agilerdev
Copy link

I'm using the responsiveFramework package that uses a FittedBox to scale the view of the application, and got the same error when I upgraded to flutter 3.10.

@ditman
Copy link
Member

ditman commented May 18, 2023

@yjbanov, I have added a small change to @htoor3 PR to address this issue as well (and others).

ditman pushed a commit to ditman/flutter-engine that referenced this issue May 19, 2023
* git cherry-pick 4f3f7bb (+ conflict fixes)

This cherry-pick backports flutter#41870 to Flutter 3.10.

Original commit message below:

[web] Fix event offset for transformed widgets (and text input nodes). (flutter#41870)

Text inputs have moved outside of the shadowDOM and are now using the pointer event offset calculation algorithm that platform views use.  However, transforms (e.g. scaling) applied to the input element aren't currently accounted for, which leads to incorrect offsets and clicks being registered inaccurately.

This PR attempts to transform those offset coordinates using the transform matrix data that is included in the geometry information sent over to `text_editing.dart` from the framework.

* Fixes flutter/flutter#125948 (text editing)
* Fixes flutter/flutter#126661 (platform view scaling)
* Fixes flutter/flutter#126754
ditman pushed a commit to ditman/flutter-engine that referenced this issue May 19, 2023
* git cherry-pick 4f3f7bb (+ conflict fixes)

This cherry-pick backports flutter#41870 to Flutter 3.10.

Original commit message below:

[web] Fix event offset for transformed widgets (and text input nodes). (flutter#41870)

Text inputs have moved outside of the shadowDOM and are now using the pointer event offset calculation algorithm that platform views use.  However, transforms (e.g. scaling) applied to the input element aren't currently accounted for, which leads to incorrect offsets and clicks being registered inaccurately.

This PR attempts to transform those offset coordinates using the transform matrix data that is included in the geometry information sent over to `text_editing.dart` from the framework.

* Fixes flutter/flutter#125948 (text editing)
* Fixes flutter/flutter#126661 (platform view scaling)
* Fixes flutter/flutter#126754
@ditman
Copy link
Member

ditman commented May 19, 2023

A fix is coming to Flutter master soon: #127233 (we're also attempting to cherry-pick so it becomes available to everybody on stable (3.10): #127229

@senthilraja-augusta

This comment was marked as duplicate.

auto-submit bot pushed a commit to flutter/engine that referenced this issue May 24, 2023
This cherry-pick backports #41870 to Flutter 3.10.

* git cherry-pick 4f3f7bb (+ conflict fixes)

Original commit message below:

[web] Fix event offset for transformed widgets (and text input nodes). (#41870)

Text inputs have moved outside of the shadowDOM and are now using the pointer event offset calculation algorithm that platform views use.  However, transforms (e.g. scaling) applied to the input element aren't currently accounted for, which leads to incorrect offsets and clicks being registered inaccurately.

This PR attempts to transform those offset coordinates using the transform matrix data that is included in the geometry information sent over to `text_editing.dart` from the framework.

* Fixes flutter/flutter#125948 (text editing)
* Fixes flutter/flutter#126661 (platform view scaling)
* Fixes flutter/flutter#126754

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
@huycozy huycozy added the r: fixed Issue is closed as already fixed in a newer version label May 24, 2023
@ditman
Copy link
Member

ditman commented May 24, 2023

A hotfix to alleviate this issue has been released on stable, version: 3.10.2 (See full changelog).

@github-actions
Copy link

github-actions bot commented Jun 8, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 has reproducible steps The issue has been confirmed reproducible and is ready to work on P1 High-priority issues at the top of the work list platform-web Web applications specifically r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants