Merge pull request #1195 from EvanBacon/@evanbacon/thread-deadlock-bug

Fixed Deadlock
This commit is contained in:
Michael Diarmid 2018-06-08 23:48:23 +01:00 committed by GitHub
commit bee7c7851f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,7 @@
#import "RNFirebase.h" #import "RNFirebase.h"
#import "RNFirebaseUtil.h" #import "RNFirebaseUtil.h"
#import <FirebaseCore/FirebaseCore.h> #import <FirebaseCore/FirebaseCore.h>
#import <React/RCTUtils.h>
@implementation RNFirebase @implementation RNFirebase
RCT_EXPORT_MODULE(RNFirebase); RCT_EXPORT_MODULE(RNFirebase);
@ -28,7 +29,7 @@ RCT_EXPORT_METHOD(initializeApp:
callback: callback:
(RCTResponseSenderBlock) callback) { (RCTResponseSenderBlock) callback) {
dispatch_sync(dispatch_get_main_queue(), ^{ RCTUnsafeExecuteOnMainQueueSync(^{
FIRApp *existingApp = [RNFirebaseUtil getApp:appDisplayName]; FIRApp *existingApp = [RNFirebaseUtil getApp:appDisplayName];
if (!existingApp) { if (!existingApp) {

View File

@ -1,4 +1,5 @@
#import "RNFirebaseAnalytics.h" #import "RNFirebaseAnalytics.h"
#import <React/RCTUtils.h>
#if __has_include(<FirebaseAnalytics/FIRAnalytics.h>) #if __has_include(<FirebaseAnalytics/FIRAnalytics.h>)
#import <FirebaseAnalytics/FIRAnalytics.h> #import <FirebaseAnalytics/FIRAnalytics.h>
@ -16,7 +17,7 @@ RCT_EXPORT_METHOD(setAnalyticsCollectionEnabled:(BOOL) enabled) {
} }
RCT_EXPORT_METHOD(setCurrentScreen:(NSString *) screenName screenClass:(NSString *) screenClassOverriew) { RCT_EXPORT_METHOD(setCurrentScreen:(NSString *) screenName screenClass:(NSString *) screenClassOverriew) {
dispatch_sync(dispatch_get_main_queue(), ^{ RCTUnsafeExecuteOnMainQueueSync(^{
[FIRAnalytics setScreenName:screenName screenClass:screenClassOverriew]; [FIRAnalytics setScreenName:screenName screenClass:screenClassOverriew];
}); });
} }

View File

@ -7,6 +7,7 @@
#import <MobileCoreServices/MobileCoreServices.h> #import <MobileCoreServices/MobileCoreServices.h>
#import <Photos/Photos.h> #import <Photos/Photos.h>
#import <Firebase.h> #import <Firebase.h>
#import <React/RCTUtils.h>
@implementation RNFirebaseStorage @implementation RNFirebaseStorage
@ -120,7 +121,7 @@ RCT_EXPORT_METHOD(downloadFile:(NSString *) appDisplayName
NSURL *localFile = [NSURL fileURLWithPath:localPath]; NSURL *localFile = [NSURL fileURLWithPath:localPath];
__block FIRStorageDownloadTask *downloadTask; __block FIRStorageDownloadTask *downloadTask;
dispatch_sync(dispatch_get_main_queue(), ^{ RCTUnsafeExecuteOnMainQueueSync(^{
downloadTask = [fileRef writeToFile:localFile]; downloadTask = [fileRef writeToFile:localFile];
}); });
@ -298,7 +299,7 @@ RCT_EXPORT_METHOD(putFile:(NSString *) appDisplayName
- (void)uploadFile:(NSString *)appDisplayName url:(NSURL *)url firmetadata:(FIRStorageMetadata *)firmetadata path:(NSString *)path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject { - (void)uploadFile:(NSString *)appDisplayName url:(NSURL *)url firmetadata:(FIRStorageMetadata *)firmetadata path:(NSString *)path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
FIRStorageReference *fileRef = [self getReference:path appDisplayName:appDisplayName]; FIRStorageReference *fileRef = [self getReference:path appDisplayName:appDisplayName];
__block FIRStorageUploadTask *uploadTask; __block FIRStorageUploadTask *uploadTask;
dispatch_sync(dispatch_get_main_queue(), ^{ RCTUnsafeExecuteOnMainQueueSync(^{
uploadTask = [fileRef putFile:url metadata:firmetadata]; uploadTask = [fileRef putFile:url metadata:firmetadata];
}); });
[self addUploadObservers:appDisplayName uploadTask:uploadTask path:path resolver:resolve rejecter:reject]; [self addUploadObservers:appDisplayName uploadTask:uploadTask path:path resolver:resolve rejecter:reject];
@ -307,7 +308,7 @@ RCT_EXPORT_METHOD(putFile:(NSString *) appDisplayName
- (void)uploadData:(NSString *)appDisplayName data:(NSData *)data firmetadata:(FIRStorageMetadata *)firmetadata path:(NSString *)path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject { - (void)uploadData:(NSString *)appDisplayName data:(NSData *)data firmetadata:(FIRStorageMetadata *)firmetadata path:(NSString *)path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
FIRStorageReference *fileRef = [self getReference:path appDisplayName:appDisplayName]; FIRStorageReference *fileRef = [self getReference:path appDisplayName:appDisplayName];
__block FIRStorageUploadTask *uploadTask; __block FIRStorageUploadTask *uploadTask;
dispatch_sync(dispatch_get_main_queue(), ^{ RCTUnsafeExecuteOnMainQueueSync(^{
uploadTask = [fileRef putData:data metadata:firmetadata]; uploadTask = [fileRef putData:data metadata:firmetadata];
}); });
[self addUploadObservers:appDisplayName uploadTask:uploadTask path:path resolver:resolve rejecter:reject]; [self addUploadObservers:appDisplayName uploadTask:uploadTask path:path resolver:resolve rejecter:reject];