Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make NativeModules immediately initializable
Summary: ## Problem: NativeModules can only be initialized after we mark them initializable on the NativeModules thread. This work is scheduled in ReactInstanceManager.setupReactContext(), after we schedule the execution of the JS bundle on the JavaScript thread in ReactInstanceManager.createReactContext(): https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java?commit=9b58f58b8eb12281567b8d24d6d000e868e61a1f&lines=1256-1257%2C1331%2C1334-1335%2C1333-1334 So, if the timings don't work out, the JavaScript thread could start executing the JS bundle before the NativeModule thread makes all NativeModules initializable. In this case, those NativeModule will just appear to be null in C++/JavaScript. ## Fix This diff makes all NativeModules initializable immediately after their ModuleHolder is created. ModuleHolder.markInitializable() simply initializes initializes modules that were eagerly created. Changelog: [Android][Fixed] - Make NativeModules immediately initializable Reviewed By: JoshuaGross Differential Revision: D26233372 fbshipit-source-id: a9223ff093da5b80781169be88e6ec9516c7a29b
- Loading branch information