Open hohlfma opened 2 years ago
Digging a bit deeper into flutter\lib\src\gestures\scale.dart
in function handleEvent(PointerEvent event)
shows that when it gets broken it has missed a PointerUpEvent
and _pointerQueue.length stucks at 1:
Working scenario (pinch after initial pan)
[Log] handleEvent: _TransformedPointerDownEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 1 (main.dart.js, line 24908)
[Log] handleEvent: _TransformedPointerDownEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 2 (main.dart.js, line 24908)
[Log] handleEvent: _TransformedPointerMoveEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 2 (main.dart.js, line 24908)
...
[Log] handleEvent: _TransformedPointerUpEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 1 (main.dart.js, line 24908)
[Log] handleEvent: _TransformedPointerUpEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 0 (main.dart.js, line 24908)
--> Detected 2x PointerDownEvent
+ 2x PointerUpEvent
Broken scenario (pinch as initial gesture after app start)
[Log] handleEvent: _TransformedPointerDownEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 1 (main.dart.js, line 24908)
[Log] handleEvent: _TransformedPointerDownEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 2 (main.dart.js, line 24908)
[Log] handleEvent: _TransformedPointerMoveEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 2 (main.dart.js, line 24908)
...
[Log] handleEvent: _TransformedPointerUpEvent (main.dart.js, line 24908)
[Log] _pointerCount: _pointerPanZooms: 0, _pointerQueue: 1 (main.dart.js, line 24908)
--> Detected 2x PointerDownEvent
but only 1x PointerUpEvent
Hi @hohlfma, thanks for filing the issue. This issue is reproducible on the latest stable
and master
channels with provided reproduction steps (including sample code).
Device info: iPhone 7 iOS 15.5
Canvaskit | HTML |
---|---|
❌ | ❌ |
iOS (Safari) | Android (Chrome) |
---|---|
❌ | ✅ |
✅: No Issue ❌: Issue reproduced
Any news on this issue, and/or are there any known workarounds at the moment?
Any news on this issue, and/or are there any known workarounds at the moment?
There aren't any, as far as I know
I find it surprising that there isn't more activity on this issue. It's breaking my app for a large part of its user base, and I would imagine the same goes for other developers. Is there any possibility of getting this issue prioritised?
A workaround for this issue is tracking which pointers are active during the first pinch, and then, when the first PointerUpEvent
fires, adding another PointerUpEvent
for the remaining active pointer (through GestureBinding.instance.handlePointerEvent()
). This is not ideal as the user is unable to keep one finger on the screen and start panning right after the initial pinch, but it is certainly better than the alternative 😊
A workaround for this issue is tracking which pointers are active during the first pinch, and then, when the first
PointerUpEvent
fires, adding anotherPointerUpEvent
for the remaining active pointer (throughGestureBinding.instance.handlePointerEvent()
). This is not ideal as the user is unable to keep one finger on the screen and start panning right after the initial pinch, but it is certainly better than the alternative 😊
@sondrelv , can you share an example of your 'solution'?
I have the swipeback issue on my flutter web app as well. Additionally, I have another similar issue occurring only on my flutter web app on iPhone. I have a flutter syncfusion grid that updates a cell with on onTap(). After a random number of taps, my menubar appears disabled and application stops working...if I then do a small swipe up on screen, the menu appears enabled again and I can continue taps. If a user doesn't notice menu has changed appearance and continues to click on a difference cell than the one causing the issue, a cell somewhere else in the grid gets updated.
UPDATE: I appears that this "freezing" only happens if user taps one cell twice in a row.
Here's my workaround on this issue. Sorry for the delayed response, @Kadzup.
So, the way I solved this was wrapping my affected widget in a listener to keep track of and handle relevant pointer events:
@override
Widget build(BuildContext context) {
return Listener(
onPointerDown: (event) async {
// Keep track of the active pointers
_activePointers.add(event.pointer);
// Keep track of whether user is scaling using two fingers
_isScaling = _activePointers.length == 2;
},
onPointerUp: (event) async {
// Update overview of active pointers when user removes finger
_activePointers.remove(event.pointer);
// If user is scaling, an artificial gesture is not already added and we're on iOS web:
// Add an extra PointerUpEvent to match the remaining PointerDownEvent
if (!_initialGesturePerformed && kIsWeb) {
var userAgent =
dart_html.window.navigator.userAgent.toString().toLowerCase();
if (userAgent.contains('ios') || true) {
Future.delayed(Duration(milliseconds: 0), () async {
if (_activePointers.isNotEmpty &&
_isScaling &&
!_initialGesturePerformed) {
var up = PointerUpEvent(
pointer: _activePointers[0],
position: Offset(
(_mapSize['width'] / 2), (_mapSize['height'] / 2)));
GestureBinding.instance.handlePointerEvent(up);
_initialGesturePerformed = true;
_isScaling = false;
}
});
}
}
},
child: ...
Thank you ❤️
This is definitely an iOS issue. I found a temporary fix for this problem - https://stackoverflow.com/questions/55120331/white-panel-arrives-on-double-tap-from-bottom-in-pwa-in-standalone-mode.
Here is what I did and it fixed my problem:
In the index.html. However, this may not fix the swipe-back completely. My issue was that when user double-tapped it totally messed with ALL swiping. But still give it a try - it may solve some issues. Here is snippet of code in index.html from my actual code. I added this to my index.html.
When using a Flutter Web-App on iPad using Safari or Chrome browser, gesture detection of pan gestures gets broken after initial pinch (zoom) gesture (performed as first gesture after app start).
It seems to be important that the very first gesture gets detected as pinch gesture (two fingers). If the very first gesture is a pan gesture (one finger only) the issue does not occur afterwards. You have to reload the page and try again in this case.
Tested + confirmed on:
Steps to Reproduce
The issue can be reproduced e.g. with InteractiveViewer builder example:
Open the web app on iPad using Safari
After app has loaded, perform a pinch zoom gesture (using two fingers) as the very first interaction with the app
Perform pan/move gesture (using one finger)
Expected results:
Zoom in/out and moving of the displayed grid as usual
Actual results:
After initial zooming the displayed grid, normal pan/move gestures are broken in 9/10 times. Panning with one finger seems to act like zooming, like there is still a second finger present on the screen.
Video:
https://user-images.githubusercontent.com/21358685/189883833-75aeb7b3-c640-48f2-a658-b61d632ec948.mp4
Logging of pointerCount
I added some handlers to the InteractiveViewer to output the pointerCount:
Broken scenario (Video: 0:00 - 0:20)
Here is the output when the gesture detector gets broken after initial pinch/zoom gesture:
[X] This is wrong! pointerCount remains 1 after the gesture, even if there is no finger left on screen!
[X] This is wrong! pointerCount starts with 2 but there is only one finger on the screen + pointerCount still does not return to 0 after finger has been released!
Working scenario (Video: 0:20 - 0:37)
However, when the very first gesture is a pan gesture, the issue does not occur and pinch/zoom + pan/move works as expected.
[√] pointerCount is zero (as expected) -> No finger left on screen
[√] works as expected + pointerCount is zero at the end
[√] works as expected + pointerCount is zero at the end
Additional notes:
The issue does also occur... a) when using Chrome browser on iPad b) when using HTML as web renderer
The issue does not occur on other devices running Windows or Android
The issue seems to be related with flutter gesture library, not with InteractiveViewer, as other Widgets are also broken like "flutter_map" which uses the plain flutter/gestures.dart
flutter doctor (stable)
``` flutter doctor -v [√] Flutter (Channel stable, 3.3.1, on Microsoft Windows [Version 10.0.22000.856], locale de-DE) • Flutter version 3.3.1 on channel stable at C:\build_tools\flutter-3 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4f9d92fbbd (6 days ago), 2022-09-06 17:54:53 -0700 • Engine revision 3efdf03e73 • Dart version 2.18.0 • DevTools version 2.15.0 [√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at C:\Users\Marvin\AppData\Local\Android\Sdk • Platform android-32, build-tools 32.1.0-rc1 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) [√] VS Code (version 1.70.2) • VS Code at C:\Users\Marvin\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.46.0 [√] Connected device (2 available) • Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.102 • Edge (web) • edge • web-javascript • Microsoft Edge 105.0.1343.27 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```flutter doctor (master)
``` flutter doctor Flutter 3.4.0-19.0.pre.221 • channel master • https://github.com/flutter/flutter.git Framework • revision bbc42632a0 (2 hours ago) • 2022-09-13 02:52:39 -0400 Engine • revision 443b3646f8 Tools • Dart 2.19.0 (build 2.19.0-191.0.dev) • DevTools 2.17.0 ```