Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Intervention] Ignored attempt to cancel a touchstart event with cancelable=false, for example because scrolling is in progress and cannot be interrupted. #553

Open
Ann2827 opened this issue Apr 9, 2021 · 2 comments

Comments

@Ann2827
Copy link

Ann2827 commented Apr 9, 2021

I get an error on touch events (however, the app doesn't break).

Снимок экрана 2021-04-09 в 15 20 00

Снимок экрана 2021-04-09 в 15 20 11

This problem can be solved by using:

if (e.type === 'touchstart' && e.cancelable) e.preventDefault();

https://alexandrerosseto.medium.com/solving-issue-intervention-ignored-attempt-to-cancel-a-touchmove-event-with-cancelable-false-62014ef15742

jschaf added a commit to jschaf/signature_pad that referenced this issue Jul 17, 2022
Chrome has started warning when canceling an event that cannot be cancelled, like scrolling.
This causes a fair bit of log spam. I know it fires for touchmove and touchend and there's 
reports that it also fires for touchstart.

    IgnoredEventCancel: intervention: Ignored attempt to cancel a touchmove event with
    cancelable=false, for example because scrolling is in progress and cannot be interrupted

References:

- react-grid-layout/react-draggable#553
- https://www.uriports.com/blog/easy-fix-for-intervention-ignored-attempt-to-cancel-a-touchmove-event-with-cancelable-false/
- FL3NKEY/scroll-lock#19
- https://stackoverflow.com/a/53315365/30900
jschaf added a commit to jschaf/mapbox-gl-js that referenced this issue Jul 28, 2022
Chrome has started warning when canceling an event that cannot be cancelled, like scrolling.
This causes a fair bit of log spam. I know it fires for touchmove and touchend and there's 
reports that it also fires for touchstart.

    IgnoredEventCancel: intervention: Ignored attempt to cancel a touchmove event with
    cancelable=false, for example because scrolling is in progress and cannot be interrupted

References:

- react-grid-layout/react-draggable#553
- https://www.uriports.com/blog/easy-fix-for-intervention-ignored-attempt-to-cancel-a-touchmove-event-with-cancelable-false/
- FL3NKEY/scroll-lock#19
- https://stackoverflow.com/a/53315365/30900

Fixes mapbox#11961.
mourner added a commit to mapbox/mapbox-gl-js that referenced this issue Jul 28, 2022
* check for event.cancelable in touch events

Chrome has started warning when canceling an event that cannot be cancelled, like scrolling.
This causes a fair bit of log spam. I know it fires for touchmove and touchend and there's 
reports that it also fires for touchstart.

    IgnoredEventCancel: intervention: Ignored attempt to cancel a touchmove event with
    cancelable=false, for example because scrolling is in progress and cannot be interrupted

References:

- react-grid-layout/react-draggable#553
- https://www.uriports.com/blog/easy-fix-for-intervention-ignored-attempt-to-cancel-a-touchmove-event-with-cancelable-false/
- FL3NKEY/scroll-lock#19
- https://stackoverflow.com/a/53315365/30900

Fixes #11961.

* Update src/ui/handler/touch_pan.js

Co-authored-by: Volodymyr Agafonkin <agafonkin@gmail.com>

Co-authored-by: Volodymyr Agafonkin <agafonkin@gmail.com>
@Hamcker
Copy link

Hamcker commented Oct 5, 2022

It looks like a working small change, any chance to merge a PR for this?

@mallchel
Copy link

mallchel commented Jul 12, 2024

I would like to suggest adding

 // Short circuit if handle or cancel prop was provided and selector doesn't match.
    if (
      // 1. we can't cancel the non-cancelable events
      // 2. so, we shouldn't start the dragging logic to avoid unpredictable behavior
      // 3. otherwise, we might fall into the situation e.g. when the scrolling is happening and touchmove is firing,
      // but the touchmove event will be fired on android in chrome once per 200ms
      e.cancelable === false ||
      // .... other conditions
      return;
    }

the main problem I came across:

  1. android, phone
  2. if non-cancelable touchstart goes further, the drag logic starts (after scrolling on a page)
  3. the scrolling and dragging happen simultaneously
  4. touchmove events on target element for dragging happens each 200ms

I can get that bug on the emulator during performance profiling and real-device

image (1)

Screen_Recording_20240707_113056_Chrome.1.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants