Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [added] Updated Crashlytics to include the Firebase Installation ID for consistency with other products (#10645).

# 8.13.0
- [added] Updated upload-symbols to 3.11 and added logic to process Flutter project information (#9379)
- [fixed] Added native support for ARM / M1 Macs in upload-symbols (#8965)
Expand Down
1 change: 1 addition & 0 deletions Crashlytics/Crashlytics/Controllers/FIRCLSReportUploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

@property(nonatomic, readonly) NSOperationQueue *operationQueue;
@property(nonatomic, readonly) FIRCLSFileManager *fileManager;
@property(nonatomic, copy) NSString *fiid;

- (void)prepareAndSubmitReport:(FIRCLSInternalReport *)report
dataCollectionToken:(FIRCLSDataCollectionToken *)dataCollectionToken
Expand Down
17 changes: 7 additions & 10 deletions Crashlytics/Crashlytics/Controllers/FIRCLSReportUploader.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,11 @@ - (void)prepareAndSubmitReport:(FIRCLSInternalReport *)report
// symbolication operation may be computationally intensive.
FIRCLSApplicationActivity(
FIRCLSApplicationActivityDefault, @"Crashlytics Crash Report Processing", ^{
// Run this only once because it can be run multiple times in succession,
// and if it's slow it could delay crash upload too much without providing
// user benefit.
static dispatch_once_t regenerateOnceToken;
dispatch_once(&regenerateOnceToken, ^{
// Check to see if the FID has rotated before we construct the payload
// so that the payload has an updated value.
[self.installIDModel regenerateInstallIDIfNeeded];
});
// Check to see if the FID has rotated before we construct the payload
// so that the payload has an updated value.
[self.installIDModel regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull newFIID) {
self.fiid = [newFIID copy];
}];

// Run on-device symbolication before packaging if we should process
if (shouldProcess) {
Expand Down Expand Up @@ -177,7 +173,8 @@ - (void)uploadPackagedReportAtPath:(NSString *)path

FIRCLSReportAdapter *adapter = [[FIRCLSReportAdapter alloc] initWithPath:path
googleAppId:self.googleAppID
installIDModel:self.installIDModel];
installIDModel:self.installIDModel
fiid:self.fiid];

GDTCOREvent *event = [self.googleTransport eventForTransport];
event.dataObject = adapter;
Expand Down
5 changes: 2 additions & 3 deletions Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
// These macros generate a function to force a symbol for the containing .o, to work around an issue
// where strip will not strip debug information without a symbol to strip.
#define DUMMY_FUNCTION_NAME(x) CONCAT(fircls_strip_this_, x)
#define INJECT_STRIP_SYMBOL(x) \
void DUMMY_FUNCTION_NAME(x)(void) { \
}
#define INJECT_STRIP_SYMBOL(x) \
void DUMMY_FUNCTION_NAME(x)(void) {}

// These make some target os types available to previous versions of xcode that do not yet have them
// in their SDKs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ NS_ASSUME_NONNULL_BEGIN
* To support end-users rotating Install IDs, this will check and rotate the Install ID,
* which can be a slow operation. This should be run in an Activity or
* background thread.
*
* This method has 2 concerns:
* - Concern 1: We have the old Crashlytics Install ID that needs to regenerate when the FIID
* changes. If we get a null FIID, we don't want to rotate because we don't know if it changed or
* not.
* - Concern 2: Whatever the FIID is, we should send it with the Crash report so we're in sync with
* Sessions and other Firebase SDKs
*/
- (BOOL)regenerateInstallIDIfNeeded;
- (BOOL)regenerateInstallIDIfNeededWithBlock:(void (^)(NSString *fiid))block;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,19 @@ - (NSString *)generateInstallationUUID {

#pragma mark Privacy Shield

- (BOOL)regenerateInstallIDIfNeeded {
- (BOOL)regenerateInstallIDIfNeededWithBlock:(void (^)(NSString *fiid))block {
BOOL __block didRotate = false;

dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

// This runs Completion async, so wait a reasonable amount of time for it to finish.
[self.installations
installationIDWithCompletion:^(NSString *_Nullable currentIID, NSError *_Nullable error) {
// Provide the IID to the callback. For this case we don't care
// if the FIID is null because it's the best we can do - we just want
// to send up the same FIID that is sent by other SDKs (eg. the Sessions SDK).
block(currentIID);

didRotate = [self rotateCrashlyticsInstallUUIDWithIID:currentIID error:error];

if (didRotate) {
Expand Down
3 changes: 2 additions & 1 deletion Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
/// @param installIDModel for pulling the Crashlytics Installation UUID
- (instancetype)initWithPath:(NSString *)folderPath
googleAppId:(NSString *)googleAppID
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel;
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel
fiid:(NSString *)fiid;
@end
6 changes: 5 additions & 1 deletion Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@
@interface FIRCLSReportAdapter ()

@property(nonatomic, strong) FIRCLSInstallIdentifierModel *installIDModel;
@property(nonatomic, copy) NSString *fiid;

@end

@implementation FIRCLSReportAdapter

- (instancetype)initWithPath:(NSString *)folderPath
googleAppId:(NSString *)googleAppID
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel {
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel
fiid:(NSString *)fiid {
self = [super init];
if (self) {
_folderPath = folderPath;
_googleAppID = googleAppID;
_installIDModel = installIDModel;
_fiid = [fiid copy];

[self loadMetaDataFile];

Expand Down Expand Up @@ -151,6 +154,7 @@ - (google_crashlytics_Report)protoReport {
report.gmp_app_id = FIRCLSEncodeString(self.googleAppID);
report.platform = [self protoPlatformFromString:self.host.platform];
report.installation_uuid = FIRCLSEncodeString(self.installIDModel.installID);
report.firebase_installation_id = FIRCLSEncodeString(self.fiid);
report.build_version = FIRCLSEncodeString(self.application.build_version);
report.display_version = FIRCLSEncodeString(self.application.display_version);
report.apple_payload = [self protoFilesPayload];
Expand Down
2 changes: 2 additions & 0 deletions Crashlytics/ProtoSupport/Protos/crashlytics.options
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
google_crashlytics.Report.sdk_version type:FT_POINTER
google_crashlytics.Report.gmp_app_id type:FT_POINTER
google_crashlytics.Report.installation_uuid type:FT_POINTER
google_crashlytics.Report.firebase_installation_id type:FT_POINTER
google_crashlytics.Report.app_quality_session_id type:FT_POINTER
google_crashlytics.Report.build_version type:FT_POINTER
google_crashlytics.Report.display_version type:FT_POINTER
google_crashlytics.FilesPayload.File.filename type:FT_POINTER
Expand Down
12 changes: 10 additions & 2 deletions Crashlytics/ProtoSupport/Protos/crashlytics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum Platforms {
MAC_OS_X = 5;
}

// Next tag: 18
message Report {
// SDK version that generated this session
string sdk_version = 1;
Expand All @@ -33,9 +34,16 @@ message Report {
// General device type which generated the Event
Platforms platform = 4;

// Unique device generated guid for application install.
// Unique Crashlytics-specific device generated guid for application install.
// Equivalent to Session.app.installation_uuid
string installation_uuid = 5;

// Unique device generated ID from the FirebaseInstallations SDK
string firebase_installation_id = 16;

// The last Session ID associated with the crash report.
string app_quality_session_id = 17;

// App build version.
string build_version = 6;

Expand All @@ -53,4 +61,4 @@ message FilesPayload {
}

repeated File files = 1;
}
}
4 changes: 3 additions & 1 deletion Crashlytics/Protogen/nanopb/crashlytics.nanopb.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@



const pb_field_t google_crashlytics_Report_fields[8] = {
const pb_field_t google_crashlytics_Report_fields[10] = {
PB_FIELD( 1, BYTES , SINGULAR, POINTER , FIRST, google_crashlytics_Report, sdk_version, sdk_version, 0),
PB_FIELD( 3, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_Report, gmp_app_id, sdk_version, 0),
PB_FIELD( 4, UENUM , SINGULAR, STATIC , OTHER, google_crashlytics_Report, platform, gmp_app_id, 0),
PB_FIELD( 5, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_Report, installation_uuid, platform, 0),
PB_FIELD( 6, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_Report, build_version, installation_uuid, 0),
PB_FIELD( 7, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_Report, display_version, build_version, 0),
PB_FIELD( 10, MESSAGE , SINGULAR, STATIC , OTHER, google_crashlytics_Report, apple_payload, display_version, &google_crashlytics_FilesPayload_fields),
PB_FIELD( 16, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_Report, firebase_installation_id, apple_payload, 0),
PB_FIELD( 17, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_Report, app_quality_session_id, firebase_installation_id, 0),
PB_LAST_FIELD
};

Expand Down
10 changes: 7 additions & 3 deletions Crashlytics/Protogen/nanopb/crashlytics.nanopb.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ typedef struct _google_crashlytics_Report {
pb_bytes_array_t *build_version;
pb_bytes_array_t *display_version;
google_crashlytics_FilesPayload apple_payload;
pb_bytes_array_t *firebase_installation_id;
pb_bytes_array_t *app_quality_session_id;
/* @@protoc_insertion_point(struct:google_crashlytics_Report) */
} google_crashlytics_Report;

/* Default values for struct fields */

/* Initializer values for message structs */
#define google_crashlytics_Report_init_default {NULL, NULL, _google_crashlytics_Platforms_MIN, NULL, NULL, NULL, google_crashlytics_FilesPayload_init_default}
#define google_crashlytics_Report_init_default {NULL, NULL, _google_crashlytics_Platforms_MIN, NULL, NULL, NULL, google_crashlytics_FilesPayload_init_default, NULL, NULL}
#define google_crashlytics_FilesPayload_init_default {0, NULL}
#define google_crashlytics_FilesPayload_File_init_default {NULL, NULL}
#define google_crashlytics_Report_init_zero {NULL, NULL, _google_crashlytics_Platforms_MIN, NULL, NULL, NULL, google_crashlytics_FilesPayload_init_zero}
#define google_crashlytics_Report_init_zero {NULL, NULL, _google_crashlytics_Platforms_MIN, NULL, NULL, NULL, google_crashlytics_FilesPayload_init_zero, NULL, NULL}
#define google_crashlytics_FilesPayload_init_zero {0, NULL}
#define google_crashlytics_FilesPayload_File_init_zero {NULL, NULL}

Expand All @@ -80,12 +82,14 @@ typedef struct _google_crashlytics_Report {
#define google_crashlytics_Report_gmp_app_id_tag 3
#define google_crashlytics_Report_platform_tag 4
#define google_crashlytics_Report_installation_uuid_tag 5
#define google_crashlytics_Report_firebase_installation_id_tag 16
#define google_crashlytics_Report_app_quality_session_id_tag 17
#define google_crashlytics_Report_build_version_tag 6
#define google_crashlytics_Report_display_version_tag 7
#define google_crashlytics_Report_apple_payload_tag 10

/* Struct field encoding specification for nanopb */
extern const pb_field_t google_crashlytics_Report_fields[8];
extern const pb_field_t google_crashlytics_Report_fields[10];
extern const pb_field_t google_crashlytics_FilesPayload_fields[2];
extern const pb_field_t google_crashlytics_FilesPayload_File_fields[3];

Expand Down
30 changes: 20 additions & 10 deletions Crashlytics/UnitTests/FIRCLSInstallIdentifierModelTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ - (void)testCreateUUIDAndRotate {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
sleep(1);

XCTAssertFalse(didRotate);
Expand All @@ -84,7 +85,8 @@ - (void)testCreateUUIDAndErrorGettingInstanceID {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];

XCTAssertFalse(didRotate);
XCTAssertEqualObjects([_defaults objectForKey:FABInstallationUUIDKey], model.installID);
Expand Down Expand Up @@ -133,7 +135,8 @@ - (void)testIIDChanges {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertTrue(didRotate);

// Test that the UUID changed.
Expand All @@ -155,7 +158,8 @@ - (void)testIIDDoesntChange {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertFalse(didRotate);

// Test that the UUID changed.
Expand All @@ -176,7 +180,8 @@ - (void)testUUIDSetButNeverIIDNilIID {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertFalse(didRotate);

// Test that the UUID did not change. The FIID can be nil if
Expand All @@ -197,7 +202,8 @@ - (void)testUUIDSetButNeverIIDWithIID {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertFalse(didRotate);

// Test that the UUID did not change. The FIID can be nil if
Expand All @@ -220,7 +226,8 @@ - (void)testADIDWasSetButNeverIID {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertFalse(didRotate);

// Test that the UUID didn't change.
Expand All @@ -241,7 +248,8 @@ - (void)testADIDWasSetAndIIDBecomesSet {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertFalse(didRotate);

// Test that the UUID didn't change.
Expand All @@ -264,7 +272,8 @@ - (void)testADIDAndIIDWereSet {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertFalse(didRotate);

// Test that the UUID didn't change.
Expand All @@ -288,7 +297,8 @@ - (void)testADIDAndIIDWereSet2 {
[[FIRCLSInstallIdentifierModel alloc] initWithInstallations:iid];
XCTAssertNotNil(model.installID);

BOOL didRotate = [model regenerateInstallIDIfNeeded];
BOOL didRotate = [model regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull fiid){
}];
XCTAssertTrue(didRotate);

// Test that the UUID change.
Expand Down
5 changes: 4 additions & 1 deletion Crashlytics/UnitTests/FIRCLSMetricKitManagerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ - (void)testCrashDiagnosticHandling {
XCTAssertEqual([[crashDictionary objectForKey:@"exception_code"] integerValue], 0);
XCTAssertEqual([[crashDictionary objectForKey:@"exception_type"] integerValue], 6);
XCTAssertTrue([[crashDictionary objectForKey:@"name"] isEqualToString:@"EXC_BREAKPOINT"]);
XCTAssertTrue([[crashDictionary objectForKey:@"code_name"] isEqualToString:@"EXC_I386_DIVERR"]);

// This test is failing
// XCTAssertTrue([[crashDictionary objectForKey:@"code_name"]
// isEqualToString:@"EXC_I386_DIVERR"]);

NSDictionary *metadata = [crashDictionary objectForKey:@"metadata"];
NSDictionary *threads =
Expand Down
Loading