Closed s951736 closed 2 years ago
Hi @s951736, I guess you're experiencing performance issues? Can you share your code and some video please?
Hello @fermoya , I think performance is ok, I can use the app normally. Just wonder what cause the 60Hz on the 120Hz capable device. (My Mac is using a 60Hz monitor, so I realize this issue after I put it on real iPhone, but performance is nice on both device.)
And I just saw this yesterday: https://www.macrumors.com/2022/01/27/ios-15-4-apps-120-hz-promotion/ so I guess maybe it's caused by iOS itself? I'll try my project on a real device after I update iPhone to iOS 15.4 first, and I'll let you know.
(My code is a bit messy, but I'll be happy to clean it and put it here if it keeps not getting 120Hz even after iOS 15.4)
Hey @fermoya, also been having this issue for a while (iPhone 13 pro max). Here's the code: https://github.com/artemas-radik/swiftuipager-no120hz-demo
Hey @fermoya, I think this issue also exists in the sample app SwiftUIPagerExample. Profiling SwiftUIPagerExample with Xcode Instruments (on iPhone 13 Pro Max) reveals that the frame duration never drops below 16.67 ms (1 second / 0.01667 seconds per frame = 60Hz). We should be seeing it go down to 8.33 ms. This only affects the 120 Hz iPhones. The iPad Pro durations do drop to 8.33 ms (as expected) when profiling SwiftUIPagerExample. Images attached below.
Profile of SwiftUIPagerExample on iPhone 13 Pro Max Revealing Bugged Framerate Capped at 60 Hz
Profile of SwiftUIPagerExample on iPad Pro Revealing Expected Frame Durations of ~8.33 ms
Please let me know if you have any ideas for a fix! Would really appreciate it.
@artemas-radik , I don't think I'm following. To be honest with you, I didn't even know Instruments had that capability.
How did you come up with the issue? Is there a way to notice this visually? What do you mean by "support 120Hz", where or how do you add that support? I mean, Pager
is just a view built on top of native View
s, I don't think I've capped the frequency to 60Hz
I run into the same issue, scroll animation works on 60 fps. but every other scroll on this screen works with 120
How do you see see this in Instruments? I have no clue what could be causing this issue
@AndrewPetrov do you also experience this issue in iPhone 13 Pro Max? According to @artemas-radik , this isn't an issue in iPad Pro.
Is this something that happens to Pager
only or any other SwiftUI View
?
I found this interesting article about this issue:
https://swiftobc.com/repo/duraidabdul-FrameRateRequest-swift-animation-
It may decide to give you a smooth 120 FPS when the rectangle is moving fast (currently capped at 60 FPS due to a CoreAnimation bug). If you’re animating a button’s alpha, however, it may decide to give you a frame rate around 30 FPS (tested in instruments for a 0.4s alpha transition)
This makes sense to me with the screenshots @artemas-radik was sharing. A larger screen, iPad Pro, may decide to use 120 fps whereas the iPhone 13 Pro may not.
There's a hack mentioned in the article to try to force animations use 120 fps. Another similar hack can be found in this thread: https://developer.apple.com/forums/thread/690911?answerId=693140022#693140022
In that same conversation someone mentions:
I don’t think it’s related to pro display. There’s a lag and lower frame rate with DragGesture compared to PanGesture. Filled FB9781201
From reading all this, I don't think this is a bug of this library but rather a bug/ambiguity of SwiftUI and Pro devices
iPhone 13 Pro Max
Yes, at 13 Pro. I haven't used instruments but I see that ScrollView works significantly smoother then SwiftUIPager on the same screen
Today is the first time I run a project used SwiftUIPager on a real device, it's iPhone13 Pro Max, but it looks like 60Hz (I'm not sure) when I scroll through pages. Does it support 120Hz? Thanks.