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

Touch input has unpredictable tap detection #1497

Closed
afandria opened this issue Jan 30, 2016 · 7 comments
Closed

Touch input has unpredictable tap detection #1497

afandria opened this issue Jan 30, 2016 · 7 comments
Labels
a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels.

Comments

@afandria
Copy link
Contributor

Details and repro case will come later. But I wanted to report this now. (I'm on the latest Flutter engine 87, but this also happened on sky engine 75 as well.)

I noticed that taps are occasionally ignored in my app.

My situation is:

  • Large container has a tap target on the full container
  • A button is inside the container (another tap/press target)
  • The button is not always present.

In my app, 4 people take turns playing cards. After each card is played, they tap the large container to reveal their cards. After all 4 cards are revealed, the "Take" button appears to tell the trick winner to take the trick.

Everything works fine up to there.

After the trick-taking tap, the next card played has issues being revealed:

  • The first tap (on the container) is ignored.
  • The next tap succeeds.

This makes me think that Flutter has a bug where:

  • If a tap target is removed, the remaining tap targets will not be able to detect taps normally.

It may also be that:

  • The first "missed" tap fixes the problem.
  • The bug generalizes to all gestures.

For now, my app is fine since I can fake the "Take" button with a similarly-styled container, but it would be nice to fix this behavior. (For my app, the large container's onTap handler does the same thing as the button's onPressed would have.)

As mentioned, I'll try to make a simpler test case later.

@afandria afandria changed the title Flutter onTap doesn't fire sometimes GestureDetector onTap doesn't fire sometimes Jan 30, 2016
@abarth
Copy link
Contributor

abarth commented Jan 30, 2016

Are you running Flutter inside of MojoShell?

@abarth
Copy link
Contributor

abarth commented Jan 30, 2016

Also, what host platform are you using?

@afandria
Copy link
Contributor Author

Yes, Flutter inside of Mojo Shell. The app was running on a Nexus 9.

@abarth abarth added the dependency: fuchsia Fuchsia team may need to help us label Jan 30, 2016
@abarth abarth changed the title GestureDetector onTap doesn't fire sometimes Touch input on Modroid (prior to Mozart) has unpredictable tap detection Jan 30, 2016
@afandria
Copy link
Contributor Author

afandria commented Feb 1, 2016

This also happens on Nexus 6 and with normal Flutter (flutter start).

Here's an easier reproduction case. I have a blue background that is tappable. When you tap the body, the tap counter increments and prints out Body Tap. (Run adb logcat output to see these printouts.)

When an even number of taps have occurred, a button with the text Yes Tap will show up. Tapping this prints out Button Tap and increments the tap counter. When an odd number show up, then No Tap text will show up instead. (This simulates adding and removing of tap targets.)

Behavior:

  • Tapping the body repeatedly works just fine, even though the button is added and removed
  • Tapping the button makes it disappear and the next tap is completely ignored.

In lib/main.dart

import 'package:flutter/material.dart';

class TempComponent extends StatefulComponent {
  TempComponentState createState() => new TempComponentState();
}

class TempComponentState extends State<TempComponent> {
  int numTapped = 0;

  Widget _buildBody() {
    List<Widget> children = new List<Widget>();
    if (numTapped % 2 == 0) {
      children = [
        new FlatButton(
          child: new Text("Yes Tap"),
          color: Colors.green[500],
          onPressed: () {
            print("Button Tap");
            setState(() { numTapped++; });
          })
      ];
    } else {
      children = [
        new Text("No Tap")
      ];
    }

    return new GestureDetector(
      onTap: () {
        print("Body Tap");
        setState(() { numTapped++; });
      },
      child: new Container(
        decoration: new BoxDecoration(backgroundColor: Colors.blue[500]),
        child: new Column(children: children))
    );
  }

  Widget build(BuildContext context) {
    return new Scaffold(
      key: new GlobalObjectKey("scaffold"),
      toolBar: new ToolBar(
          center: new Text('Croupier')),
      body: new Material(child: _buildBody()));
  }
}

void main() {
  runApp(new MaterialApp(
    title: 'My app',
    routes: <String, RouteBuilder>{
      '/': (RouteArguments args) => new TempComponent()
    }
  ));
}

Perhaps the real behavior is:

  • If a tap target was tapped, and the handler makes that target disappear, then the next tap will be ignored.

@abarth abarth changed the title Touch input on Modroid (prior to Mozart) has unpredictable tap detection Touch input has unpredictable tap detection Feb 1, 2016
vanadium-bot pushed a commit to vanadium-archive/croupier that referenced this issue Feb 1, 2016
There's an onTap bug in Flutter (or Modroid)
flutter/flutter#1497

I have to investigate further, but for now, we're going to workaround
it by mocking the center "Take" button with a styled Container.

Change-Id: I038121b62388a74384e2ff13cc6aaabb20f2d19d
@Hixie Hixie modified the milestone: Flutter 1.0 Feb 3, 2016
@Hixie Hixie added framework flutter/packages/flutter repository. See also f: labels. and removed dependency: fuchsia Fuchsia team may need to help us labels Feb 3, 2016
@eseidelGoogle eseidelGoogle added the a: text input Entering text in a text field or keyboard related problems label Jul 13, 2016
@sethladd sethladd modified the milestones: Flutter 1.0, 2016 Q3 Jul 19, 2016
@sethladd sethladd removed this from the 2016 Q3 milestone Aug 22, 2016
@Hixie Hixie modified the milestone: Flutter 1.0 Sep 12, 2016
@mpcomplete
Copy link
Contributor

@HansMuller , this is ancient, but is it related to your work to fix Missing Taps?

@abarth
Copy link
Contributor

abarth commented Jan 26, 2017

Mojo shell isn't a thing anymore.

@abarth abarth closed this as completed Jan 26, 2017
@github-actions
Copy link

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 Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

6 participants