Skip to content

fix(pinch): stop native-stack overflow on rapid pinch under Reanimated 4#127

Open
ssahil97 wants to merge 1 commit into
Glazzes:mainfrom
ssahil97:fix/pinch-reset-stack-overflow-reanimated4
Open

fix(pinch): stop native-stack overflow on rapid pinch under Reanimated 4#127
ssahil97 wants to merge 1 commit into
Glazzes:mainfrom
ssahil97:fix/pinch-reset-stack-overflow-reanimated4

Conversation

@ssahil97

@ssahil97 ssahil97 commented Jul 6, 2026

Copy link
Copy Markdown

Fixes #126.

usePinchCommons reset() wrote gestureEnd.value inside its own withTiming callback unconditionally. Under Reanimated 4.x, valueSetter invokes a still-live animation's callback(false) when the value is overwritten/cancelled before clearing _animation, so the self-write re-enters the same callback and recurses to Maximum call stack size exceeded (native stack depth) on rapid pinch in/out.

This gates the reset on finished, mirroring usePanCommons (which never self-writes the shared value). On a real finish it writes once and the re-entrant finished === false call is a single no-op level deep; on cancel it never writes. gestureEnd is an internal gimmick (never read in a style), so the change is behavior-preserving.

Verified on-device (iOS, RN 0.86, Reanimated 4.5.0): rapid pinch in/out no longer overflows the native stack.

…erflow under Reanimated 4

usePinchCommons' reset() wrote gestureEnd.value inside its own withTiming
callback unconditionally. Under Reanimated 4.x, valueSetter fires a still-live
animation's callback(false) before clearing _animation when the value is
overwritten, so the self-write re-enters the same callback and recurses to a
'Maximum call stack size exceeded (native stack depth)' crash on rapid pinch
in/out. Gate the write on `finished`, matching usePanCommons which never
self-writes. gestureEnd is an internal gimmick (never read in a style), so this
is behavior-preserving.

Fixes Glazzes#126
@Lewdaghen

Copy link
Copy Markdown

Thanks

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

Successfully merging this pull request may close these issues.

Pinch in/out crashes with 'Maximum call stack size exceeded' under Reanimated 4.5 (usePinchCommons reset self-write)

2 participants