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

Three finger screenshotting throws assert #20517

Closed
taibaiyinxing opened this issue Aug 13, 2018 · 43 comments
Closed

Three finger screenshotting throws assert #20517

taibaiyinxing opened this issue Aug 13, 2018 · 43 comments
Assignees
Labels
c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: dream (g3) customer: mulligan (g3) engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels.
Milestone

Comments

@taibaiyinxing
Copy link

taibaiyinxing commented Aug 13, 2018

Internal: b/143427192

On our released version of App, we were notified with an exception as the title show, the detail track infos are as follow:

NoSuchMethodError: The getter 'lastPosition' was called on null.

6 Receiver: null
7 Tried calling: lastPosition===>#0 PointerEventConverter.expand (package:flutter/src/gestures/converter.dart:246)
8 #1 _SyncIterator.moveNext (dart:core/runtime/libcore_patch.dart:151)
9 #2 ListQueue.addAll (dart:collection/queue.dart:715)
10 #3 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:46)
11 #4 _rootRunUnary (dart:async/zone.dart:1136)
12 #5 _CustomZone.runUnary (dart:async/zone.dart:1029)
13 #6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931)
14 #7 _invoke1 (dart:ui/hooks.dart:144)
15 #8 _dispatchPointerDataPacket (dart:ui/hooks.dart:99)

That's the full exception stack, from where I cannot get any info where my code got wrong because it's all about the framework layer, and I'm not very familiar with this layer.I did not found anything invoke the function _dispatchPointerDataPacket in hooks.dart from my code.
This exception appeared only once by now.
Can we avoid this by checking if it's null before invoking lastPosition in converter.dart ?

@zoechi
Copy link
Contributor

zoechi commented Aug 22, 2018

Please add the output of flutter doctor -v.

@zoechi zoechi added c: crash Stack traces logged to the console framework flutter/packages/flutter repository. See also f: labels. labels Aug 22, 2018
@zoechi zoechi added this to the Goals milestone Aug 22, 2018
@philipgiuliani
Copy link

philipgiuliani commented Oct 12, 2018

I can reproduce this in a release build, when tapping anywhere with 3 fingers. It does not crash when tapping with 1 or 2 fingers.

[✓] Flutter (Channel dev, v0.10.0, on Mac OS X 10.14 18A391, locale de-DE)
    • Flutter version 0.10.0 at /Users/MyUserName/flutter
    • Framework revision d954ae6850 (2 days ago), 2018-10-09 16:21:06 -0400
    • Engine revision bf377896ff
    • Dart version 2.1.0-dev.6.0.flutter-a50dfd6698

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/MyUserName/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

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

[✓] Connected device (3 available)
   --- Removed

• No issues found!

Update: Seems that its crashing on a OnePlus 5, but not on a Xiaomi A2.

@philipgiuliani
Copy link

I even have more information. My phone has 3 finger screenshot gesture enabled. In debug mode the app does not crash, just in release mode.
I see the following message in debug mode though: D/ViewRootImpl( 4960): Gesture Screenshot triggered, ignore event.

@HerrNiklasRaab
Copy link

Same problem here, but I cannot reproduce the error as you described.

@goderbauer
Copy link
Member

Do you have a reliable way to reproduce this error? If so, can you post a minimal runnable code example that shows the error? That would help us tremendously in fixing this.

@Hixie Hixie changed the title Getting an NoSuchMethodError with package:flutter/src/gestures/converter.dart:246 Getting a NoSuchMethodError with package:flutter/src/gestures/converter.dart:246 Feb 6, 2019
@Hixie
Copy link
Contributor

Hixie commented Feb 6, 2019

My guess would be that some Android device is sending us bogus data (or at least data that we haven't thought to expect). Without knowing more about the device, steps to reproduce, or in general any more information, it's hard for us to do anything.

If you see this, please try to provide such information, as well as an up to date stack trace and the output of flutter doctor -v. Thanks.

@Hixie
Copy link
Contributor

Hixie commented Feb 13, 2019

@goderbauer reports that Android claims to make no promises regarding their events, so we must make the engine robust to arbitrary sequences of input events, and try to convey coherent events to the framework.

@Hixie Hixie added the engine flutter/engine repository. See also e: labels. label Feb 13, 2019
@kongshanshan33
Copy link
Contributor

I can reproduce this in a xiaomi 6X, when use the three-finger screenshot feature.

@xster
Copy link
Member

xster commented Feb 14, 2019

Adding some additional paraphrasing from customers via WeChat:

The Xiaomi OS (?) has a 3 finger screenshot function. When using it on Flutter, it turns into one ACTION_DOWN and one ACTION_POINTER_DOWN in FlutterView.

On the dart side, that's 2 down. Then there's an ACTION_CANCEL but its getPointerCount is 3. When that reaches dart, it becomes 3 cancels which doesn't match the 2 from before.

So far, it's only reproducible on a Xiaomi 6X.

@xster
Copy link
Member

xster commented Feb 14, 2019

Hopefully we can buy one but I also strongly suspect that the bundled OS for Xiaomi phones domestically and on international versions are different. Maybe a OnePlus 5 as mentioned in #20517 (comment) is a safer bet.

@Hixie Hixie removed the framework flutter/packages/flutter repository. See also f: labels. label Feb 20, 2019
@goderbauer goderbauer self-assigned this Feb 26, 2019
@Hixie Hixie modified the milestones: Goals, Scheduled customer work Feb 27, 2019
@goderbauer
Copy link
Member

Here's the sequence of pointer events that Flutter is seeing when the user performs the three-finger screenshot gesture:

Pointer 1 down
Pointer 2 down
Cancel Pointer 1, 2, and 3

The problem is that we get a cancel event for the third finger even though we never were told to track it. The fix is going to be to filter those "illegal" events out.

@goderbauer goderbauer added the framework flutter/packages/flutter repository. See also f: labels. label Feb 28, 2019
@The-Redhat
Copy link
Contributor

I can also reproduce this error on a oneplus 3 using the three-finger screenshot feature.

@cbracken cbracken added this to the October 2019 milestone Sep 24, 2019
@cbracken
Copy link
Member

I'm pushing this to the Oct milestone. We plan to get to this ASAP but I've asked @chinmaygarde to finish up work on a higher-priority issue first. We realise this is impacting customers, and this is definitely very much on our radar. Thanks for your patience.

@sergicastellsague
Copy link

@cbracken @chinmaygarde I wonder if there's any feasible workaround we can implement on our side or even an ugly fix would work for us.
Our top three crashes in reported in Fabric come from Flutter's core code, this being the first crash by a big difference.

@goderbauer
Copy link
Member

@sergicastellsague I posted the workaround a couple of comments above: #20517 (comment)

@sergicastellsague
Copy link

sergicastellsague commented Sep 26, 2019

Thanks, @goderbauer! however, when I tried it the code was not matching Flutter's code anymore, so it was not possible to simply apply the patch. I tried to adapt it, without luck.

@sergicastellsague
Copy link

@shihaohong / @chunhtai do you see this happening in October 2019?
This is the top 1 crash in our flutter app (probably the top 2 too)
imatge

@shihaohong
Copy link
Contributor

Hi @sergicastellsague, I don't think this will be happening in October 2019. I just started looking at the issue and proposed solutions. @chunhtai will be back from vacation next week, so we will discuss what needs to get done when he returns.

@sergicastellsague
Copy link

@shihaohong I understand. But this issue is really a pain for our users. It's causing a lot of crashes, not only on Android but iOS as well. I guess my users are not taking screenshots constantly, it's just by normal usage of the app that they touch the screen with 3 fingers and experience this crash.

If the bugfix is not released, I'm more than willing to have a patch as a workaround, but I really need something to stop having them.
Do you have any quick and dirty way to prevent them?

Thanks a lot.

@shihaohong
Copy link
Contributor

@sergicastellsague Could you elaborate on how the patch that @goderbauer suggested failed to work? Your version of Flutter would certainly become a fork of the original, and that comes with the drawback of having to keep in sync with the official version. That would probably be the only workaround for it for as far as I know.

@sergicastellsague
Copy link

sergicastellsague commented Oct 25, 2019

In case somebody sees this crash and looks for a workaround, modify the file packages/flutter/lib/src/rendering/platform_view.dart and add

if (downTimeMillis == null) return;

in the handlePointerEvent method, right below this:

if (event is PointerDownEvent) {
  if (nextPointerId == 0)
    downTimeMillis = event.timeStamp.inMilliseconds;
  pointerProperties[event.pointer] = propertiesFor(event, nextPointerId++);
}

@flutterfrank
Copy link

I can't find the handlePointerEvent method anymore. Can somebody help me?

@chunhtai
Copy link
Contributor

it got moved to the engine side, see
engine/src/flutter/lib/ui/window/pointer_data_packet_converter.h

@github-actions
Copy link

github-actions bot commented Aug 6, 2021

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 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: dream (g3) customer: mulligan (g3) engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests