Skip to content

Commit

Permalink
fix(ios): fix some issues (#1679)
Browse files Browse the repository at this point in the history
* fix(ios): fix a deadlock issue for module data

* fix(ios): fix data race in batched bridge
  • Loading branch information
ozonelmy authored and zoomchan-cxj committed Mar 29, 2022
1 parent 3e15f5c commit 8a88f0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ios/sdk/base/HippyBatchedBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,14 @@ - (id)callNativeModule:(NSUInteger)moduleID method:(NSUInteger)methodID params:(
return nil;
}
}
if (methodID >= [moduleData.methods count]) {
NSArray<id<HippyBridgeMethod>> *methods = [moduleData.methods copy];
if (methodID >= [methods count]) {
if (_valid) {
HippyLogError(@"methodID %lu exceed range of moduleData.methods %lu, bridge is valid %ld", moduleID, [moduleData.methods count], (long)_valid);
HippyLogError(@"methodID %lu exceed range of moduleData.methods %lu, bridge is valid %ld", moduleID, [methods count], (long)_valid);
}
return nil;
}
id<HippyBridgeMethod> method = moduleData.methods[methodID];
id<HippyBridgeMethod> method = methods[methodID];
if (HIPPY_DEBUG && !method) {
if (_valid) {
HippyLogError(@"Unknown methodID: %lu for module: %lu (%@)", (unsigned long)methodID, (unsigned long)moduleID, moduleData.name);
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/base/HippyModuleData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ - (void)setMethodQueue:(dispatch_queue_t)methodQueue {
}

- (dispatch_queue_t)methodQueue {
[self instance];
@synchronized(self) {
[self instance];
return _methodQueue;
}
}
Expand Down

0 comments on commit 8a88f0a

Please sign in to comment.