alexiscreuzot / SwiftyGif

High performance GIF engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gif animations play at different speeds on iPad vs iPhone

RoboWorldEnt opened this issue · comments

Hello all,

I've been loving SwiftyGif so far. When we implemented it, we noticed gif animations are playing at different speeds on iPad vs iPhone. Here's a few videos to showcase what I mean:

iPad:
https://trello-attachments.s3.amazonaws.com/5d8d55c6edf1901a536c38c8/5dc185b8b25a342a77c24f2e/4e2fd05eb07a1254ec5ed1179648e0b1/ipad-gifplayback.mp4

iPhone:
https://trello-attachments.s3.amazonaws.com/5d8d55c6edf1901a536c38c8/5dc185b8b25a342a77c24f2e/029961d6a5990c416ee0b79830e511a3/iPhone_gif_playback.mp4

Any ideas about how to fix this?

The error might be around here : https://github.com/kirualex/SwiftyGif/blob/master/SwiftyGif/UIImage%2BSwiftyGif.swift#L207-L215

Could you try changing :
let displayRefreshFactors = [60, 30, 20, 15, 12, 10, 6, 5, 4, 3, 2, 1]
to
let displayRefreshFactors = [30, 20, 15, 12, 10, 6, 5, 4, 3, 2, 1]

@kirualex tried that, didn't help - still get ~2x GIF speed on iPad Pro (11-inch) iOS 13.7.

Same problem on iPad Pro, gif plays abnormally faster.

Tried add 120 to displayRefreshFactors and works.
let displayRefreshFactors = [120, 60, 30, 20, 15, 12, 10, 6, 5, 4, 3, 2, 1]

It might be related to the 120HZ refresh rate on iPad pro?

I'm having the same problem. What's the best workaround?

@amberreyn I've ended up using simple WebView (my case is onboarding screen, with a single looping animation) with SwiftUI like so:

WebView(url: Bundle.main.url(forResource: "fox.gif", withExtension: nil)!)
                    .frame(width: 240, height: 240)

Submitted a PR that fixes this: #150