expo-modules-core 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.4.7 — 2021-10-28
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fix iOS app freezing in remote debugging mode. ([#14922](https://github.com/expo/expo/pull/14922) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 0.4.6 — 2021-10-27
14
20
 
15
21
  _This version does not introduce any user-facing changes._
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '0.4.6'
6
+ version = '0.4.7'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -58,7 +58,7 @@ android {
58
58
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
59
  consumerProguardFiles 'proguard-rules.pro'
60
60
  versionCode 1
61
- versionName "0.4.6"
61
+ versionName "0.4.7"
62
62
  }
63
63
  lintOptions {
64
64
  abortOnError false
@@ -32,6 +32,7 @@ static const NSString *methodInfoArgumentsCountKey = @"argumentsCount";
32
32
 
33
33
  @interface RCTBridge (RegisterAdditionalModuleClasses)
34
34
 
35
+ - (NSArray<RCTModuleData *> *)registerModulesForClasses:(NSArray<Class> *)moduleClasses;
35
36
  - (void)registerAdditionalModuleClasses:(NSArray<Class> *)modules;
36
37
 
37
38
  @end
@@ -248,7 +249,7 @@ RCT_EXPORT_METHOD(callMethod:(NSString *)moduleName methodNameOrKey:(id)methodNa
248
249
  [bridge uiManager];
249
250
 
250
251
  // Register the view managers as additional modules.
251
- [bridge registerAdditionalModuleClasses:additionalModuleClasses];
252
+ [self registerAdditionalModuleClasses:additionalModuleClasses inBridge:bridge];
252
253
 
253
254
  // Bridge's `registerAdditionalModuleClasses:` method doesn't register
254
255
  // components in UIManager — we need to register them on our own.
@@ -263,6 +264,32 @@ RCT_EXPORT_METHOD(callMethod:(NSString *)moduleName methodNameOrKey:(id)methodNa
263
264
  [_exModuleRegistry initialize];
264
265
  }
265
266
 
267
+ - (void)registerAdditionalModuleClasses:(NSArray<Class> *)moduleClasses inBridge:(RCTBridge *)bridge
268
+ {
269
+ // In remote debugging mode, i.e. executorClass is `RCTWebSocketExecutor`,
270
+ // there is a deadlock issue in `registerAdditionalModuleClasses:` and causes app freezed.
271
+ // - The JS thread acquired the `RCTCxxBridge._moduleRegistryLock` lock in `RCTCxxBridge._initializeBridgeLocked`
272
+ // = it further goes into RCTObjcExecutor and tries to get module config from main thread
273
+ // - The main thread is pending in `RCTCxxBridge.registerAdditionalModuleClasses` where trying to acquire the same lock.
274
+ // To workaround the deadlock, we tend to use the non-locked registration and mutate the bridge internal module data.
275
+ // Since JS thread in this situation is waiting for main thread, it's safe to mutate module data without lock.
276
+ // The only risk should be the internal `_moduleRegistryCreated` flag without lock protection.
277
+ // As we just workaround in `RCTWebSocketExecutor` case, the risk of `_moduleRegistryCreated` race condition should be lower.
278
+ //
279
+ // Learn more about the non-locked initialization:
280
+ // https://github.com/facebook/react-native/blob/757bb75fbf837714725d7b2af62149e8e2a7ee51/React/CxxBridge/RCTCxxBridge.mm#L922-L935
281
+ // See the `_moduleRegistryCreated` false case
282
+ if ([NSStringFromClass([bridge executorClass]) isEqualToString:@"RCTWebSocketExecutor"]) {
283
+ NSNumber *moduleRegistryCreated = [bridge valueForKey:@"_moduleRegistryCreated"];
284
+ if (![moduleRegistryCreated boolValue]) {
285
+ [bridge registerModulesForClasses:moduleClasses];
286
+ return;
287
+ }
288
+ }
289
+
290
+ [bridge registerAdditionalModuleClasses:moduleClasses];
291
+ }
292
+
266
293
  - (void)registerComponentDataForModuleClasses:(NSArray<Class> *)moduleClasses inBridge:(RCTBridge *)bridge
267
294
  {
268
295
  // Hacky way to get a dictionary with `RCTComponentData` from UIManager.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "@testing-library/react-hooks": "^7.0.1",
43
43
  "expo-module-scripts": "^2.0.0"
44
44
  },
45
- "gitHead": "59adc892501ce855c3c758fc984e06a766d00f76"
45
+ "gitHead": "42eccf17fce009282234ba2d5d40a37d6fff4e86"
46
46
  }