-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
After updating to expo 52: ReferenceError: _WORKLET | __reanimatedLoggerConfig is not defined #6740
Comments
@hirbod @abretonc7s I'm on it! |
Heyi @abretonc7s @hirbod I tried to reproduce it locally but it didn't work. Could you provide some minimal expo repo where this issue appears? |
similar here. |
For now, I added if (Platform.OS === 'web') {
global._WORKLET = false
// @ts-expect-error
global._log = console.log
// @ts-expect-error
global._getAnimationTimestamp = () => performance.now()
} as a hack in my entrypoint. Everything works now, beside reanimatedLoggerConfig, but I don't import configureReanimatedLogger for web. |
@abretonc7s @hirbod @MariusCatanoiu The supposed fix is available on @next and @nightly versions of Reanimated. Could you install it and see if it resolves the issue? |
Well that sucks 🤔 |
That aligns with my observations, as I also tried patch 3.16.2, and it didn’t work. Now, let me add a bit more confusion to the topic: if (Platform.OS !== 'web') {
// We need to set the log level to error to avoid spamming the console because of NativeWind for now
configureReanimatedLogger({
level: ReanimatedLogLevel.error,
});
} else {
global._WORKLET = false;
// @ts-expect-error
global._log = console.log;
// @ts-expect-error
global._getAnimationTimestamp = () => performance.now();
} This is my "hack." After adding it, changing the |
Yes, it happened to me a few times recently that only after |
@abretonc7s Could you see if wiping all the caches works for you on the nightly versions? |
Doesn't work with the nighlty, cleaning all caches. You can easily reproduce, just make a component and run it on web import React, { useEffect } from 'react'
import { ColorValue, View } from 'react-native'
import { Text } from 'react-native-paper'
import Animated, {
useAnimatedStyle,
useSharedValue,
withRepeat,
withSpring,
} from 'react-native-reanimated'
interface LoaderProps {
color?: ColorValue
size?: number
}
const Loader = ({ color, size = 40 }: LoaderProps) => {
const rotateValue = useSharedValue(0)
const handleRotation = (value: number): string => {
'worklet'
return `${value * 4 * Math.PI}rad`
}
const rotateStyles = useAnimatedStyle(() => {
return {
transform: [
{ rotate: handleRotation(rotateValue.value) },
{ scale: rotateValue.value + 0.3 },
],
opacity: rotateValue.value + 0.2,
borderRadius: rotateValue.value * 20,
}
})
useEffect(() => {
rotateValue.value = withRepeat(withSpring(0.5), -1, true)
}, [])
return (
<View
style={{
justifyContent: 'center',
alignItems: 'center',
}}
>
<Animated.View
style={[
{
height: size,
width: size,
backgroundColor: color,
marginTop: 5,
},
rotateStyles,
]}
/>
</View>
)
}
const TestScreen = () => {
return (
<View>
<Text>Test</Text>
<Loader />
</View>
)
}
export default TestScreen util.js:347 Uncaught ReferenceError: _WORKLET is not defined |
@abretonc7s When I run this snippet on a fresh Expo app and start web everything works well. |
Same happening here, web only works with 3.15.x but Android only works on 3.16.x. (RN 0.76) |
I have the reverse issue... 3.15 works for web but then android conflicts... Anyway expo recommends 3.16.1 which has the web issue.
|
I'd love to take a look at this issue too, mostly to see if this is a Reanimated issue or an Expo issue. Unfortunately, I can't reproduce with none of the examples here, nor do I get If someone can provide a repro, using the blank or default Expo templates, I'd be more than happy to debug this too. PS. The original monorepo posted also did not trigger this error for me. |
Hey @byCedric I pushed an update to https://deeeed.github.io/expo-audio-stream/playground/more where you can see the bug. You can just pull this branch and run locally as well https://github.com/deeeed/expo-audio-stream/tree/docupdate Currently there is a switch that enabled / disable the hack which is : import { useToast } from '@siteed/design-system'
import { useCallback, useEffect, useState } from 'react'
import { Platform } from 'react-native'
import { baseLogger } from '../config'
const logger = baseLogger.extend('useReanimatedWebHack')
export function useReanimatedWebHack() {
const [isHackEnabled, setIsHackEnabled] = useState(false)
const { show } = useToast()
useEffect(() => {
if (Platform.OS === 'web') {
// Initialize state based on existing global._WORKLET
const initialValue = !!global._WORKLET
logger.log('initialValue', initialValue)
setIsHackEnabled(initialValue)
}
}, [])
const handleHackToggle = useCallback((value: boolean) => {
logger.log('handleHackToggle', value)
if (Platform.OS === 'web') {
setIsHackEnabled(value)
if (value) {
global._WORKLET = false
// @ts-expect-error
global._log = console.log
// @ts-expect-error
global._getAnimationTimestamp = () => performance.now()
show({
type: 'success',
iconVisible: true,
message: 'Reanimated Web Hack Enabled',
})
} else {
delete global._WORKLET
// @ts-expect-error
delete global._log
// @ts-expect-error
delete global._getAnimationTimestamp
show({
type: 'warning',
iconVisible: true,
message: 'Reanimated Web Hack Disabled',
})
}
}
}, [])
return {
isHackEnabled,
handleHackToggle,
}
} To see the issue, just go to the main page and start recording, without the hack you will get the error: This deployed page runs with "react-native-reanimated": "3.17.0-nightly-20241204-5ffa47792", |
Description
After updating to Expo SDK 52, I encountered a ReferenceError: _WORKLET is not defined error on web platform. This error occurred after running expo install --fix to update dependencies. The error prevents the application from running properly on web.
Relevant dependencies:
Steps to reproduce
on Web it seems that using any wtihTiming creates the issue.
Snack or a link to a repository
https://github.com/deeeed/expo-audio-stream/blob/main/apps/playground/src/app/minimal.tsx
Reanimated version
3.6.1
React Native version
0.76.2
Platforms
Android, iOS, Web
JavaScript runtime
Hermes
Workflow
Expo Dev Client
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
Real device
Device model
iphone pro 13
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: