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

Make Fabric event receivers init only once #6907

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
piaskowyk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,20 @@ protected void doFrameGuarded(long frameTimeNanos) {
}
};

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

mAnimationManager = new AnimationsManager(mContext, mUIManager);
}
Expand Down
Loading