diff --git a/Crashlytics/CHANGELOG.md b/Crashlytics/CHANGELOG.md index 87932c1cce..01086dc158 100644 --- a/Crashlytics/CHANGELOG.md +++ b/Crashlytics/CHANGELOG.md @@ -8,8 +8,6 @@ when caching settings. (#16728) - [fixed] Fixed the app executable's minimum OS and SDK versions being recorded as `0.0.0` in report metadata for apps targeting iOS 12, macOS 10.14, tvOS 12, watchOS 5, or later. (#16810) -- [fixed] Moved Crashlytics settings check and fetch off the main thread during - startup when automatic data collection is enabled. (#16736) # 13.0.0 - [fixed] Safely validate memory reads when executing `DW_OP_deref_size` diff --git a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m index ed3f0d572e..1b6d4b909b 100644 --- a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m +++ b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m @@ -283,10 +283,10 @@ typedef NSNumber FIRCLSWrappedReportAction; FIRCLSDebugLog(@"Unsent reports will be uploaded at startup"); FIRCLSDataCollectionToken *dataCollectionToken = [FIRCLSDataCollectionToken validToken]; + [self beginSettingsWithToken:dataCollectionToken]; + promise = [reportProfilingPromise onQueue:_dispatchQueue then:^id _Nullable(id _Nullable value) { - [self beginSettingsWithToken:dataCollectionToken]; - [self beginReportUploadsWithToken:dataCollectionToken blockingSend:launchFailure]; diff --git a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager_Private.h b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager_Private.h index bc47615e86..5aa49dda9b 100644 --- a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager_Private.h +++ b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager_Private.h @@ -16,7 +16,6 @@ #import "Crashlytics/Crashlytics/Controllers/FIRCLSReportUploader.h" #import "Crashlytics/Crashlytics/Models/FIRCLSLaunchMarkerModel.h" -@class FIRCLSDataCollectionToken; @class FIRCLSInstallIdentifierModel; @interface FIRCLSReportManager () @@ -30,6 +29,4 @@ @property(nonatomic, strong) FIRCLSLaunchMarkerModel *launchMarker; -- (void)beginSettingsWithToken:(FIRCLSDataCollectionToken *)token; - @end diff --git a/Crashlytics/UnitTests/FIRCLSReportManagerTests.m b/Crashlytics/UnitTests/FIRCLSReportManagerTests.m index 33423e6c22..fcdfe7e91e 100644 --- a/Crashlytics/UnitTests/FIRCLSReportManagerTests.m +++ b/Crashlytics/UnitTests/FIRCLSReportManagerTests.m @@ -320,9 +320,6 @@ XCTAssertEqual([self.prepareAndSubmitReportArray count], 0); XCTAssertEqual([self.uploadReportArray count], 0); - - // Fetching settings is data collection, so it must wait for consent. - XCTAssertEqual(self.reportManager.beginSettingsCallCount, 0); } - (void)testExistingReportOnStart { @@ -376,10 +373,6 @@ XCTAssertEqual([self.prepareAndSubmitReportArray count], 1); XCTAssertEqualObjects(self.prepareAndSubmitReportArray[0][@"process"], @(YES)); XCTAssertEqualObjects(self.prepareAndSubmitReportArray[0][@"urgent"], @(NO)); - - // Enabling data collection should fetch settings once, off the main thread. - XCTAssertEqual(self.reportManager.beginSettingsCallCount, 1); - XCTAssertFalse(self.reportManager.beginSettingsCalledOnMainThread); } - (void)testExistingReportOnStartWithDataCollectionDisabledAndSend { @@ -409,10 +402,6 @@ XCTAssertEqualObjects(self.prepareAndSubmitReportArray[0][@"process"], @(YES)); XCTAssertEqualObjects(self.prepareAndSubmitReportArray[0][@"urgent"], @(NO)); - // Sending unsent reports should fetch settings once, off the main thread. - XCTAssertEqual(self.reportManager.beginSettingsCallCount, 1); - XCTAssertFalse(self.reportManager.beginSettingsCalledOnMainThread); - // Calling processReports again should not call the callback. // Technically, the behavior is unspecified. [self processReports:YES andExpectReports:NO]; @@ -442,9 +431,6 @@ // Should not call report manager for that report. XCTAssertEqual([self.prepareAndSubmitReportArray count], 0); - - // Deleting unsent reports should not fetch settings. - XCTAssertEqual(self.reportManager.beginSettingsCallCount, 0); } - (void)testExistingUrgentReportOnStart { @@ -644,11 +630,4 @@ XCTAssertEqualObjects(json, nil); } -- (void)testBeginSettingsRunsOffMainThreadWhenDataCollectionEnabled { - XCTAssertTrue([NSThread isMainThread]); - [self startReportManager]; - XCTAssertEqual(self.reportManager.beginSettingsCallCount, 1); - XCTAssertFalse(self.reportManager.beginSettingsCalledOnMainThread); -} - @end diff --git a/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.h b/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.h index 9d99edb46d..1024ebc656 100644 --- a/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.h +++ b/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.h @@ -19,9 +19,6 @@ NS_ASSUME_NONNULL_BEGIN @interface FIRCLSMockReportManager : FIRCLSReportManager -@property(nonatomic, assign) NSUInteger beginSettingsCallCount; -@property(nonatomic, assign) BOOL beginSettingsCalledOnMainThread; - @end NS_ASSUME_NONNULL_END diff --git a/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m b/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m index 4bce6205b2..e2c3fcc0d1 100644 --- a/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m +++ b/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m @@ -43,11 +43,4 @@ // This stuff does operations on the main thread, which we don't want during tests. } -- (void)beginSettingsWithToken:(FIRCLSDataCollectionToken *)token { - // Intentionally doesn't call super: the real method starts a settings download over the - // network, and its process-wide dispatch_once would leak state between tests. - self.beginSettingsCallCount += 1; - self.beginSettingsCalledOnMainThread = [NSThread isMainThread]; -} - @end