Skip to content

Commit ca6f7e6

Browse files
Fireperf: prewarm counters (#9283)
* hidden counters * changelog * lowercase
1 parent 9d20350 commit ca6f7e6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

FirebasePerformance/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
* [fixed] Potentially drop pre-warmed app start traces on iOS 15 and above (#9026). App start measurements are made only for cold app starts (without pre-warming).
3+
14
# Version 8.10.0
25
* Fix a crash related to FPRSessionDetails. (#8691)
36
* Fix heap-buffer overflow when encoding sessions. (#8849)

FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
NSString *const kFPRAppCounterNameTraceEventsRateLimited = @"_fstec";
4343
NSString *const kFPRAppCounterNameNetworkTraceEventsRateLimited = @"_fsntc";
4444
NSString *const kFPRAppCounterNameTraceNotStopped = @"_tsns";
45+
NSString *const kFPRAppCounterNameActivePrewarm = @"_fsapc";
46+
NSString *const kFPRAppCounterNameDoubleDispatch = @"_fsddc";
4547

4648
@interface FPRAppActivityTracker ()
4749

@@ -202,18 +204,25 @@ - (BOOL)isApplicationPreWarmed {
202204
return NO;
203205
}
204206

207+
BOOL isPrewarmed = NO;
208+
205209
NSDictionary<NSString *, NSString *> *environment = [NSProcessInfo processInfo].environment;
206210
BOOL activePrewarmFlagValue = [environment[@"ActivePrewarm"] boolValue];
207-
if ([self isActivePrewarmEnabled] && activePrewarmFlagValue == YES) {
208-
return YES;
211+
if (activePrewarmFlagValue == YES) {
212+
isPrewarmed = isPrewarmed || [self isActivePrewarmEnabled];
213+
[self.activeTrace incrementMetric:kFPRAppCounterNameActivePrewarm byInt:1];
214+
} else {
215+
[self.activeTrace incrementMetric:kFPRAppCounterNameActivePrewarm byInt:0];
209216
}
210217

211-
if ([self isDoubleDispatchEnabled] &&
212-
[doubleDispatchTime compare:applicationDidFinishLaunchTime] == NSOrderedAscending) {
213-
return YES;
218+
if ([doubleDispatchTime compare:applicationDidFinishLaunchTime] == NSOrderedAscending) {
219+
isPrewarmed = isPrewarmed || [self isDoubleDispatchEnabled];
220+
[self.activeTrace incrementMetric:kFPRAppCounterNameDoubleDispatch byInt:1];
221+
} else if (doubleDispatchTime) {
222+
[self.activeTrace incrementMetric:kFPRAppCounterNameDoubleDispatch byInt:0];
214223
}
215224

216-
return NO;
225+
return isPrewarmed;
217226
}
218227

219228
/**

0 commit comments

Comments
 (0)