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

[Web]ReferenceError: _frameTimestamp is not defined #3355

Closed
1 of 3 tasks
alantoa opened this issue Jul 4, 2022 · 26 comments · Fixed by #3418
Closed
1 of 3 tasks

[Web]ReferenceError: _frameTimestamp is not defined #3355

alantoa opened this issue Jul 4, 2022 · 26 comments · Fixed by #3418
Labels
Missing repro This issue need minimum repro scenario Needs review Issue is ready to be reviewed by a maintainer Platform: Web This issue is specific to web

Comments

@alantoa
Copy link

alantoa commented Jul 4, 2022

Description

Get this error when upgrading react-native-reanimated to v2.9.0+ on the web (v2.8.0 works), it works fine on iOS and Android.

image

Expected behavior

Works on the web.

Actual behavior & steps to reproduce

web not working when upgrading to v2.9.0+.

Snack or minimal code example

https://github.com/tamagui/starters/tree/main/next-expo-solito

Package versions

name version
react-native 0.68.2
react-native-reanimated 2.9.1
NodeJS 16.15.1
Xcode 13.4.1
Java
Gradle
expo 45.0.2

Affected platforms

  • Android
  • iOS
  • Web
@alantoa alantoa added the Needs review Issue is ready to be reviewed by a maintainer label Jul 4, 2022
@github-actions github-actions bot added Platform: Web This issue is specific to web Missing repro This issue need minimum repro scenario labels Jul 4, 2022
@github-actions
Copy link

github-actions bot commented Jul 4, 2022

Hey! 👋

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

Could you provide a snippet of code, a snack or a link to a GitHub repository that reproduces the problem?

@github-actions github-actions bot added the Missing info The user didn't precise the problem enough label Jul 4, 2022
@zzph
Copy link

zzph commented Jul 13, 2022

I'm also facing this issue, on 2.9.1 on web.

For example, in this repo (not minimal): https://github.com/tamagui/starters/tree/main/next-expo-solito

Has anyone found a solution?

@github-actions github-actions bot removed the Missing info The user didn't precise the problem enough label Jul 13, 2022
@tpisto
Copy link

tpisto commented Jul 15, 2022

Same problem with simple react-native-web project with library v2.9.1 and react-native v0.69.1. Error is in "styleUpdater" function:

Screenshot 2022-07-16 at 1 03 35


Seems quick workaround is to add window._frameTimestamp = null on top of the component file =)

@mikevocalz
Copy link

which file to be exact?

@mo-fouad
Copy link

had the same issue with V2.9 and had to downgrade to 2.8.

piaskowyk added a commit that referenced this issue Aug 5, 2022
## Description

The PR with tree shaking moved global objects initialization for web to another file and then imported it into the `index` file (`import './reanimated2/js-reanimated/global';`). However, the Webpack can lazy import modules, but we don't have any call to this module, so global objects were never initialized.

Fixes #3355
@WillenOLeal
Copy link

Having the same issue while using Next.js any updates on this?

@piaskowyk
Copy link
Member

@WillenOLeal I fixed it, but this hasn't been released yet. I want to release the new version this week.

@azimgd
Copy link

azimgd commented Aug 15, 2022

Hey @piaskowyk. Can we get new version released please ?

@github-actions
Copy link

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?

@vbylen
Copy link

vbylen commented Aug 17, 2022

Hmm I'm on 3.0.0-rc.1 and still getting the _frameTimestamp is not defined error on web.

piaskowyk added a commit that referenced this issue Aug 17, 2022
The PR with tree shaking moved global objects initialization for web to another file and then imported it into the `index` file (`import './reanimated2/js-reanimated/global';`). However, the Webpack can lazy import modules, but we don't have any call to this module, so global objects were never initialized.

Fixes #3355
@ChronSyn
Copy link

ChronSyn commented Aug 22, 2022

I've been experiencing this recently too. My use-case was with Moti (on Expo SDK46) presence animation. Version 2.8.0 and 2.9.x versions were all experiencing this issue.

I've found that this issue seems to only happen in the built bundle, and not when running local dev (e.g. via expo start --web). The correct transpilation process is setup for moti and reanimated.

(Sorry for cross-promoting, but switching to https://legendapp.com/dev/motion/animate-presence/ on web solves my specific issue - might be useful for others, though this doesn't have the performance benefits of reanimated)

@dohomi
Copy link

dohomi commented Aug 25, 2022

I bumped into the issue as well on the latest 3.0.0-rc2. Is there a temporary solution for it?

@tpisto
Copy link

tpisto commented Aug 25, 2022

I bumped into the issue as well on the latest 3.0.0-rc2. Is there a temporary solution for it?

Add window._frameTimestamp = null on top of the component file

@jesse-savary
Copy link

jesse-savary commented Aug 26, 2022

I bumped into the issue as well on the latest 3.0.0-rc2. Is there a temporary solution for it?

Stick the following at the top of _app.tsx, outside the component definition:

// FIXME need reanimated update, see https://github.com/software-mansion/react-native-reanimated/issues/3355
if (process.browser) {
  // @ts-ignore
  window._frameTimestamp = null
}

@sunnylqm
Copy link
Contributor

still not fixed on 2.11.0

@crutch12
Copy link

crutch12 commented Nov 1, 2022

Bump

1 similar comment
@bombillazo
Copy link

Bump

@JamesHemery
Copy link

Today on 2.12.0 with #3418 merged the problem is still present after building the application with Expo.

Temp fix of @jesse-savary works:

I bumped into the issue as well on the latest 3.0.0-rc2. Is there a temporary solution for it?

Stick the following at the top of _app.tsx, outside the component definition:

// FIXME need reanimated update, see https://github.com/software-mansion/react-native-reanimated/issues/3355
if (process.browser) {
  // @ts-ignore
  window._frameTimestamp = null
}

@Ryanjso
Copy link

Ryanjso commented Jan 24, 2023

We're still having this issue

@pencilcheck
Copy link

pencilcheck commented Apr 19, 2023

Still having this issue, looks like it went away after upgrading to 3.x.x

@prateem
Copy link

prateem commented Apr 20, 2023

Today on 2.12.0 with #3418 merged the problem is still present after building the application with Expo.

Temp fix of @jesse-savary works:

I bumped into the issue as well on the latest 3.0.0-rc2. Is there a temporary solution for it?

Stick the following at the top of _app.tsx, outside the component definition:

// FIXME need reanimated update, see https://github.com/software-mansion/react-native-reanimated/issues/3355
if (process.browser) {
  // @ts-ignore
  window._frameTimestamp = null
}

I get error process is not defined, am I missing something?

@Ryanjso
Copy link

Ryanjso commented Apr 20, 2023

Today on 2.12.0 with #3418 merged the problem is still present after building the application with Expo.
Temp fix of @jesse-savary works:

I bumped into the issue as well on the latest 3.0.0-rc2. Is there a temporary solution for it?

Stick the following at the top of _app.tsx, outside the component definition:

// FIXME need reanimated update, see https://github.com/software-mansion/react-native-reanimated/issues/3355
if (process.browser) {
  // @ts-ignore
  window._frameTimestamp = null
}

I get error process is not defined, am I missing something?

You need to let TS know that process exists. Create a file named global.d.ts and add the following to it:

declare namespace NodeJS {
    interface Process {
        browser: boolean
    }
}

@prateem
Copy link

prateem commented Apr 20, 2023

You need to let TS know that process exists. Create a file named global.d.ts and add the following to it:

declare namespace NodeJS {
    interface Process {
        browser: boolean
    }
}

Thanks for the quick reply! I've tried this and I still get this error in the console:

Uncaught ReferenceError: process is not defined
    at ./App.tsx (App.tsx:9:1)
    at __webpack_require__ (bootstrap:24:1)

for environment context I am using expo if that makes a difference

@jgo80
Copy link

jgo80 commented Apr 23, 2023

@prateem use this instead:

if (typeof window !== 'undefined') {
  window._frameTimestamp = null;
}

fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this issue Jun 5, 2023
## Description

The PR with tree shaking moved global objects initialization for web to another file and then imported it into the `index` file (`import './reanimated2/js-reanimated/global';`). However, the Webpack can lazy import modules, but we don't have any call to this module, so global objects were never initialized.

Fixes software-mansion#3355
letam added a commit to letam/expo-react-native-app-tutorial-2023 that referenced this issue Jun 12, 2023
- Note: There's a bug with the Reanimiated lib; applying fix found at
  software-mansion/react-native-reanimated#3355 (comment)
@GiladR1979
Copy link

What solved this for me is this, after tearing a few hairs for half a day:
npm start -- --reset-cache
or if you use yarn:
yarn cache clean

@Pramela-Devi-S
Copy link

Clean your cache use this command in your project directory->npx react-native clean cache. It should work
✔ Select all caches to clean › metro (Metro, haste-map caches), watchman (Stop Watchman and delete its cache)
✔ Clean Metro cache
✔ Clean Haste cache
✔ Clean React Native cache
✔ Stop Watchman
✔ Delete Watchman cache

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 Needs review Issue is ready to be reviewed by a maintainer Platform: Web This issue is specific to web
Projects
None yet
Development

Successfully merging a pull request may close this issue.