1

In iOS, How many times does RunLoop cycle in one second? Is it the same as the screen refresh rate, 60 times a second?

emmm
  • 11
  • 1
  • Yes, except that the screen refresh rate isn't always 60 times a second. – matt Oct 29 '21 at 11:45
  • If you want to match with the screen refresh rate you might want to look into using `CADisplayLink`. – Fogmeister Oct 29 '21 at 11:46
  • The iPhone refresh rate is not constant and can vary based on load. And also, is not always based around 60fps. Some of the old devices are 30fps and the new iPhone 13 aims for 120fps. – Fogmeister Oct 29 '21 at 11:49
  • There is one [RunLoop](https://developer.apple.com/documentation/foundation/runloop) per thread. Also, documentation (even for for [main thread RunLoop](https://developer.apple.com/documentation/foundation/runloop/1418388-main), or [CFRunLoop](https://developer.apple.com/documentation/corefoundation/cfrunloop-rht)) does not mention how often it runs, OR if it is in any way related to display refresh rate. It would be better to mention what you are trying to achieve, so you'll get better / relevant answers. – Swapnil Luktuke Oct 29 '21 at 12:11
  • @matt - Are you sure about that? IIRC, the run loop runs with far greater frequency than the screen refresh rate. – Rob Oct 29 '21 at 15:28
  • This feels distinctly like a XY problem. – Rob Oct 29 '21 at 15:46
  • @Rob I agree with you but usually the reason for wanting to know this is the situation where you need to let the run loop loop, and that generally means you're waiting for the transaction to commit, which is effectively the same as the screen refresh rate. So the xy problem critique holds. – matt Oct 29 '21 at 15:48

1 Answers1

2

No, the run loop frequency is not the same as the screen refresh rate. (It generally exceeds the potential screen refresh rates unless you block the thread.)

When we need to coordinate something with the screen refresh process, we generally use a CADisplayLink, which not only runs with the desired frequency, but also maximizes its timing within the screen refresh cycle.

Note, screen refresh rates can vary from device to device, and, on new devices, they can even vary depending upon the needs of a particular task running on a particular device (faster when you need better performance, slower when not needed and you want to enjoy more energy efficiency). See Optimizing ProMotion Refresh Rates for iPhone 13 Pro and iPad Pro.

Rob
  • 415,655
  • 72
  • 787
  • 1,044