photo_view icon indicating copy to clipboard operation
photo_view copied to clipboard

[BUG] Delay around 0.4s with GestureDetector in PhotoView.customChild

Open 1g0rrr opened this issue 4 years ago • 10 comments

Describe the bug GestureDetector inside PhotoView.customChild detects taps with delay of around 0.4s which is quite noticeable. I try to use Listener instead of GestureDetector and it seems it works good, but gestures is useful also for my needs.

To Reproduce Paste this code in the default flutter project in main.dart, tap on the screen and look at the output. I tested it in web and windows builds.

import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    DateTime timeGestureStart;
    DateTime timeListenerStart;
    Duration diff;

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: PhotoView.customChild(
        child: GestureDetector(
          onTap: () {
            timeGestureStart = DateTime.now();
            print('GestureDetector');
            diff = timeGestureStart.difference(timeListenerStart);
            print('diff ' + diff.toString());
          },
          child: Listener(
            onPointerDown: (PointerDownEvent event) {
              timeListenerStart = DateTime.now();
              print('Listener');
            },
            child: Container(
              color: Colors.greenAccent,
              child: Text('Sample text'),
            ),
          ),
        ),
      ),
    );
  }
}

What is the current behavior? Listener and GestureDetector works with delay between each other. Here is calculated difference in this code as a Duration: diff 0:00:00.388052

Expected behavior Expected to see no delay in general and working of the GestureDetector and Listener at the same time.

Screenshots bugtouch

Additional context It seems it's similar to this issue #233 Maybe there is a sort of gesture disambiguation problem.

Logs photo_view: ^0.9.2

flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel master, 1.19.0-2.0.pre.193, on Microsoft Windows [Version 10.0.17763.1217], locale ru-RU) [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3) X Android license status unknown. Try re-installing or updating your Android SDK Manager. See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions. [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio CommunityВ 2019 16.4.2) [√] Android Studio (version 3.6) [√] VS Code (version 1.43.2) [√] Connected device (3 available)

1g0rrr avatar May 29 '20 15:05 1g0rrr

I think this is due to the fact that the package expects a double tap, but the double tap function cannot be disabled. I did not find how to do it

MichaelBabets avatar Jun 03 '20 09:06 MichaelBabets

We push the image to full screen on tap and the delay is noticeable. Hopefully this can be solved in the package itself somehow, instead of finding some hack to fix it :)

PerLycke avatar Jun 06 '20 19:06 PerLycke

@renancaraujo

When will this issue can be fixed?

Can this problem be solved by turning off the double click event by parameter? Double-click is generally not used. When viewing full screen, it is often used to close the page with a single click.

luckmlc avatar Aug 04 '22 11:08 luckmlc

Can this problem be solved by turning off the double click event by parameter

That would be a great way to approach this. But I am afraid that photoview is growing to receive too many paremeters.

We could group all params related to double tap into one that would describe the double tap behavior with and option to "not accept double taps". Then the delays would be gone. What do you think?

renancaraujo avatar Aug 04 '22 12:08 renancaraujo

Can this problem be solved by turning off the double click event by parameter

That would be a great way to approach this. But I am afraid that photoview is growing to receive too many paremeters.

We could group all params related to double tap into one that would describe the double tap behavior with and option to "not accept double taps". Then the delays would be gone. What do you think?

👍 Good solution

luckmlc avatar Aug 05 '22 01:08 luckmlc

When will it be update? @renancaraujo

luckmlc avatar Sep 01 '22 05:09 luckmlc

Any updates here?

owenkealey avatar Dec 23 '22 00:12 owenkealey

@renancaraujo

owenkealey avatar Jan 31 '23 18:01 owenkealey

@renancaraujo

hyped0001 avatar Mar 09 '23 21:03 hyped0001

@renancaraujo

HighLiuk avatar Aug 18 '23 20:08 HighLiuk