Skip to content

Commit d098e5a

Browse files
FIRApp optimize config time (#6919)
* FIRApp optimize config time * Changelog * Changelog update * update version
1 parent 90d3600 commit d098e5a

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

FirebaseCore/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Firebase 7.2.0
2+
- [fixed] Reduced `FirebaseApp.configure()` and `+[FIRApp registerInternalLibrary:withName:]` impact on app launch time. (#6902)
3+
14
# Firebase 7.0.0
25
- [changed] Update minimum iOS version to iOS 10 except for Analytics which is now iOS 9. (#4847)
36
- [changed] Update minimum macOS version to 10.12.

FirebaseCore/Sources/FIRApp.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ - (BOOL)configureCore {
348348
return NO;
349349
}
350350

351-
[self logCoreTelemetryIfEnabled];
352-
353351
#if TARGET_OS_IOS
354352
// Initialize the Analytics once there is a valid options under default app. Analytics should
355353
// always initialize first by itself before the other SDKs.
@@ -853,7 +851,9 @@ - (void)appDidBecomeActive:(NSNotification *)notification {
853851

854852
- (void)logCoreTelemetryIfEnabled {
855853
if ([self isDataCollectionDefaultEnabled]) {
856-
[FIRCoreDiagnosticsConnector logCoreTelemetryWithOptions:_options];
854+
dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{
855+
[FIRCoreDiagnosticsConnector logCoreTelemetryWithOptions:[self options]];
856+
});
857857
}
858858
}
859859

FirebaseCore/Sources/FIRFirebaseUserAgent.m

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,37 @@
2121
@interface FIRFirebaseUserAgent ()
2222

2323
@property(nonatomic, readonly) NSMutableDictionary<NSString *, NSString *> *valuesByComponent;
24+
@property(nonatomic, readonly) NSDictionary<NSString *, NSString *> *environmentComponents;
2425
@property(nonatomic, readonly) NSString *firebaseUserAgent;
2526

2627
@end
2728

2829
@implementation FIRFirebaseUserAgent
2930

3031
@synthesize firebaseUserAgent = _firebaseUserAgent;
32+
@synthesize environmentComponents = _environmentComponents;
3133

3234
- (instancetype)init {
3335
self = [super init];
3436
if (self) {
35-
_valuesByComponent = [[[self class] environmentComponents] mutableCopy];
37+
_valuesByComponent = [[NSMutableDictionary alloc] init];
3638
}
3739
return self;
3840
}
3941

4042
- (NSString *)firebaseUserAgent {
4143
@synchronized(self) {
4244
if (_firebaseUserAgent == nil) {
45+
NSMutableDictionary<NSString *, NSString *> *allComponents =
46+
[self.valuesByComponent mutableCopy];
47+
[allComponents setValuesForKeysWithDictionary:self.environmentComponents];
48+
4349
__block NSMutableArray<NSString *> *components =
4450
[[NSMutableArray<NSString *> alloc] initWithCapacity:self.valuesByComponent.count];
45-
[self.valuesByComponent
46-
enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull name, NSString *_Nonnull value,
47-
BOOL *_Nonnull stop) {
48-
[components addObject:[NSString stringWithFormat:@"%@/%@", name, value]];
49-
}];
51+
[allComponents enumerateKeysAndObjectsUsingBlock:^(
52+
NSString *_Nonnull name, NSString *_Nonnull value, BOOL *_Nonnull stop) {
53+
[components addObject:[NSString stringWithFormat:@"%@/%@", name, value]];
54+
}];
5055
[components sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
5156
_firebaseUserAgent = [components componentsJoinedByString:@" "];
5257
}
@@ -73,6 +78,13 @@ - (void)reset {
7378

7479
#pragma mark - Environment components
7580

81+
- (NSDictionary<NSString *, NSString *> *)environmentComponents {
82+
if (_environmentComponents == nil) {
83+
_environmentComponents = [[self class] environmentComponents];
84+
}
85+
return _environmentComponents;
86+
}
87+
7688
+ (NSDictionary<NSString *, NSString *> *)environmentComponents {
7789
NSMutableDictionary<NSString *, NSString *> *components = [NSMutableDictionary dictionary];
7890

FirebaseCore/Tests/Unit/FIRAppTest.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,20 +910,14 @@ - (void)testFirebaseUserAgent_IsFromAppStore {
910910

911911
#pragma mark - Core Diagnostics
912912

913-
- (void)testCoreDiagnosticsLoggedWhenFIRAppIsConfigured {
914-
[self expectCoreDiagnosticsDataLogWithOptions:[self appOptions]];
915-
[self createConfiguredAppWithName:NSStringFromSelector(_cmd)];
916-
OCMVerifyAll(self.mockCoreDiagnosticsConnector);
917-
}
918-
919913
- (void)testCoreDiagnosticsLoggedWhenAppDidBecomeActive {
920914
FIRApp *app = [self createConfiguredAppWithName:NSStringFromSelector(_cmd)];
921915
[self expectCoreDiagnosticsDataLogWithOptions:app.options];
922916

923917
[self.notificationCenter postNotificationName:[self appDidBecomeActiveNotificationName]
924918
object:nil];
925919

926-
OCMVerifyAll(self.mockCoreDiagnosticsConnector);
920+
OCMVerifyAllWithDelay(self.mockCoreDiagnosticsConnector, 0.5);
927921
}
928922

929923
#pragma mark - private

0 commit comments

Comments
 (0)