openseadragon / openseadragon

An open-source, web-based viewer for zoomable images, implemented in pure JavaScript.
http://openseadragon.github.io/
BSD 3-Clause "New" or "Revised" License
3.02k stars 596 forks source link

Potential MouseTracker bug on touch devices (active pointer count not cleared) #2607

Open oblak1 opened 3 days ago

oblak1 commented 3 days ago

I've encountered an issue where the active pointer count on innerTracker (and outerTracker as well) does not reset in some cases when using the SVG Overlay plugin (and potentially other similar plugins). To illustrate, I created a minimal demo: LINK.

Here's a step-by-step breakdown of the issue:

Device: I'm using an iPad, but it occurs on other touch-enabled devices as well.

Setup: The demo is a simple OpenSeadragon instance with SVG Overlay (the SVG plugin code is embedded directly in the JS tab)

Important Note: The SVG element (a red triangle) has pointer-events set to auto—this appears to be the key, as the issue does not occur with pointer-events: none.

Reproducing the Issue:

I added the following code to the demo:

setInterval(() => {
  document.getElementById("count").innerHTML = "Active pointer count: " + viewer.innerTracker.getActivePointerCount();
}, 300);
....
overlay.onClick(d3Rect.node(), function() {
  setTimeout(() => d3Rect.remove(), 1000);
});

The first snippet logs the active pointer count. The second snippet removes the SVG polygon 1 second after it’s clicked.

Steps to Trigger:

  1. Click the triangle.
  2. Immediately, with 1-2 fingers on the triangle and one off, perform a pan/zoom gesture continuously.
  3. When the triangle disappears and fingers are released, the getActivePointerCount() does not reset and may stay at 1 (or sometimes 2).
  4. This leads to the pointer count remaining "stuck," which in turn disrupts gesture functionality.
iangilman commented 2 days ago

@msalsbery What do you think? Would you mind taking a look?

msalsbery commented 14 hours ago

@msalsbery What do you think? Would you mind taking a look?

Yes! 👍