moveToResumedLifecycleState must be called from UI thread

Summary:
I was seeing a SoftException in our apps due to this method being called as part of ReactInstanceManager's init. It seems inconsistent that we would call this from a background thread when all other `onHost*` methods are marked as confined to the UI thread.

Changelog: [Internal]

Reviewed By: ryancat

Differential Revision: D34340210

fbshipit-source-id: 0104eda66b2ca6bb315e64e806e9a30409d0d45c
This commit is contained in:
Pieter De Baets
2022-02-18 11:23:42 -08:00
committed by Facebook GitHub Bot
parent bb7214b9c4
commit fc35a65a7e
2 changed files with 9 additions and 5 deletions
@@ -254,6 +254,7 @@ public class ReactContext extends ContextWrapper {
}
/** Should be called by the hosting Fragment in {@link Fragment#onResume} */
@ThreadConfined(UI)
public void onHostResume(@Nullable Activity activity) {
mLifecycleState = LifecycleState.RESUMED;
mCurrentActivity = new WeakReference(activity);
@@ -282,6 +283,7 @@ public class ReactContext extends ContextWrapper {
}
/** Should be called by the hosting Fragment in {@link Fragment#onPause} */
@ThreadConfined(UI)
public void onHostPause() {
mLifecycleState = LifecycleState.BEFORE_RESUME;
ReactMarker.logMarker(ReactMarkerConstants.ON_HOST_PAUSE_START);