From 6d7f2b02fe6ce3c749c7a3b302e330ff1a9a690c Mon Sep 17 00:00:00 2001 From: Clement Polet Date: Thu, 26 Oct 2017 13:33:23 -0700 Subject: [PATCH 1/2] Run user confirmation handler from main thread --- .../MobileCenterCrashes/MSCrashes.mm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/MobileCenterCrashes/MobileCenterCrashes/MSCrashes.mm b/MobileCenterCrashes/MobileCenterCrashes/MSCrashes.mm index 87dea29d12..efd324df41 100644 --- a/MobileCenterCrashes/MobileCenterCrashes/MSCrashes.mm +++ b/MobileCenterCrashes/MobileCenterCrashes/MSCrashes.mm @@ -1073,7 +1073,7 @@ - (BOOL)sendCrashReportsOrAwaitUserConfirmation { @"The flag for user confirmation is set to MSUserConfirmationAlways, continue sending logs"); [self notifyWithUserConfirmation:MSUserConfirmationSend]; return alwaysSend; - } else if (self.automaticProcessing && !(self.userConfirmationHandler && self.userConfirmationHandler(self.unprocessedReports))) { + } else if (self.automaticProcessing && !(self.userConfirmationHandler && [self userPromptedForConfirmation])) { // User confirmation handler doesn't exist or returned NO which means 'want to process'. MSLogDebug([MSCrashes logTag], @@ -1086,6 +1086,20 @@ - (BOOL)sendCrashReportsOrAwaitUserConfirmation { return alwaysSend; } +-(BOOL)userPromptedForConfirmation{ + + // User confirmation handler may contain UI so we have to run it in the main thread. + __block BOOL userPromptedForConfirmation; + if ([NSThread isMainThread]) { + userPromptedForConfirmation = self.userConfirmationHandler(self.unprocessedReports); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + userPromptedForConfirmation = self.userConfirmationHandler(self.unprocessedReports); + }); + } + return userPromptedForConfirmation; +} + // This is an instance method to make testing easier. - (BOOL)shouldAlwaysSend { NSNumber *flag = [MS_USER_DEFAULTS objectForKey:kMSUserConfirmationKey]; From 8b59ea3dd1e48ab54d551571f4d7abbb949c7dc5 Mon Sep 17 00:00:00 2001 From: Clement Polet Date: Thu, 26 Oct 2017 14:19:10 -0700 Subject: [PATCH 2/2] Fix header issues on wrapper SDK files --- .../project.pbxproj | 28 ++++++++++++------- .../MobileCenterCrashes/MobileCenterCrashes.h | 3 ++ .../MSCrashHandlerSetupDelegate.h | 0 .../MSWrapperCrashesHelper.h | 0 .../MSWrapperCrashesHelper.m | 0 5 files changed, 21 insertions(+), 10 deletions(-) rename MobileCenterCrashes/MobileCenterCrashes/{Internals => WrapperSDKUtilities}/MSCrashHandlerSetupDelegate.h (100%) rename MobileCenterCrashes/MobileCenterCrashes/{Internals => WrapperSDKUtilities}/MSWrapperCrashesHelper.h (100%) rename MobileCenterCrashes/MobileCenterCrashes/{Internals => WrapperSDKUtilities}/MSWrapperCrashesHelper.m (100%) diff --git a/MobileCenterCrashes/MobileCenterCrashes.xcodeproj/project.pbxproj b/MobileCenterCrashes/MobileCenterCrashes.xcodeproj/project.pbxproj index b3acce310b..7e14d75542 100644 --- a/MobileCenterCrashes/MobileCenterCrashes.xcodeproj/project.pbxproj +++ b/MobileCenterCrashes/MobileCenterCrashes.xcodeproj/project.pbxproj @@ -229,11 +229,11 @@ 04CC3B811F35284D00F7D92A /* MSWrapperExceptionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 353FD1601F29209000E1DF78 /* MSWrapperExceptionInternal.h */; }; 04CC3B821F35284E00F7D92A /* MSWrapperExceptionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 353FD1601F29209000E1DF78 /* MSWrapperExceptionInternal.h */; }; 04CC3B831F3528BD00F7D92A /* MSWrapperCrashesHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 04CC3B841F3528BE00F7D92A /* MSWrapperCrashesHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */; }; - 04CC3B851F3528BF00F7D92A /* MSWrapperCrashesHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */; }; + 04CC3B841F3528BE00F7D92A /* MSWrapperCrashesHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 04CC3B851F3528BF00F7D92A /* MSWrapperCrashesHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; 04CC3B861F3528C200F7D92A /* MSCrashHandlerSetupDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 04CC3B871F3528C300F7D92A /* MSCrashHandlerSetupDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */; }; - 04CC3B881F3528C400F7D92A /* MSCrashHandlerSetupDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */; }; + 04CC3B871F3528C300F7D92A /* MSCrashHandlerSetupDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 04CC3B881F3528C400F7D92A /* MSCrashHandlerSetupDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 04CC3B891F3528DA00F7D92A /* MSWrapperExceptionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 350B29F31F1E6F1D009B91CF /* MSWrapperExceptionTests.m */; }; 04CC3B8A1F3528E200F7D92A /* MSWrapperCrashesHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 352B1D6E1F27C36300684A7F /* MSWrapperCrashesHelperTests.m */; }; 04EBBEB21F01C0C90006B8AE /* MSErrorReport.m in Sources */ = {isa = PBXBuildFile; fileRef = B2F120DF1D657CF10060DED7 /* MSErrorReport.m */; }; @@ -839,17 +839,24 @@ name = iOS; sourceTree = ""; }; - 350B29E91F192A5C009B91CF /* WrapperSdkUtilities */ = { + 350B29E91F192A5C009B91CF /* WrapperSDKUtilities */ = { isa = PBXGroup; children = ( - 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */, - 350B29F11F1D67EE009B91CF /* MSWrapperCrashesHelper.m */, - 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */, 35B7D8791DE4CB6D00C846CD /* MSWrapperExceptionManagerInternal.h */, 35D504CE1DDD140500D58B40 /* MSWrapperExceptionManager.m */, 35D504CD1DDD140500D58B40 /* MSWrapperExceptionManager.h */, ); - name = WrapperSdkUtilities; + name = WrapperSDKUtilities; + sourceTree = ""; + }; + 380609CC1FA2848D00211C22 /* WrapperSDKUtilities */ = { + isa = PBXGroup; + children = ( + 350B29E71F192554009B91CF /* MSCrashHandlerSetupDelegate.h */, + 350B29E81F1929A1009B91CF /* MSWrapperCrashesHelper.h */, + 350B29F11F1D67EE009B91CF /* MSWrapperCrashesHelper.m */, + ); + path = WrapperSDKUtilities; sourceTree = ""; }; 6E04012A1D1C98690051BCFA = { @@ -888,6 +895,7 @@ 6E0401501D1C9A4F0051BCFA /* MSCrashes.mm */, B2DCB1351DAC03C400120F87 /* MSCrashesDelegate.h */, B2F120DE1D657CF10060DED7 /* MSErrorReport.h */, + 380609CC1FA2848D00211C22 /* WrapperSDKUtilities */, 6E0401511D1C9A4F0051BCFA /* Internals */, D38024001E7125F500466558 /* Model */, 6E37297E1D1DE93800F1E4AE /* Support */, @@ -898,7 +906,7 @@ 6E0401511D1C9A4F0051BCFA /* Internals */ = { isa = PBXGroup; children = ( - 350B29E91F192A5C009B91CF /* WrapperSdkUtilities */, + 350B29E91F192A5C009B91CF /* WrapperSDKUtilities */, 3515F9C01DD63EC9005E6E27 /* MSCrashesInternal.h */, 6E73FE711D4059E7008CDC15 /* MSCrashesCXXExceptionWrapperException.h */, 6E73FE721D4059E7008CDC15 /* MSCrashesCXXExceptionWrapperException.m */, diff --git a/MobileCenterCrashes/MobileCenterCrashes/MobileCenterCrashes.h b/MobileCenterCrashes/MobileCenterCrashes/MobileCenterCrashes.h index a6f3fe39a9..cba53ef950 100644 --- a/MobileCenterCrashes/MobileCenterCrashes/MobileCenterCrashes.h +++ b/MobileCenterCrashes/MobileCenterCrashes/MobileCenterCrashes.h @@ -2,5 +2,8 @@ #import "MSCrashes.h" #import "MSCrashesDelegate.h" +#import "MSCrashHandlerSetupDelegate.h" #import "MSErrorAttachmentLog.h" #import "MSErrorAttachmentLog+Utility.h" +#import "MSWrapperCrashesHelper.h" + diff --git a/MobileCenterCrashes/MobileCenterCrashes/Internals/MSCrashHandlerSetupDelegate.h b/MobileCenterCrashes/MobileCenterCrashes/WrapperSDKUtilities/MSCrashHandlerSetupDelegate.h similarity index 100% rename from MobileCenterCrashes/MobileCenterCrashes/Internals/MSCrashHandlerSetupDelegate.h rename to MobileCenterCrashes/MobileCenterCrashes/WrapperSDKUtilities/MSCrashHandlerSetupDelegate.h diff --git a/MobileCenterCrashes/MobileCenterCrashes/Internals/MSWrapperCrashesHelper.h b/MobileCenterCrashes/MobileCenterCrashes/WrapperSDKUtilities/MSWrapperCrashesHelper.h similarity index 100% rename from MobileCenterCrashes/MobileCenterCrashes/Internals/MSWrapperCrashesHelper.h rename to MobileCenterCrashes/MobileCenterCrashes/WrapperSDKUtilities/MSWrapperCrashesHelper.h diff --git a/MobileCenterCrashes/MobileCenterCrashes/Internals/MSWrapperCrashesHelper.m b/MobileCenterCrashes/MobileCenterCrashes/WrapperSDKUtilities/MSWrapperCrashesHelper.m similarity index 100% rename from MobileCenterCrashes/MobileCenterCrashes/Internals/MSWrapperCrashesHelper.m rename to MobileCenterCrashes/MobileCenterCrashes/WrapperSDKUtilities/MSWrapperCrashesHelper.m