jtrivedi / Wave

Wave is a spring-based animation engine for iOS and macOS that makes it easy to create fluid, interruptible animations that feel great.
https://jtrivedi.github.io/Wave/
MIT License
2.04k stars 55 forks source link

DisplayLinkProvider preferredFrameRateRange range error #30

Closed kushsolitary closed 1 year ago

kushsolitary commented 1 year ago

Hi,

First of all - great library! I am trying this out with SwiftUI (although I think this issue is unrelated) but I am encountering an issue. On my physical device (iPhone 11 Pro), the returned value of UIScreen.main.maximumFramesPerSecond is 61.

This makes the following error out:

        if #available(iOS 15.0, *) {
            let maximumFramesPerSecond = Float(UIScreen.main.maximumFramesPerSecond)
            let highFPSEnabled = maximumFramesPerSecond > 60
            let minimumFPS: Float = highFPSEnabled ? 80 : 60
            displayLinkProvider?.preferredFrameRateRange = .init(minimum: minimumFPS, maximum: maximumFramesPerSecond, preferred: maximumFramesPerSecond)
        }

Error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'invalid range (minimum: 80.00 maximum: 61.00 preferred: 61.00)'

For now, I am forking the repo to increase the highFPSEnabled threshold and see if that works. Is there any other way to make the check work more reliably?

jtrivedi commented 1 year ago

Interesting, good find! Let me take a look 👍

jtrivedi commented 1 year ago

Fixed with release 0.3.2. Thanks for opening the issue!