Skip to content

Commit

Permalink
Guard against nil methodQueue in RCTBlobManager
Browse files Browse the repository at this point in the history
Summary:
## Description
In T63516227, we're seeing a crash that occurs because `networking.methodQueue` is `nil`, and we try to `dispatch_async` to it.

## Hypothesis
This looks like a problem with NativeModule cleanup:
1. Some JS executes a call to `RCTBlobManager.addNetworkingHander`. This schedules an async method call on the `RCTBlobManager` method queue.
2. In `RCTCxxBridge invalidate`, on the JS thread, we loop through all the `RCTModuleData`s, and invalidate them. This invalidates our NativeModules (perhaps not all but only `RCTNetworking`).
3. The `RCTBlobManager.addNetworkingHander` method call finally executes, with `RCTNetworking`'s methodQueue set to nil, which throws this error.

Changelog:
[iOS][Fixed] - Fix RCTBlobManager cleanup crash

Reviewed By: PeteTheHeat

Differential Revision: D20498096

fbshipit-source-id: d2d60984637ddf883278289258aa9b2ae81bb172
  • Loading branch information
RSNara authored and facebook-github-bot committed Mar 17, 2020
1 parent 48fe460 commit 91c5ff4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/Blob/RCTBlobManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ - (void)remove:(NSString *)blobId
{
RCTNetworking *const networking = _bridge ? _bridge.networking : [_turboModuleLookupDelegate moduleForName:"RCTNetworking"];

// TODO(T63516227): Why can methodQueue be nil here?
// We don't want to do anything when methodQueue is nil.
if (!networking.methodQueue) {
return;
}

dispatch_async(networking.methodQueue, ^{
[networking addRequestHandler:self];
[networking addResponseHandler:self];
Expand Down

0 comments on commit 91c5ff4

Please sign in to comment.