fix: rename window variable to avoid Hermes global collision and add listener cleanup - #2679
parkjmjohn wants to merge 1 commit into
Conversation
…listener cleanup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This is going to resolve a major crash due to this package. |
|
@gorhom Please have a look into this |
|
It's an important fix |
|
These changes fix the same type of crash in our app as well. It would be great to have it included in a release. |
|
FYI @gorhom |
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
The app I'm working on, suffers from this same bug. This PR would solve it. Please, can you include it on the next release? thanks. |
|
See also #2687 |
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
I think this PR should stay active / shouldn't be closed since the issue was not resolved. |
Fixes #2678
Problem
In
useAnimatedLayout.ts, theDimensions.addEventListenercallback destructures the event as{ window }. On the Hermes JS engine, worklets run in a UI runtime that exposes a globalwindowobject. When aDimensionschange fires (app switching, entering Maps/Camera, device rotation) while a bottom sheet is mounted, Hermes resolves the capturedwindowvariable through its global lookup instead of the local destructured value — causing a crash.Additionally, the listener was never cleaned up: the
useEffectreturned nothing, so the subscription leaked on every unmount.Fix
windowtowindowDimensionsto avoid the collision with the Hermes global.addEventListenerand callssubscription.remove()in the effect cleanup.