Skip to content

Commit

Permalink
Merge pull request #32 from rosskimes/main
Browse files Browse the repository at this point in the history
Fixed a crash on tvOS if the device’s refresh rate was set below 60fps.
  • Loading branch information
b3ll authored Jan 23, 2024
2 parents 3bb3e02 + fe99822 commit c676667
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/Motion/Utilities/AnimationDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ final class CoreAnimationDriver: AnimationDriver {
If we've got a high refresh display, we can use 80 as a minimum.
https://developer.apple.com/documentation/quartzcore/optimizing_promotion_refresh_rates_for_iphone_13_pro_and_ipad_pro
- Note: We choose 80 as a minimum to be considered high refresh rate, since some devices will erronously report 61fps as a maximum (see: https://github.com/b3ll/Motion/issues/25)
- Note: We choose 80 as a minimum to be considered high refresh rate, since some devices will erronously report 61fps as a maximum (see: https://github.com/b3ll/Motion/issues/25). We also have the guard against the minimum being below the maximum because tvOS can run at less than 60fps.
*/
let adjustedMinFPS: Float = maxFPS > 80.0 ? 80.0 : 60.0

let baseMinFPS: Float = maxFPS > 80.0 ? 80.0 : 60.0
let adjustedMinFPS = min(baseMinFPS, maxFPS)

return CAFrameRateRange(minimum: adjustedMinFPS, maximum: maxFPS, preferred: maxFPS)
}

Expand Down

0 comments on commit c676667

Please sign in to comment.