wiseman / mavelous

multi-platform ground station for drones that speak the MAVLink protocol
MIT License
167 stars 85 forks source link

Improve reliability of double tap on iOS #9

Closed wiseman closed 11 years ago

wiseman commented 12 years ago

It seems like sometimes double taps get missed.

wiseman commented 12 years ago

After some investigation I've seen two cases:

  1. Two taps sometimes happen too far apart in time. Our TouchHandler code (based on an old modestmaps example) has a maximum of 350 ms between taps in a double tap. Despite a lot of searching I haven't been able to find out what the default maximum time for double taps is in iOS, but in Android it seems to be 300 ms. I think we could increase this to 400, 450 or even 500 ms pretty safely.
  2. Weird events. I'd say most of the time when a double tap has been missed, there's a problem either getting the events or interpreting the events.

Here's a good double tap event log ("@1234" means the time on the client was 1234 ms):

2012-07-29 16:35:31,309:INFO:mmap_server:119: jslog: touchStartMachine @1343604929943 ms
2012-07-29 16:35:31,310:INFO:mmap_server:119: jslog: touchEndMachine @1343604929952 ms
2012-07-29 16:35:31,311:INFO:mmap_server:119: jslog: onTap: tap.time:1343604929952 ms @1343604929957 ms
2012-07-29 16:35:31,312:INFO:mmap_server:119: jslog: touchStartMachine @1343604929963 ms
2012-07-29 16:35:31,312:INFO:mmap_server:119: jslog: touchEndMachine @1343604929969 ms
2012-07-29 16:35:31,320:INFO:mmap_server:119: jslog: onTap: tap.time:1343604929969 ms @1343604929973 ms
2012-07-29 16:35:31,354:INFO:mmap_server:119: jslog: onDoubleTap: tap.time:1343604929969 ms @1343604929977 ms

Here's a log of getting all the touchstart and touchevent events that we'd expect, but for some reason a double tap wasn't fired:

2012-07-29 16:36:08,853:INFO:mmap_server:119: jslog: touchStartMachine @1343604967563 ms
2012-07-29 16:36:08,936:INFO:mmap_server:119: jslog: touchEndMachine @1343604967639 ms
2012-07-29 16:36:08,969:INFO:mmap_server:119: jslog: onTap: tap.time:1343604967639 ms @1343604967643 ms
2012-07-29 16:36:09,037:INFO:mmap_server:119: jslog: touchStartMachine @1343604967738 ms
2012-07-29 16:36:09,282:INFO:mmap_server:119: jslog: touchEndMachine @1343604968094 ms

And another:

2012-07-29 16:38:29,858:INFO:mmap_server:119: jslog: touchStartMachine @1343605108731 ms
2012-07-29 16:38:30,386:INFO:mmap_server:119: jslog: touchEndMachine @1343605109122 ms
2012-07-29 16:38:31,190:INFO:mmap_server:119: jslog: touchStartMachine @1343605109129 ms
2012-07-29 16:38:31,191:INFO:mmap_server:119: jslog: touchEndMachine @1343605109136 ms
2012-07-29 16:38:31,192:INFO:mmap_server:119: jslog: onTap: tap.time:1343605109136 ms @1343605109140 ms

Looks like we may need to rework the touch event logic.

I think I've also seen cases where we didn't even get the final browser touchend event, but I'll have to try to reproduce that.

For now I'll increase the maxDoubleTapDelay to maybe 400, and check-in my client-to-server logging code.