Skip to content

fix: rename window variable to avoid Hermes global collision and add listener cleanup#2679

Open
parkjmjohn wants to merge 1 commit into
gorhom:masterfrom
parkjmjohn:master
Open

fix: rename window variable to avoid Hermes global collision and add listener cleanup#2679
parkjmjohn wants to merge 1 commit into
gorhom:masterfrom
parkjmjohn:master

Conversation

@parkjmjohn
Copy link
Copy Markdown

@parkjmjohn parkjmjohn commented May 21, 2026

Fixes #2678

Problem

In useAnimatedLayout.ts, the Dimensions.addEventListener callback destructures the event as { window }. On the Hermes JS engine, worklets run in a UI runtime that exposes a global window object. When a Dimensions change fires (app switching, entering Maps/Camera, device rotation) while a bottom sheet is mounted, Hermes resolves the captured window variable through its global lookup instead of the local destructured value — causing a crash.

Additionally, the listener was never cleaned up: the useEffect returned nothing, so the subscription leaked on every unmount.

Fix

  • Renames the destructured parameter from window to windowDimensions to avoid the collision with the Hermes global.
  • Stores the subscription returned by addEventListener and calls subscription.remove() in the effect cleanup.

…listener cleanup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rareAnshh
Copy link
Copy Markdown

This is going to resolve a major crash due to this package.
I support this Merge.

@rareAnshh
Copy link
Copy Markdown

@gorhom Please have a look into this

@RomanSytnyk
Copy link
Copy Markdown

It's an important fix

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.

[Bug]: ReferenceError: Property 'window' doesn't exist. Worklet -> (IOS/Android)

4 participants