phetsims / scenery

Scenery is an HTML5 scene graph.
MIT License
54 stars 12 forks source link

Edge not sending pointercancel #645

Open jonathanolson opened 7 years ago

jonathanolson commented 7 years ago

Noticed in testing for https://github.com/phetsims/scenery/issues/619 where the pointer cancel seems to not happen as expected, however the general problem is larger in scope (thus this issue).

How to reproduce:

  1. Open Build an Atom in Edge, and open up something in another tab.
  2. On the first screen, start dragging around a particle with finger A.
  3. Use finger B to switch to the other browser tab (may require one or two presses).
  4. Release finger A.
  5. Go back to the simulation tab.

Expected (e.g. Chrome): pointercancel event fires, which means the particle animates back to the bucket (or to the atom if it's close to the center, because we don't handle the cancel differently yet).

Actual with Edge: Particle is now stuck in that location.

It's also possible to reproduce by:

@phet-steele, can you verify that this isn't just happening only on my Surface device?

In general, in 5 hours of debugging, I have never triggered a pointercancel event on Edge. Certain threads note that preventDefault(), touch-action, setPointerCapture, etc. could be related (https://github.com/w3c/pointerevents/issues/205#issuecomment-301564961). I've tried out all combinations of these, but still not getting a pointercancel. Enabling certain combinations of things also allows certain default browser behaviors to happen that we don't want to happen.

An independent code sample (https://patrickhlauke.github.io/touch/) also shows the "no pointercancel event" when doing the "switch to another tab".

If this was just the LoL prototype, I'd have bailed, but I'm concerned that switching tabs may be a somewhat common case on Edge. I'm really finding no information specific to this type of bug online, so creating a minimal reproducible example and (a) finding a point where this works, and/or (b) submitting a bug report would be my next options.

@ariel-phet, can you prioritize this?

@oliver-phet, has any user reported Edge bugginess consistent with this?

jonathanolson commented 7 years ago

Best workaround so far would be detecting it by polling every frame (for every touch) with setPointerCapture, as it errors out when a pointer isn't active.

This doesn't work well, because Edge doesn't error out until you put another finger back down in the sim. Unsure of performance impact.

e.g.:

        // Workaround for not getting pointercancel, see https://github.com/phetsims/scenery/issues/645
        if ( platform.edge && pointer.isTouch ) {
          var target = this.attachToWindow ? document.body : this.display.domElement;
          if ( target.setPointerCapture ) {
            try {
              target.setPointerCapture( pointer.id );
            }
            catch ( e ) {
              console.log( 'LOST LOST LOST' );
              pointer.interruptAll();
              this.removePointer( pointer );
            }
          }
        }
oliver-phet commented 7 years ago

I have yet to receive any Edge bugginess similar to this.

ariel-phet commented 7 years ago

@jonathanolson considering our usage on Edge (very low), and other priorities, I am marking this a low (quite low). Best to focus on sim work and revisit this question after the summer.

jonathanolson commented 7 years ago

Understand, unassigning myself.

phet-steele commented 7 years ago

@jonathanolson both procedures, tab switching and LoL zooming, are reproducible on my Win 10 Edge.