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

ReanimatedError: Property 'window' doesn't exist, js engine: reanimated #6472

Open
wcandillon opened this issue Sep 2, 2024 · 5 comments
Open
Labels
Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS

Comments

@wcandillon
Copy link
Contributor

Description

After upgrading from 3.6 to 3.15, variables named window seem to be treated differently. In examples where I had a variable named window. I got the following error: ReanimatedError: Property 'window' doesn't exist, js engine: reanimated. I assumed this is because of the window variable on Web. Renaming this variable to something else (e.g win), fixes the issue immediately.

Steps to reproduce

Create an example that uses window as a variable name, e.g: https://github.com/Shopify/react-native-skia/blob/main/example/src/Examples/Vertices/Vertices.tsx#L25

Snack or a link to a repository

https://github.com/Shopify/react-native-skia/blob/main/example/src/Examples/Vertices/Vertices.tsx#L25

Reanimated version

3.15

React Native version

0.75

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added the Missing repro This issue need minimum repro scenario label Sep 2, 2024
Copy link

github-actions bot commented Sep 2, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Platform: iOS This issue is specific to iOS label Sep 2, 2024
@MicroDroid
Copy link

Are you sure variables named window cause this error to show up? Because I don't have such a variable in my code base, and if it's from a library then woah it's going to be really weird trying to search for every variable ever defined in my zillion dependencies tree lol

@MicroDroid
Copy link

(I similarly upgraded from 3.6 to 3.15)

@tomekzaw
Copy link
Member

tomekzaw commented Sep 16, 2024

Hey @wcandillon, thanks for opening the issue.

Heads-up: link in issue description is broken, here's a correct link: https://github.com/Shopify/react-native-skia/blob/963d1c35dc57e5c36e178fa66b878c75f1a17d6f/apps/paper/src/Examples/Vertices/Vertices.tsx#L25 (with win instead of window)

You're right, it looks like window was added to notCapturedIdentifiers array in Reanimated Babel Plugin (here) in #6284.

So previously window would get captured into worklet closure like a regular variable but since 3.15.0 it is not captured (now it's treated analogously to global or globalThis).

However, in worklet runtime, window is not defined, hence the error Property 'window' doesn't exist.

cc @tjzel who's the author of the PR

@tjzel
Copy link
Collaborator

tjzel commented Sep 16, 2024

@tomekzaw Explained it well.

The closure capturing in worklets isn't smart. It doesn't use all semantic analysis available to it. In result it's not really feasible to discern if window refer to some local variable or if it refers to the global window object.

While this could be improved (and I hope in the future I will find some time for it) I strongly advise not to name variables window, same as you shouldn't name them global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS
Projects
None yet
Development

No branches or pull requests

4 participants