NewsCrawler.org

Bypassing iOS Safari's 60 FPS Limit to Build Web Applications That Feel Native

Bypassing iOS Safari's 60 FPS Limit to Build Web Applications That Feel Native
Image: Reddit

The rida.dev blog describes how to make web interfaces feel native on iOS Safari, where requestAnimationFrame[1] is limited to 60 Hz on 120 Hz screens by default. Unless the "Prefer Page Rendering Updates near 60fps" flag in Safari's developer settings is changed, touch and pointer events are held to the same rate. The approach builds on Devon Govett's React Aria work, which relies on the browser's compositor[2] to handle scrolling in its own thread.

The author reads scroll positions from a hidden scrollable grid called a "controller", starting with about 80 reads per second using a MessageChannel and a setTimeout timed to the device's refresh rate. An empty requestAnimationFrame loop raised this to 90 reads per second, and a tiny invisible smooth-scrolling element was needed to reach 120 Hz on ProMotion[3] displays. Scroll values are scaled by the device pixel ratio to get sub-point precision.

The author reserves these techniques for animations and notes that the page itself can act as a controller. Safari, however, throttles reported scroll positions to 10 Hz during URL bar resizing.

Product Safari apple.com

Apple's web browser for iPhone, iPad and Mac, with built-in privacy protections and support for third-party extensions.

Apple shares (AAPL)

342.56 USD 0.0% since the news day, November 22

Close on November 20 Quotes: CNBC Chart by TradingView

Read the original rida.devDiscussion

Discussion

Most commenters praise the post and say they enjoyed reading it, though none say they will use the technique. One asks whether it works in Low Power Mode, where they say Safari caps animations at 30 fps, and how much battery a full-rate page uses. One reports that the blog feels laggy when scrolling in Firefox on Android.

Sources

Published: First seen: Читать по-русски

Open as a page