-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
The assert in the following method is incorrect:
flutter/packages/flutter/lib/src/gestures/recognizer.dart
Lines 427 to 432 in 1adc275
| void startTrackingPointer(int pointer, [Matrix4? transform]) { | |
| GestureBinding.instance.pointerRouter.addRoute(pointer, handleEvent, transform); | |
| _trackedPointers.add(pointer); | |
| assert(!_entries.containsValue(pointer)); | |
| _entries[pointer] = _addPointerToArena(pointer); | |
| } |
It must of course be containsKey instead of containsValue. The bug was introduced over half a decade ago in #3552. Correcting the assert now fails hundreds of tests. Having the correct assert there is definitely the right thing as we don't want to accidentally overwrite existing entries in _entries. However, it seems like that a lot of our existing recognizers are not properly cleaning up their entries when they don't need them anymore. We need to fix that first before we can enable the assert.
From an initial analysis, it appears that we only clean up the entries when a OneSequenceGestureRecognizer decides to accept or reject a gesture by calling resolve or resolvePointer on itself. However, if the recognizer is told by the GestureArena that it must accept or reject the gesture by calling acceptGesture/rejectGesture on the recognizer, we fail to properly clean up the entries in _entries for some recognizers. Subsequent gestures involving the same pointers then trigger the corrected assert mentioned above.
The problem can easily be reproduced by correcting the assert and then running the test/gestures/tap_test.dart tests, some of which will then fail with that assertion.