From fe9982205224e14a58ae291573ae65b57af1d72c Mon Sep 17 00:00:00 2001 From: Ross Kimes Date: Thu, 4 Jan 2024 16:01:58 -0600 Subject: [PATCH] =?UTF-8?q?Fixed=20a=20crash=20on=20tvOS=20if=20the=20devi?= =?UTF-8?q?ce=E2=80=99s=20refresh=20rate=20was=20set=20below=2060fps.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Motion/Utilities/AnimationDriver.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/Motion/Utilities/AnimationDriver.swift b/Sources/Motion/Utilities/AnimationDriver.swift index c5a4bd6d..2dc4f271 100644 --- a/Sources/Motion/Utilities/AnimationDriver.swift +++ b/Sources/Motion/Utilities/AnimationDriver.swift @@ -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) }