Skip to content

Conversation

@JesusRojass
Copy link
Contributor

@JesusRojass JesusRojass commented Oct 28, 2025

Fix frame rate metrics for dynamic refresh rates (#10220)

Discussion

Fix slow rendering false positives mentioned in #10220 (Work In Progress Ongoing testing!!!)

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 this fixes? (My possible reproduction ideas on why this is happening):

Case 1 - tvOS 50Hz Display (Europe)

  • Configure Apple TV to output 50Hz (Settings > Video and Audio > Format)
  • Launch any app with smooth animations
  • Monitor Firebase Performance console for slow rendering metrics
  • Observe that 18ms frames (well within 20ms budget) get flagged as slow due to 16.67ms threshold

Case 2 - ProMotion iPhone, iPad and MacBook Dynamic Rates

  • From the iPhone 13 Pro or Pro Max or more recently released iPhones (14, 15 16 Pro and Pro Max or any from the 17 line up), recent iPad Pro with ProMotion enabled and Macbook's equipped with a ProMotion Display Like the Pro models or recent Air Models
  • Created a test mule app with static content (forces display to lower refresh rates for power saving)
  • When display drops to 24Hz, 40ms frames are normal but get flagged as slow
  • When display jumps to 120Hz, 10ms frames should be flagged as slow but aren't

Case 3 - External Displays with Custom Refresh Rates

  • Connect Mac to external display supporting non-60Hz rates
  • Set custom refresh rate in System Settings
  • Launch app and observe incorrect frame classifications

Case 4 - Adaptive Sync Displays

  • Use a display with VRR (In my case I tried with a Hisense U8N TV and Asus TUF Gaming VG27AQ3A)
  • Content frame rate doesn't match display refresh rate
  • Static thresholds fail to account for dynamic pacing

Testing

  • Ongoing Testing, Work in Progress but locally it is passing all unit tests
  • ONGOING!!! Manual testing on ProMotion devices with rate changes (iPhone 14 Pro, 16 Pro and a MacBook Pro 16 inch from 2021)
  • ONGOING!!! Validation on 50Hz tvOS configuration
  • ONGOING!!! Check for Backwards compatibility verified (60Hz behavior unchanged)

API Changes

  • No API Changes

@JesusRojass
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement by adapting the frame rate metrics to handle dynamic refresh rates, which is crucial for modern Apple devices. The approach of using CADisplayLink's targetTimestamp and timestamp to determine the actual frame duration is solid and correctly addresses the scenarios outlined in the description. The logic for identifying slow and frozen frames is now much more accurate across different display frequencies.

I have a couple of minor suggestions to clean up the code: one regarding an unused instance variable that was introduced, and another about a comment's formatting. Overall, this is a great change that will improve the accuracy of performance monitoring.

@JesusRojass
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses issues with frame rate metrics on devices with dynamic or non-60Hz refresh rates. The core change is to move away from static thresholds for slow and frozen frames to dynamic ones based on the actual frame duration provided by CADisplayLink. This is a solid approach that correctly handles variable refresh rates as described in the problem statement. The introduction of kFPRFrozenFrameMultiplier to define a frozen frame relative to the current refresh rate is a clever way to maintain perceptual consistency across different devices. Additionally, pausing the CADisplayLink when the app is backgrounded is a nice performance and battery-saving improvement. The changes are well-implemented and the code is clear. I have one minor suggestion regarding comment formatting.

JesusRojass and others added 2 commits October 28, 2025 13:08
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@JesusRojass JesusRojass marked this pull request as ready for review October 29, 2025 18:45
@JesusRojass
Copy link
Contributor Author

@visumickey All of my commits ready for review, just continuing with my testing atm

@JesusRojass JesusRojass changed the title WIP!!! - Fix frame rate metrics for dynamic refresh rates #10220 Fix frame rate metrics for dynamic refresh rates #10220 Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant