diff --git a/Crashlytics/CHANGELOG.md b/Crashlytics/CHANGELOG.md index b1f6409bb00..b5b068a624e 100644 --- a/Crashlytics/CHANGELOG.md +++ b/Crashlytics/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased - [fixed] Fix `'FirebaseCrashlytics/FirebaseCrashlytics-Swift.h' file not found` errors (#12611). +- [changed] Remove usages of `mach_absolute_time` to reduce required reason impact. # 10.23.0 - [added] Updated upload-symbols to 13.7 with VisionPro build phase support. (#12306) diff --git a/Crashlytics/Crashlytics/Components/FIRCLSProcess.c b/Crashlytics/Crashlytics/Components/FIRCLSProcess.c index b816506fc75..89743627fb8 100644 --- a/Crashlytics/Crashlytics/Components/FIRCLSProcess.c +++ b/Crashlytics/Crashlytics/Components/FIRCLSProcess.c @@ -16,7 +16,6 @@ #include "Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h" #include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h" #include "Crashlytics/Crashlytics/Components/FIRCLSGlobals.h" -#include "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h" #include "Crashlytics/Crashlytics/Helpers/FIRCLSThreadState.h" #include "Crashlytics/Crashlytics/Unwind/FIRCLSUnwind.h" #include "Crashlytics/Crashlytics/Helpers/FIRCLSUtility.h" diff --git a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.h b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.h index 3f5c398426a..1b17edb47e5 100644 --- a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.h +++ b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.h @@ -16,8 +16,6 @@ #import "Crashlytics/Crashlytics/Public/FirebaseCrashlytics/FIRCrashlytics.h" -#import "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h" - @class FBLPromise; @class FIRCLSExistingReportManager; @class FIRCLSAnalyticsManager; @@ -35,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; -- (FBLPromise *)startWithProfilingMark:(FIRCLSProfileMark)mark; +- (FBLPromise *)startWithProfiling; - (FBLPromise *)checkForUnsentReports; - (FBLPromise *)sendUnsentReports; diff --git a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m index 55f5bcb7d1d..fc7a5637412 100644 --- a/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m +++ b/Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m @@ -268,7 +268,7 @@ - (FBLPromise *)deleteUnsentReports { return _unsentReportsHandled; } -- (FBLPromise *)startWithProfilingMark:(FIRCLSProfileMark)mark { +- (FBLPromise *)startWithProfiling { NSString *executionIdentifier = self.executionIDModel.executionID; // This needs to be called before the new report is created for @@ -294,7 +294,7 @@ - (FBLPromise *)deleteUnsentReports { FIRCLSErrorLog(@"Unable to setup a new report"); } - if (![self startCrashReporterWithProfilingMark:mark report:report]) { + if (![self startCrashReporterWithProfilingReport:report]) { FIRCLSErrorLog(@"Unable to start crash reporter"); report = nil; } @@ -361,11 +361,9 @@ - (FBLPromise *)deleteUnsentReports { } if (report != nil) { - // capture the start-up time here, but record it asynchronously - double endMark = FIRCLSProfileEnd(mark); - + // empty for disabled start-up time dispatch_async(FIRCLSGetLoggingQueue(), ^{ - FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSStartTimeKey, [@(endMark) description]); + FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSStartTimeKey, @""); }); } @@ -414,8 +412,7 @@ - (void)beginReportUploadsWithToken:(FIRCLSDataCollectionToken *)token } } -- (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark - report:(FIRCLSInternalReport *)report { +- (BOOL)startCrashReporterWithProfilingReport:(FIRCLSInternalReport *)report { if (!report) { return NO; } @@ -430,12 +427,12 @@ - (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark [self.analyticsManager registerAnalyticsListener]; - [self crashReportingSetupCompleted:mark]; + [self crashReportingSetupCompleted]; return YES; } -- (void)crashReportingSetupCompleted:(FIRCLSProfileMark)mark { +- (void)crashReportingSetupCompleted { // check our handlers FIRCLSDispatchAfter(2.0, dispatch_get_main_queue(), ^{ FIRCLSExceptionCheckHandlers((__bridge void *)(self)); @@ -447,12 +444,12 @@ - (void)crashReportingSetupCompleted:(FIRCLSProfileMark)mark { #endif }); - // remove the launch failure marker and record the startup time + // remove the launch failure marker and records and empty string since + // we're avoiding mach_absolute_time calls. dispatch_async(dispatch_get_main_queue(), ^{ [self.launchMarker removeLaunchFailureMarker]; dispatch_async(FIRCLSGetLoggingQueue(), ^{ - FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSFirstRunloopTurnTimeKey, - [@(FIRCLSProfileEnd(mark)) description]); + FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSFirstRunloopTurnTimeKey, @""); }); }); } diff --git a/Crashlytics/Crashlytics/FIRCrashlytics.m b/Crashlytics/Crashlytics/FIRCrashlytics.m index 9caae970a97..13906bb38ed 100644 --- a/Crashlytics/Crashlytics/FIRCrashlytics.m +++ b/Crashlytics/Crashlytics/FIRCrashlytics.m @@ -29,7 +29,6 @@ #import "Crashlytics/Crashlytics/FIRCLSUserDefaults/FIRCLSUserDefaults.h" #include "Crashlytics/Crashlytics/Handlers/FIRCLSException.h" #import "Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h" -#include "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h" #include "Crashlytics/Crashlytics/Helpers/FIRCLSUtility.h" #import "Crashlytics/Crashlytics/Models/FIRCLSExecutionIdentifierModel.h" #import "Crashlytics/Crashlytics/Models/FIRCLSFileManager.h" @@ -133,8 +132,6 @@ - (instancetype)initWithApp:(FIRApp *)app return nil; } - FIRCLSProfileMark mark = FIRCLSProfilingStart(); - NSLog(@"[Firebase/Crashlytics] Version %@", FIRCLSSDKVersion()); FIRCLSDeveloperLog("Crashlytics", @"Running on %@, %@ (%@)", FIRCLSHostModelInfo(), @@ -200,7 +197,7 @@ - (instancetype)initWithApp:(FIRApp *)app }); } - [[[_reportManager startWithProfilingMark:mark] then:^id _Nullable(NSNumber *_Nullable value) { + [[[_reportManager startWithProfiling] then:^id _Nullable(NSNumber *_Nullable value) { if (![value boolValue]) { FIRCLSErrorLog(@"Crash reporting could not be initialized"); } diff --git a/Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.c b/Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.c deleted file mode 100644 index 2c705187705..00000000000 --- a/Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.c +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2019 Google -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h" - -#include -#include - -FIRCLSProfileMark FIRCLSProfilingStart(void) { - return mach_absolute_time(); -} - -double FIRCLSProfileEnd(FIRCLSProfileMark mark) { - uint64_t duration = mach_absolute_time() - mark; - - mach_timebase_info_data_t info; - mach_timebase_info(&info); - - if (info.denom == 0) { - return 0.0; - } - - // Convert to nanoseconds - duration *= info.numer; - duration /= info.denom; - - return (double)duration / (double)NSEC_PER_MSEC; // return time in milliseconds -} - -void FIRCLSProfileBlock(const char* label, void (^block)(void)) { - FIRCLSProfileMark mark = FIRCLSProfilingStart(); - - block(); - - fprintf(stderr, "[Profile] %s: %f ms\n", label, FIRCLSProfileEnd(mark)); -} diff --git a/Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h b/Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h deleted file mode 100644 index 5cc312f4e95..00000000000 --- a/Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 Google -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include - -typedef uint64_t FIRCLSProfileMark; - -__BEGIN_DECLS - -// high-resolution timing, returning the results in seconds -FIRCLSProfileMark FIRCLSProfilingStart(void); -double FIRCLSProfileEnd(FIRCLSProfileMark mark); - -void FIRCLSProfileBlock(const char* label, void (^block)(void)); - -__END_DECLS diff --git a/Crashlytics/UnitTests/FIRCLSReportManagerTests.m b/Crashlytics/UnitTests/FIRCLSReportManagerTests.m index f2723635733..11e270fb314 100644 --- a/Crashlytics/UnitTests/FIRCLSReportManagerTests.m +++ b/Crashlytics/UnitTests/FIRCLSReportManagerTests.m @@ -200,7 +200,7 @@ - (NSArray *)uploadReportArray { #pragma mark - File/Directory Handling - (void)testCreatesNewReportOnStart { - FBLPromise *promise = [self->_reportManager startWithProfilingMark:0]; + FBLPromise *promise = [self->_reportManager startWithProfiling]; XCTestExpectation *expectation = [[XCTestExpectation alloc] initWithDescription:@"waiting on promise"]; @@ -244,7 +244,7 @@ - (void)startReportManager { - (FBLPromise *)startReportManagerWithDataCollectionEnabled:(BOOL)enabled { [self.dataArbiter setCrashlyticsCollectionEnabled:enabled]; - return [self.reportManager startWithProfilingMark:0]; + return [self.reportManager startWithProfiling]; } - (void)processReports:(BOOL)send andExpectReports:(BOOL)reportsExpected { diff --git a/Crashlytics/UnitTests/FIRCLSReportUploaderTests.m b/Crashlytics/UnitTests/FIRCLSReportUploaderTests.m index 82c8e9033cc..4dbca18e44c 100644 --- a/Crashlytics/UnitTests/FIRCLSReportUploaderTests.m +++ b/Crashlytics/UnitTests/FIRCLSReportUploaderTests.m @@ -213,7 +213,7 @@ - (void)testUrgentUploadPackagedReportWithPath { [self runUploadPackagedReportWithUrgency:YES]; } -- (void)testUrgentWaitUntillUpload { +- (void)testUrgentWaitUntilUpload { self.mockDataTransport.async = YES; [self runUploadPackagedReportWithUrgency:YES]; @@ -221,7 +221,7 @@ - (void)testUrgentWaitUntillUpload { XCTAssertNotNil(self.mockDataTransport.sendDataEvent_event); } -- (void)testUrgentWaitUntillUploadWithError { +- (void)testUrgentWaitUntilUploadWithError { self.mockDataTransport.async = YES; self.mockDataTransport.sendDataEvent_error = [[NSError alloc] initWithDomain:@"domain" code:1 @@ -234,7 +234,7 @@ - (void)testUrgentWaitUntillUploadWithError { XCTAssertNotNil(self.mockDataTransport.sendDataEvent_event); } -- (void)testUrgentWaitUntillUploadWithWritingError { +- (void)testUrgentWaitUntilUploadWithWritingError { self.mockDataTransport.async = YES; self.mockDataTransport.sendDataEvent_wasWritten = NO; diff --git a/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m b/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m index 1ab43afba36..ff0dae7fe2a 100644 --- a/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m +++ b/Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m @@ -22,8 +22,7 @@ @implementation FIRCLSMockReportManager -- (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark - report:(FIRCLSInternalReport *)report { +- (BOOL)startCrashReporterWithProfilingReport:(FIRCLSInternalReport *)report { NSLog(@"Crash Reporting system disabled for testing"); return YES;