Skip to content

Commit f6e26aa

Browse files
committed
Backwards Compatibility: Use 59 Threshold on 60 fps devices
1 parent 248ee2a commit f6e26aa

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

FirebasePerformance/Sources/AppActivity/FPRScreenTraceTracker.m

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ - (instancetype)init {
128128

129129
// Initialize cached values with defaults. These will be updated by updateCachedSlowBudget,
130130
// but having defaults ensures reasonable behavior if initialization is delayed or fails.
131-
_cachedMaxFPS = 60; // Default to 60 FPS.
132-
_cachedSlowBudget = 1.0 / 60.0; // Default to 60 FPS budget.
131+
// Use 59 FPS as default to match legacy behavior (60 FPS devices use 59 FPS threshold).
132+
_cachedMaxFPS = 59;
133+
_cachedSlowBudget = 1.0 / 59.0;
133134

134135
// Initialize cached maxFPS and slowBudget on main thread.
135136
// UIScreen.maximumFramesPerSecond reflects device capability and can be up to 120 on ProMotion.
@@ -250,16 +251,19 @@ - (void)updateCachedSlowBudget {
250251
if (mainScreen) {
251252
_cachedMaxFPS = mainScreen.maximumFramesPerSecond;
252253
if (_cachedMaxFPS > 0) {
253-
_cachedSlowBudget = 1.0 / _cachedMaxFPS;
254+
// Preserve legacy behavior: 60 FPS devices historically used 59 FPS threshold
255+
// to avoid too many false positives for slow frames.
256+
NSInteger effectiveFPS = (_cachedMaxFPS == 60) ? 59 : _cachedMaxFPS;
257+
_cachedSlowBudget = 1.0 / effectiveFPS;
254258
} else {
255-
// Fallback to 60 FPS if maximumFramesPerSecond is unavailable or invalid.
256-
_cachedMaxFPS = 60;
257-
_cachedSlowBudget = 1.0 / 60.0;
259+
// Fallback to 59 FPS (matching legacy behavior) if maximumFramesPerSecond is unavailable or invalid.
260+
_cachedMaxFPS = 59;
261+
_cachedSlowBudget = 1.0 / 59.0;
258262
}
259263
} else {
260264
// Fallback if mainScreen is nil.
261-
_cachedMaxFPS = 60;
262-
_cachedSlowBudget = 1.0 / 60.0;
265+
_cachedMaxFPS = 59;
266+
_cachedSlowBudget = 1.0 / 59.0;
263267
}
264268
}
265269

0 commit comments

Comments
 (0)