Skip to content

Commit 385bfdc

Browse files
paulb777ncooke3
andauthored
[Crashlytics] Remove mach_absolute_time usages (#12664)
Co-authored-by: Nick Cooke <[email protected]>
1 parent 88d2b5c commit 385bfdc

File tree

10 files changed

+19
-104
lines changed

10 files changed

+19
-104
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
22
- [fixed] Fix `'FirebaseCrashlytics/FirebaseCrashlytics-Swift.h' file not found`
33
errors (#12611).
4+
- [changed] Remove usages of `mach_absolute_time` to reduce required reason impact.
45

56
# 10.23.0
67
- [added] Updated upload-symbols to 13.7 with VisionPro build phase support. (#12306)

Crashlytics/Crashlytics/Components/FIRCLSProcess.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h"
1717
#include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h"
1818
#include "Crashlytics/Crashlytics/Components/FIRCLSGlobals.h"
19-
#include "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h"
2019
#include "Crashlytics/Crashlytics/Helpers/FIRCLSThreadState.h"
2120
#include "Crashlytics/Crashlytics/Unwind/FIRCLSUnwind.h"
2221
#include "Crashlytics/Crashlytics/Helpers/FIRCLSUtility.h"

Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#import "Crashlytics/Crashlytics/Public/FirebaseCrashlytics/FIRCrashlytics.h"
1818

19-
#import "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h"
20-
2119
@class FBLPromise<T>;
2220
@class FIRCLSExistingReportManager;
2321
@class FIRCLSAnalyticsManager;
@@ -35,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
3533
- (instancetype)init NS_UNAVAILABLE;
3634
+ (instancetype)new NS_UNAVAILABLE;
3735

38-
- (FBLPromise<NSNumber *> *)startWithProfilingMark:(FIRCLSProfileMark)mark;
36+
- (FBLPromise<NSNumber *> *)startWithProfiling;
3937

4038
- (FBLPromise<FIRCrashlyticsReport *> *)checkForUnsentReports;
4139
- (FBLPromise *)sendUnsentReports;

Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ - (FBLPromise *)deleteUnsentReports {
268268
return _unsentReportsHandled;
269269
}
270270

271-
- (FBLPromise<NSNumber *> *)startWithProfilingMark:(FIRCLSProfileMark)mark {
271+
- (FBLPromise<NSNumber *> *)startWithProfiling {
272272
NSString *executionIdentifier = self.executionIDModel.executionID;
273273

274274
// This needs to be called before the new report is created for
@@ -294,7 +294,7 @@ - (FBLPromise *)deleteUnsentReports {
294294
FIRCLSErrorLog(@"Unable to setup a new report");
295295
}
296296

297-
if (![self startCrashReporterWithProfilingMark:mark report:report]) {
297+
if (![self startCrashReporterWithProfilingReport:report]) {
298298
FIRCLSErrorLog(@"Unable to start crash reporter");
299299
report = nil;
300300
}
@@ -361,11 +361,9 @@ - (FBLPromise *)deleteUnsentReports {
361361
}
362362

363363
if (report != nil) {
364-
// capture the start-up time here, but record it asynchronously
365-
double endMark = FIRCLSProfileEnd(mark);
366-
364+
// empty for disabled start-up time
367365
dispatch_async(FIRCLSGetLoggingQueue(), ^{
368-
FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSStartTimeKey, [@(endMark) description]);
366+
FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSStartTimeKey, @"");
369367
});
370368
}
371369

@@ -414,8 +412,7 @@ - (void)beginReportUploadsWithToken:(FIRCLSDataCollectionToken *)token
414412
}
415413
}
416414

417-
- (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark
418-
report:(FIRCLSInternalReport *)report {
415+
- (BOOL)startCrashReporterWithProfilingReport:(FIRCLSInternalReport *)report {
419416
if (!report) {
420417
return NO;
421418
}
@@ -430,12 +427,12 @@ - (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark
430427

431428
[self.analyticsManager registerAnalyticsListener];
432429

433-
[self crashReportingSetupCompleted:mark];
430+
[self crashReportingSetupCompleted];
434431

435432
return YES;
436433
}
437434

438-
- (void)crashReportingSetupCompleted:(FIRCLSProfileMark)mark {
435+
- (void)crashReportingSetupCompleted {
439436
// check our handlers
440437
FIRCLSDispatchAfter(2.0, dispatch_get_main_queue(), ^{
441438
FIRCLSExceptionCheckHandlers((__bridge void *)(self));
@@ -447,12 +444,12 @@ - (void)crashReportingSetupCompleted:(FIRCLSProfileMark)mark {
447444
#endif
448445
});
449446

450-
// remove the launch failure marker and record the startup time
447+
// remove the launch failure marker and records and empty string since
448+
// we're avoiding mach_absolute_time calls.
451449
dispatch_async(dispatch_get_main_queue(), ^{
452450
[self.launchMarker removeLaunchFailureMarker];
453451
dispatch_async(FIRCLSGetLoggingQueue(), ^{
454-
FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSFirstRunloopTurnTimeKey,
455-
[@(FIRCLSProfileEnd(mark)) description]);
452+
FIRCLSUserLoggingWriteInternalKeyValue(FIRCLSFirstRunloopTurnTimeKey, @"");
456453
});
457454
});
458455
}

Crashlytics/Crashlytics/FIRCrashlytics.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#import "Crashlytics/Crashlytics/FIRCLSUserDefaults/FIRCLSUserDefaults.h"
3030
#include "Crashlytics/Crashlytics/Handlers/FIRCLSException.h"
3131
#import "Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h"
32-
#include "Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h"
3332
#include "Crashlytics/Crashlytics/Helpers/FIRCLSUtility.h"
3433
#import "Crashlytics/Crashlytics/Models/FIRCLSExecutionIdentifierModel.h"
3534
#import "Crashlytics/Crashlytics/Models/FIRCLSFileManager.h"
@@ -133,8 +132,6 @@ - (instancetype)initWithApp:(FIRApp *)app
133132
return nil;
134133
}
135134

136-
FIRCLSProfileMark mark = FIRCLSProfilingStart();
137-
138135
NSLog(@"[Firebase/Crashlytics] Version %@", FIRCLSSDKVersion());
139136

140137
FIRCLSDeveloperLog("Crashlytics", @"Running on %@, %@ (%@)", FIRCLSHostModelInfo(),
@@ -200,7 +197,7 @@ - (instancetype)initWithApp:(FIRApp *)app
200197
});
201198
}
202199

203-
[[[_reportManager startWithProfilingMark:mark] then:^id _Nullable(NSNumber *_Nullable value) {
200+
[[[_reportManager startWithProfiling] then:^id _Nullable(NSNumber *_Nullable value) {
204201
if (![value boolValue]) {
205202
FIRCLSErrorLog(@"Crash reporting could not be initialized");
206203
}

Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.c

Lines changed: 0 additions & 47 deletions
This file was deleted.

Crashlytics/Crashlytics/Helpers/FIRCLSProfiling.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

Crashlytics/UnitTests/FIRCLSReportManagerTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ - (NSArray *)uploadReportArray {
200200

201201
#pragma mark - File/Directory Handling
202202
- (void)testCreatesNewReportOnStart {
203-
FBLPromise<NSNumber *> *promise = [self->_reportManager startWithProfilingMark:0];
203+
FBLPromise<NSNumber *> *promise = [self->_reportManager startWithProfiling];
204204

205205
XCTestExpectation *expectation =
206206
[[XCTestExpectation alloc] initWithDescription:@"waiting on promise"];
@@ -244,7 +244,7 @@ - (void)startReportManager {
244244

245245
- (FBLPromise<NSNumber *> *)startReportManagerWithDataCollectionEnabled:(BOOL)enabled {
246246
[self.dataArbiter setCrashlyticsCollectionEnabled:enabled];
247-
return [self.reportManager startWithProfilingMark:0];
247+
return [self.reportManager startWithProfiling];
248248
}
249249

250250
- (void)processReports:(BOOL)send andExpectReports:(BOOL)reportsExpected {

Crashlytics/UnitTests/FIRCLSReportUploaderTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ - (void)testUrgentUploadPackagedReportWithPath {
213213
[self runUploadPackagedReportWithUrgency:YES];
214214
}
215215

216-
- (void)testUrgentWaitUntillUpload {
216+
- (void)testUrgentWaitUntilUpload {
217217
self.mockDataTransport.async = YES;
218218

219219
[self runUploadPackagedReportWithUrgency:YES];
220220

221221
XCTAssertNotNil(self.mockDataTransport.sendDataEvent_event);
222222
}
223223

224-
- (void)testUrgentWaitUntillUploadWithError {
224+
- (void)testUrgentWaitUntilUploadWithError {
225225
self.mockDataTransport.async = YES;
226226
self.mockDataTransport.sendDataEvent_error = [[NSError alloc] initWithDomain:@"domain"
227227
code:1
@@ -234,7 +234,7 @@ - (void)testUrgentWaitUntillUploadWithError {
234234
XCTAssertNotNil(self.mockDataTransport.sendDataEvent_event);
235235
}
236236

237-
- (void)testUrgentWaitUntillUploadWithWritingError {
237+
- (void)testUrgentWaitUntilUploadWithWritingError {
238238
self.mockDataTransport.async = YES;
239239
self.mockDataTransport.sendDataEvent_wasWritten = NO;
240240

Crashlytics/UnitTests/Mocks/FIRCLSMockReportManager.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
@implementation FIRCLSMockReportManager
2424

25-
- (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark
26-
report:(FIRCLSInternalReport *)report {
25+
- (BOOL)startCrashReporterWithProfilingReport:(FIRCLSInternalReport *)report {
2726
NSLog(@"Crash Reporting system disabled for testing");
2827

2928
return YES;

0 commit comments

Comments
 (0)