firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

#10220 - Use UIScreen.maximumFramesPerSecond for dynamic slow frame threshold

Open JesusRojass opened this issue 3 weeks ago • 3 comments

Discussion

Fix for #10220 by deriving slow-frame budget from UIScreen.maximumFramesPerSecond

User Statements:

  • Slow rendering values on tvOS approximately 150 times higher (~60%) than on iOS (<1%)
  • ProMotion devices reporting inaccurate frame metrics during refresh rate changes
  • 50Hz tvOS displays (Europe) incorrectly flagging smooth 18ms frames as slow
  • Static 60Hz assumption breaks on modern Apple hardware with variable refresh rates

What was done?

  • Replace fixed 16 ms with slowBudget = 1.0 / UIScreen.mainScreen.maximumFramesPerSecond (seconds). Keeps frozen at 700 ms. Behavior at 60 Hz preserved.
  • Cache maxFPS and recompute slowBudget only when needed.
  • Scoped refresh of the cache to tvOS on app-did-become-active.

Testing

All green ✅

Added tests:

  • 50 fps budget ~20 ms, 60 fps ~16.67 ms, 120 fps ~8.33 ms - assert slow/ok classification and frozen remains at 700 ms.
  • tvOS-specific test mirroring testSlowFrameIsRecorded.
  • Tests stub maximumFramesPerSecond locally to avoid global state.

API Changes

No API Changes

JesusRojass avatar Nov 20 '25 00:11 JesusRojass