expo-modules-core 0.4.3 → 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,26 @@
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
+
19
+ ## 0.4.6 — 2021-10-27
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
23
+ ## 0.4.5 — 2021-10-25
24
+
25
+ _This version does not introduce any user-facing changes._
26
+
27
+ ## 0.4.4 — 2021-10-15
28
+
29
+ ### 🐛 Bug fixes
30
+
31
+ - Fix UIManager has not setter or ivar error when reloading app. ([#14741](https://github.com/expo/expo/pull/14741) by [@kudo](https://github.com/kudo))
32
+
13
33
  ## 0.4.3 — 2021-10-15
14
34
 
15
35
  _This version does not introduce any user-facing changes._
package/README.md CHANGED
@@ -8,7 +8,7 @@ For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-
8
8
 
9
9
  # Installation in bare React Native projects
10
10
 
11
- For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
11
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
12
12
 
13
13
  ### Add the package to your npm dependencies
14
14
 
@@ -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.3'
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.
@@ -56,8 +56,9 @@ android {
56
56
  defaultConfig {
57
57
  minSdkVersion safeExtGet("minSdkVersion", 21)
58
58
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
+ consumerProguardFiles 'proguard-rules.pro'
59
60
  versionCode 1
60
- versionName "0.4.3"
61
+ versionName "0.4.7"
61
62
  }
62
63
  lintOptions {
63
64
  abortOnError false
@@ -1,6 +1,6 @@
1
1
  // Copyright 2016-present 650 Industries. All rights reserved.
2
2
 
3
- #import <ExpoModulesCore/EXBarCodeScannerInterface.h>
3
+ #import <ExpoModulesCore/EXBarcodeScannerInterface.h>
4
4
 
5
5
  @protocol EXBarCodeScannerProviderInterface
6
6
 
@@ -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
@@ -242,8 +243,13 @@ RCT_EXPORT_METHOD(callMethod:(NSString *)moduleName methodNameOrKey:(id)methodNa
242
243
  }
243
244
  }
244
245
 
246
+ // `registerAdditionalModuleClasses:` call below is not thread-safe if RCTUIManager is not initialized.
247
+ // The case happens especially with reanimated which accesses `bridge.uiManager` and initialize bridge in js thread.
248
+ // Accessing uiManager here, we try to make sure RCTUIManager is initialized.
249
+ [bridge uiManager];
250
+
245
251
  // Register the view managers as additional modules.
246
- [bridge registerAdditionalModuleClasses:additionalModuleClasses];
252
+ [self registerAdditionalModuleClasses:additionalModuleClasses inBridge:bridge];
247
253
 
248
254
  // Bridge's `registerAdditionalModuleClasses:` method doesn't register
249
255
  // components in UIManager — we need to register them on our own.
@@ -258,6 +264,32 @@ RCT_EXPORT_METHOD(callMethod:(NSString *)moduleName methodNameOrKey:(id)methodNa
258
264
  [_exModuleRegistry initialize];
259
265
  }
260
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
+
261
293
  - (void)registerComponentDataForModuleClasses:(NSArray<Class> *)moduleClasses inBridge:(RCTBridge *)bridge
262
294
  {
263
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.3",
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": "d23e1ac491da96b51c25eb2533efcd56499ee287"
45
+ "gitHead": "42eccf17fce009282234ba2d5d40a37d6fff4e86"
46
46
  }