mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Back out "Make NativeModules immediately initializable"
Summary: This caused a few apps to crash on launch. Changelog: [Android][Fixed] - Crashes due to "Make NativeModules immediately initializable" Reviewed By: olegbl Differential Revision: D26278594 fbshipit-source-id: 969a3dc49a843366c4ae6ed19a9233d1e6f39b13
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a70dc4bcad
commit
b474be6cc8
@@ -50,6 +50,7 @@ public class ModuleHolder {
|
||||
private @Nullable @GuardedBy("this") NativeModule mModule;
|
||||
|
||||
// These are used to communicate phases of creation and initialization across threads
|
||||
private @GuardedBy("this") boolean mInitializable;
|
||||
private @GuardedBy("this") boolean mIsCreating;
|
||||
private @GuardedBy("this") boolean mIsInitializing;
|
||||
|
||||
@@ -88,6 +89,7 @@ public class ModuleHolder {
|
||||
boolean shouldInitializeNow = false;
|
||||
NativeModule module = null;
|
||||
synchronized (this) {
|
||||
mInitializable = true;
|
||||
if (mModule != null) {
|
||||
Assertions.assertCondition(!mIsInitializing);
|
||||
shouldInitializeNow = true;
|
||||
@@ -191,7 +193,7 @@ public class ModuleHolder {
|
||||
boolean shouldInitializeNow = false;
|
||||
synchronized (this) {
|
||||
mModule = module;
|
||||
if (!mIsInitializing) {
|
||||
if (mInitializable && !mIsInitializing) {
|
||||
shouldInitializeNow = true;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +227,7 @@ public class ModuleHolder {
|
||||
boolean shouldInitialize = false;
|
||||
// Check to see if another thread is initializing the object, if not claim the responsibility
|
||||
synchronized (this) {
|
||||
if (!mIsInitializing) {
|
||||
if (mInitializable && !mIsInitializing) {
|
||||
shouldInitialize = true;
|
||||
mIsInitializing = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user