-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
'_initialButtons == kPrimaryButton': is not true. #75061
Comments
I was able to replicate this on latest stable as well as on master, but it doesn't throw the above error right away. Upon tapping on ListView and on blank space at the same time(doesn't replicate at first, have to repeat it few times), it first throws below exception:
At this point, the app isn't responsive and gets stuck. Tapping anywhere on the screen then leads to below exception:
A similar issue related to Gesture exception |
In this example there is a When I reproduce the exception, the
The @dkwingsmt Is it ever expected for an |
Thank you all for the reports. This is definitely an issue I'd like to solve and one that has been haunting for a long time. The investigation and reproducing process you provided are extremely important and I greatly appreciate them. Although I'm currently stuck on a project that I really need to finish first, I'll come back afterwards ASAP. Meanwhile it'd be helpful if you have more investigation and/or PRs. Feel free to ping me for them. @jason-simmons IIRC TapGestureRecognizer doesn't accept nor reject the pointer at PointerUpEvent, but relies on all other gesture recognizers to reject theirs for this tap to be recognized, which can happen way after the up event (which means "yes" to your question). Although I doubt if this situation should apply to the drag gestures. |
Here's a test case to repro the crash in isolation with some explanations of what's going on: import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
import 'gesture_tester.dart';
void main() {
setUp(ensureGestureBinding);
testGesture('should not crash - up', (GestureTester tester) {
final VerticalDragGestureRecognizer v = VerticalDragGestureRecognizer()
..onStart = (_) { };
final HorizontalDragGestureRecognizer h = HorizontalDragGestureRecognizer()
..onStart = (_) { };
const PointerDownEvent down90 = PointerDownEvent(
pointer: 90,
position: Offset(10.0, 10.0),
);
const PointerUpEvent up90 = PointerUpEvent(
pointer: 90,
position: Offset(10.0, 10.0),
);
const PointerDownEvent down91 = PointerDownEvent(
pointer: 91,
position: Offset(20.0, 20.0),
);
const PointerUpEvent up91 = PointerUpEvent(
pointer: 91,
position: Offset(20.0, 20.0),
);
// "V" instantly wins the arena for pointer 90 because nobody else is
// competing for it. This causes "V" to switch into the "accepted" state,
// nulling out _lastPendingEventTimestamp.
// "V" and "H" continue to compete for pointer 91 (pointer hasn't moved
// enough to declare winner).
v.addPointer(down90);
GestureBinding.instance!.gestureArena.close(90);
h.addPointer(down91);
v.addPointer(down91);
GestureBinding.instance!.gestureArena.close(91);
tester.async.flushMicrotasks();
GestureBinding.instance!.handleEvent(up90, HitTestEntry(MockHitTestTarget()));
// "H" rejects the gesture of pointer 91, but "V" continues to
// (incorrectly) compete for it in the arena (because this evaluates to
// false: https://github.com/flutter/flutter/blob/980880e2b69764fb2d1ea18eafe6fffc466c6509/packages/flutter/lib/src/gestures/monodrag.dart#L314).
// The arena is swept, and "V" becomes the winner. However, "V" has already
// nulled out _lastPendingEventTimestamp (see above) and is therefore not in
// a state to handle the "win" correctly.
GestureBinding.instance!.handleEvent(up91, HitTestEntry(MockHitTestTarget()));
});
}
class MockHitTestTarget implements HitTestTarget {
@override
void handleEvent(PointerEvent event, HitTestEntry entry) { }
} The problem seems to be here: flutter/packages/flutter/lib/src/gestures/monodrag.dart Lines 312 to 315 in 980880e
I believe, if the DragGestureRecognizer receives an up event for a pointer (here: 91) for which it was never told it had won the arena, it need to tell the gesture arena that it is no longer interested in winning for this pointer (i.e. we need to reject it). I'll see how I can express that in code to fix the bug. |
Should we cherry-pick this one into 1.22 or 1.26? Since it's a P2 issue. |
Request 1.22 cp due to stable channel at present. Also I'm concerning about the upgrading rate when a new stable version release, a nnbd one. FYI @xu-baolin |
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 |
Corresponds to Google internal bug b/179634050
flutter create bug
.Expected results: Outer Listview to work normal.
Actual results: Outer Listview crashes.
Logs
] flutter: ══╡ EXCEPTION CAUGHT BY GESTURE LIBRARY ╞═══════════════════════════════════════════════════════════
[ +7 ms] flutter: The following assertion was thrown while routing a pointer event:
[ ] flutter: 'package:flutter/src/gestures/monodrag.dart': Failed assertion: line 435 pos 12: '_initialButtons ==
[ ] flutter: kPrimaryButton': is not true.
[ ] flutter:
[ ] flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
[ ] flutter: more information in this error message to help you determine and fix the underlying cause.
[ ] flutter: In either case, please report this assertion by filing a bug on GitHub:
[ ] flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
[ ] flutter:
[ ] flutter: When the exception was thrown, this was the stack:
[ ] flutter: #2 DragGestureRecognizer._checkEnd (package:flutter/src/gestures/monodrag.dart:435:12)
[ ] flutter: #3 DragGestureRecognizer.didStopTrackingLastPointer (package:flutter/src/gestures/monodrag.dart:376:9)
[ +12 ms] flutter: #4 OneSequenceGestureRecognizer.stopTrackingPointer (package:flutter/src/gestures/recognizer.dart:342:9)
[ ] flutter: #5 DragGestureRecognizer._giveUpPointer (package:flutter/src/gestures/monodrag.dart:385:5)
[ ] flutter: #6 DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:282:9)
[ ] flutter: #7 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
[ ] flutter: #8 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9)
[ ] flutter: #9 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
[ ] flutter: #10 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
[ ] flutter: #11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
[ ] flutter: #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19)
[ ] flutter: #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
[ ] flutter: #14 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
[ ] flutter: #15 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
[ ] flutter: #16 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
[ ] flutter: #17 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
[ +1 ms] flutter: #21 _invoke1 (dart:ui/hooks.dart:265:10)
[ ] flutter: #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
[ +1 ms] flutter: (elided 5 frames from class _AssertionError and dart:async)
[ ] flutter:
[ ] flutter: router: Instance of 'PointerRouter'
[ ] flutter: route: Closure: (PointerEvent) => void from Function 'handleEvent':.
[ ] flutter: event: PointerMoveEvent#ed135(position: Offset(62.0, 506.5))
[ ] flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
[+6807 ms] flutter: Another exception was thrown: 'package:flutter/src/gestures/monodrag.dart': Failed assertion: line 435 pos 12:
'_initialButtons == kPrimaryButton': is not true.
[+26092 ms] flutter: Another exception was thrown: 'package:flutter/src/gestures/monodrag.dart': Failed assertion: line 435 pos 12:
'_initialButtons == kPrimaryButton': is not true.
[ +419 ms] flutter: Another exception was thrown: 'package:flutter/src/gestures/monodrag.dart': Failed assertion: line 435 pos 12:
'_initialButtons == kPrimaryButton': is not true.
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-IN)
• Flutter version 1.22.6 at /Users/rahul/Desktop/flutter
• Framework revision 9b2d32b (8 days ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for
detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT
to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.0
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for
detailed instructions).
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (1 available)
• R’s I (mobile) • c6467d3f454b96020193bf65ecad69cb68dbf640 • ios • iOS 14.3
The text was updated successfully, but these errors were encountered: