Skip to content

Commit 0136c60

Browse files
committed
make event receivers init only once on fabric
1 parent b02cdb0 commit 0136c60

File tree

1 file changed

+14
-12
lines changed
  • packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated

1 file changed

+14
-12
lines changed

packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,20 @@ protected void doFrameGuarded(long frameTimeNanos) {
187187
}
188188
};
189189

190-
// We register as event listener at the end, because we pass `this` and we haven't finished
191-
// constructing an object yet.
192-
// This lead to a crash described in
193-
// https://github.com/software-mansion/react-native-reanimated/issues/604 which was caused by
194-
// Nodes Manager being constructed on UI thread and registering for events.
195-
// Events are handled in the native modules thread in the `onEventDispatch()` method.
196-
// This method indirectly uses `mChoreographerCallback` which was created after event
197-
// registration, creating race condition
198-
EventDispatcher eventDispatcher =
199-
Objects.requireNonNull(UIManagerHelper.getEventDispatcher(context, uiManagerType));
200-
eventDispatcher.addListener(this);
201-
mUnsubscribe = () -> eventDispatcher.removeListener(this);
190+
if(!BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
191+
// We register as event listener at the end, because we pass `this` and we haven't finished
192+
// constructing an object yet.
193+
// This lead to a crash described in
194+
// https://github.com/software-mansion/react-native-reanimated/issues/604 which was caused by
195+
// Nodes Manager being constructed on UI thread and registering for events.
196+
// Events are handled in the native modules thread in the `onEventDispatch()` method.
197+
// This method indirectly uses `mChoreographerCallback` which was created after event
198+
// registration, creating race condition
199+
EventDispatcher eventDispatcher =
200+
Objects.requireNonNull(UIManagerHelper.getEventDispatcher(context, uiManagerType));
201+
eventDispatcher.addListener(this);
202+
mUnsubscribe = () -> eventDispatcher.removeListener(this);
203+
}
202204

203205
mAnimationManager = new AnimationsManager(mContext, mUIManager);
204206
}

0 commit comments

Comments
 (0)