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

[CP-stable][web:semantics] fix double click due to long-press #54735

Conversation

flutteractionsbot
Copy link

@flutteractionsbot flutteractionsbot commented Aug 23, 2024

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

What is the link to the issue this cherry-pick is addressing?

flutter/flutter#147050

Changelog Description:

Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples

When semantics are enabled on Web, the onTap of various widgets (GestureDetector, InkWell) are called twice or the callback from one widget is called when another widget is pressed.

Impact Description:

What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

This causes multiple issues, e.g I have an InputField and a InkWell within the same page, tapping on the InputField executes the callback of the InkWell.

Workaround:

Is there a workaround for this issue?

The workaround is to go through all clickable components and set excludeFromSemantics: true. Note that this is not always feasible when using external packages (those you don't have control over).

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

What are the steps to validate that this fix works?

Steps to validate

  1. Run the sample code below
  2. Tap ONCE on the button

Expected results

The on tap callback is called once and onTap is printed once on the console:

onTap

Code sample

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SemanticsBinding.instance.ensureSemantics();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Semantics(
        enabled: true,
        child: Scaffold(
          body: Center(
            child: GestureDetector(
              onTap: () => print('onTap'),
              child: const Text('Click me'),
            ),
          ),
        ),
      ),
    );
  }
}

Remember the timestamp of _all_ `pointerup` events, not just those that were flushed. Clicks should be deduplicated after a `pointerup` even when not debouncing anything. This is because when not debouncing the engine already forwards all the pointer events to the framework, and sending click events on top only causes double-clicks.

Fixes flutter/flutter#147050
@flutteractionsbot flutteractionsbot added the cp: review add the cp request to the review queue of release engineers label Aug 23, 2024
@flutteractionsbot
Copy link
Author

@pedromassango please fill out the PR description above, afterwards the release team will review this request.

@github-actions github-actions bot added the platform-web Code specifically for the web engine label Aug 23, 2024
@christopherfujino
Copy link
Member

@yjbanov do you think the impact of this bug/fix warrants a stable branch CP?

@yjbanov
Copy link
Contributor

yjbanov commented Aug 26, 2024

I think this one should be safe to CP. However, let's do our due diligence and clearly justify the CP in the description. @pedromassango Could you please write up a justification for the CP?

@pedromassango
Copy link
Member

I think this one should be safe to CP. However, let's do our due diligence and clearly justify the CP in the description. @pedromassango Could you please write up a justification for the CP?

Updated the form, to add more details, internally we've a Flutter web app that strongly depends on semantics and disabling it is not an option, which means we can't apply the workaround mentioned in the OP (and here)

Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@yjbanov yjbanov added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 28, 2024
@auto-submit auto-submit bot merged commit f314ded into flutter:flutter-3.24-candidate.0 Aug 28, 2024
26 checks passed
@pedromassango
Copy link
Member

@yjbanov sorry for pocking,

Is there an eta for the cherry-pick to land on stable? Had a look at the Flutter Cherry-pick Process and couldn't figure that out

@yjbanov
Copy link
Contributor

yjbanov commented Aug 28, 2024

@pedromassango That is a good question for @itsjustkevin. The release schedule is driven not by the web platform, but by the needs of all platforms, and I'm not fully looped into what else is going on. If you need it really really soon, consider patching the version of the engine that you are currently using, and building a custom one.

@itsjustkevin
Copy link
Contributor

@pedromassango this cherry-pick has been merged, meaning that is in the queue for the next hotfix release.

We aim to release hotfixes weekly where possible, but it is not a guarantee. If you need the fix immediately, I suggest following the callout by @yjbanov.

@pedromassango
Copy link
Member

We aim to release hotfixes weekly where possible,

I am glad the week is (almost) over then 🎉

If you need it really really soon, consider patching the version of the engine that you are currently using, and building a custom one.

The problem is just that that doesn't seems too trivial to do... is there any doc as a starting point?

auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 3, 2024
# Flutter stable 3.24.0 Framework

## Scheduled Cherrypicks
[flutter/153949](#153949): Fix a crash when deleting text inside CupertinoPageRoute, with a CJK (chinese, japanese, korean) keyboard on Android. 
[flutter/153939](#153939): Fixes an issue where Flutter TextField may stop accepting input on iOS.
[flutter/152420](#152420): Fixes scrolling jank when a SelectionArea/SelectableRegion is used as a child of a Scrollable like ListView or PageView on Android and iOS. 
[flutter/154199](#154199): Removes log spam when building a freshly created template app for Android.
[flutter/153967](#153967): Fixes macOS host build failure when there are no native asset frameworks to codesign. Impacts users who have enabled experimental native assets feature. 
[flutter/153769](#153769): When running a Flutter app, display a concise error message when connection to the device is lost.
[flutter/154270](#154270): Prevent preemptive gradle crash for android builds that would fail to build anyway but with a confusing error message. 
[flutter/54735](flutter/engine#54735): When semantics are enabled on Web, the onTap of various widgets (GestureDetector, InkWell) are called twice or the callback from one widget is called when another widget is pressed.
@shannon-rodricks
Copy link

shannon-rodricks commented Sep 11, 2024

@yjbanov @pedromassango
Thank you for this!
Been facing an issue where automated tests were failing cause of this and wasnt able to identify the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App cp: review add the cp request to the review queue of release engineers platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants