Skip to content

Commit 16c6f7a

Browse files
authored
fix: LA Manager initialized too late on the UI runtime (#7954)
## Summary This PR fixes too late initialization of the UI LA manager, which caused crashes when the view with entering LA was rendered before initialization of this manager. ## Example recordings ### Before <video src="https://github.com/user-attachments/assets/af6e5071-d2f6-42af-8634-2cbcc2b910ae" ></video> ### After <video src="https://github.com/user-attachments/assets/ba24d946-f7e1-4d9e-b745-3371d00a6a61" ></video> ## Test example Replace the entire app's code (`e.g. in the `fabric-example/App.tsx`) with the following code: ```tsx import Animated, { FadeIn } from 'react-native-reanimated'; export default function App() { return ( <Animated.View entering={FadeIn} style={{ width: 100, height: 100, backgroundColor: 'red' }} /> ); } ``` It crashed before this change and works after applying changes from this PR.
1 parent 7e8b944 commit 16c6f7a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/react-native-reanimated/src/layoutReanimation/animationsManager.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
2-
import { runOnUI } from 'react-native-worklets';
2+
import { executeOnUIRuntimeSync } from 'react-native-worklets';
33

44
import { withStyleAnimation } from '../animation';
5+
import { SHOULD_BE_USE_WEB } from '../common';
56
import type {
67
LayoutAnimation,
78
LayoutAnimationStartFunction,
@@ -100,10 +101,12 @@ function createLayoutAnimationManager(): {
100101
};
101102
}
102103

103-
runOnUI(() => {
104-
'worklet';
105-
global.LayoutAnimationsManager = createLayoutAnimationManager();
106-
})();
104+
if (!SHOULD_BE_USE_WEB) {
105+
executeOnUIRuntimeSync(() => {
106+
'worklet';
107+
global.LayoutAnimationsManager = createLayoutAnimationManager();
108+
})();
109+
}
107110

108111
export type LayoutAnimationsManager = ReturnType<
109112
typeof createLayoutAnimationManager

0 commit comments

Comments
 (0)