Photo_view: Gallery stopped working on Android after Flutter 1.20 upgrade

Created on 7 Aug 2020  路  13Comments  路  Source: fireslime/photo_view

Cannot browse gallery images. Images do not respond to slides and taps, only to resize.
This is on Android only. iPhone works as expected.
This started after Flutter 1.2 upgrade.

Framework bug Gallery Priority bug

Most helpful comment

News about this:

After some days over this, I think we can have two approaches to fix, the red and the blue pill.

The red pill:

We (PhotoViewGestureDetector) fight harder but wiser in the gesture arena.

Happens that the ScaleGestureRecognizer is the "weakest" recognizer of all, and the DragGestureRecognizer ( applied by PageView; this is what PhotoViewGallery uses) is waaaay "stronger".

DragGestureRecognizer declares itself winner with a movement of 18 pixels, whilst ScaleGestureRecognizer waits for 36.
With the original ScaleGestureRecognizer we can't have scale and pan gestures unless we extend it, as we did on PhotoViewGestureRecognizer.

This is where we fight harder. We can modify the handleEvent method to declare it winner earlier than our opponent.

This brings the problem that we always will win over the DragGestureRecognizer and lose the ability to change pages in the gallery.

This is where we fight wiser. PhotoViewGestureRecognizer should know when to lose and this is why we have HitCornersDetector. When the panning gestures hit the image edges, we have to give up on the gesture.

The bug lies in the fact that the current implementation of our recognizer and HitCornersDetector are failing to be that wise.

I'm working on that here: https://github.com/renancaraujo/photo_view/compare/detector-refactor

The Blue pill:

We (PhotoViewGestureDetector) don't fight in the gesture arena. Rather than that, we make the GestureRecognizer from the gallery's PageView give up in certain conditions.

I haven't worked on this approach yet.

All 13 comments

Yup, this is also happening to me.
If you want to compile your project while we wait for this to be resolved, you can use
flutter downgrade
to revert to a previous version that should work again.

flutter 1.2 or 1.20?

flutter 1.2 or 1.20?

If you knew the math you wouldn't be asking:), but if you insist, it is 1.20.0 and also confirmed on 1.20.1

https://flutter.dev/docs/development/tools/sdk/releases

Gonna look into it asap.

If you knew the math you wouldn't be asking

And if you knew package versioning semantics you wouldn't be that rude.

Ca I see your flutter doctor?
Also, which photo_view version are you using?

Couldnt reproduce over on channel master SDK version 1.21

Please note: This issue is only on Android phone. On iPhone it works as expected.
photo_view-0.9.2

Doctor summary (to see all details, run flutter doctor -v):
[鉁揮 Flutter (Channel stable, 1.20.1, on Mac OS X 10.14.6 18G3020, locale en-US)

[鉁揮 Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[鉁揮 Xcode - develop for iOS and macOS (Xcode 11.3.1)
[鉁揮 Android Studio (version 4.0)
[鉁揮 VS Code (version 1.45.1)
[鉁揮 Connected device (3 available)

Thanks

Is the example gallery working fine for you?
Tested in the following conditions:

[鉁揮 Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.5 19F101, locale en-GB)
[鉁揮 Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[鉁揮 Xcode - develop for iOS and macOS (Xcode 11.5)
[鉁揮 Android Studio (version 3.6)
[鉁揮 VS Code (version 1.43.2)
[鉁揮 Connected device (1 available)

On an Android 10 device and simulator, I can not reproduce this bug.

Running example on multiple devices. Here is the summary:
Works fine on Pixel 3 emulator with Android 10
Does not work on Honor 7X BND-L24 with Android 8.0.0
Works on my old Honor 5 with Android 6.0.1
Works on Pixel 2 emulator with Android 8.0.0
Does not work on Huawei Mate SE BND-L34 with Android 8.0.0

I wonder what device was used by other user who was able to reproduce it.
Thanks

May be relate to: #293

News about this:

After some days over this, I think we can have two approaches to fix, the red and the blue pill.

The red pill:

We (PhotoViewGestureDetector) fight harder but wiser in the gesture arena.

Happens that the ScaleGestureRecognizer is the "weakest" recognizer of all, and the DragGestureRecognizer ( applied by PageView; this is what PhotoViewGallery uses) is waaaay "stronger".

DragGestureRecognizer declares itself winner with a movement of 18 pixels, whilst ScaleGestureRecognizer waits for 36.
With the original ScaleGestureRecognizer we can't have scale and pan gestures unless we extend it, as we did on PhotoViewGestureRecognizer.

This is where we fight harder. We can modify the handleEvent method to declare it winner earlier than our opponent.

This brings the problem that we always will win over the DragGestureRecognizer and lose the ability to change pages in the gallery.

This is where we fight wiser. PhotoViewGestureRecognizer should know when to lose and this is why we have HitCornersDetector. When the panning gestures hit the image edges, we have to give up on the gesture.

The bug lies in the fact that the current implementation of our recognizer and HitCornersDetector are failing to be that wise.

I'm working on that here: https://github.com/renancaraujo/photo_view/compare/detector-refactor

The Blue pill:

We (PhotoViewGestureDetector) don't fight in the gesture arena. Rather than that, we make the GestureRecognizer from the gallery's PageView give up in certain conditions.

I haven't worked on this approach yet.

Any progress on this issue?

Any progress on this issue?

https://github.com/fireslime/photo_view/pull/326 should fixed it.

You can try to ref the lib in your pubspec.yaml as the following code:

  photo_view:
    git:
      url: https://github.com/fireslime/photo_view.git
      ref: master
Was this page helpful?
0 / 5 - 0 ratings