Force FbReactInstanceManagerAppJob.IdleExecutor to run in the UIThread

Summary:
`createReactContextInBackground` must be run on the UI Thread, so we update the DI annotation from `DefaultIdleExecutor` to `ForUiThread` so that happens.

Unclear why Infer didn't flag this. Asked [here](https://fb.workplace.com/groups/572076376174315/permalink/2661423100572955/).

Also adds an additional thread assert before setting `mHasStartedCreatingInitialContext = true` so that if a similar bug happens in the future, RN won't be completely hosed.

Reviewed By: mdvacca

Differential Revision: D16574901

fbshipit-source-id: 02ba63979904e9df9ef6d782aa7379cb44702508
This commit is contained in:
Spencer Ahrens
2019-07-30 20:28:27 -07:00
committed by Facebook Github Bot
parent f161583713
commit c46353abe4
@@ -337,6 +337,8 @@ public class ReactInstanceManager {
@ThreadConfined(UI)
public void createReactContextInBackground() {
Log.d(ReactConstants.TAG, "ReactInstanceManager.createReactContextInBackground()");
UiThreadUtil
.assertOnUiThread(); // Assert before setting mHasStartedCreatingInitialContext = true
if (!mHasStartedCreatingInitialContext) {
mHasStartedCreatingInitialContext = true;
recreateReactContextInBackgroundInner();