react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

[Web] Make `PointerTracker` elements nullable

Open m-bert opened this issue 5 months ago • 0 comments

Description

It was reported that in some cases Gesture Handler crashes on web on the following line. Seems like elements in PointerTracker may not exist, even though we believed that during our workflow they always do. Casts in PointerTracker were introduced because Map.get may return undefined if the element doesn't exist. Turns out that it actually may be the case, so we decided to remove those casts and handle these cases across our codebase.

While we don't know what exactly causes the fact that elements are not inside trackedPointers map, we have two possibilities:

  1. Pointer is removed form PointerTracker before handler enters BEGAN state - removing may happen for example when one lifts pointer from the view (calling onPointerUp, etc.).
  2. PointerTracker is reset before handler enters BEGAN state - this one can happen when pointercancel event is received.

Test plan

Tested on expo-example on web

m-bert avatar Jun 17 '25 09:06 m-bert