Add bridgeless check so that we notify listeners if activity is already resumed

Summary:
When a native module registers itself as a lifecycle event listener, ReactContext will immediately call `onHostResume` if the activity is already in a resumed state. We rely on this behavior for things like NativeAnimatedModule, which only enqueues the frame callback in onHostResume. However, ReactContext only does this if `hasActiveCatalystInstance()` returns true - which makes sense, because we don't want to notify listeners if the instance has been destroyed. But in bridgeless mode, `hasActiveCatalystInstance` returns false, and we never call `onHostResume` in this case.

This diff fixes an issue where native driver animations don't work the first time you navigate to a screen with bridgeless mode enabled.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22560314

fbshipit-source-id: 1a60cb482896308e21d6e438eb9a7314f580ad04
This commit is contained in:
Emily Janzer
2020-07-16 11:37:12 -07:00
committed by Facebook GitHub Bot
parent 5ac524bdbc
commit e12cf7d069
@@ -183,7 +183,7 @@ public class ReactContext extends ContextWrapper {
public void addLifecycleEventListener(final LifecycleEventListener listener) {
mLifecycleEventListeners.add(listener);
if (hasActiveCatalystInstance()) {
if (hasActiveCatalystInstance() || isBridgeless()) {
switch (mLifecycleState) {
case BEFORE_CREATE:
case BEFORE_RESUME: