· JavaScript

React Aria, OffscreenCanvas allow bypassing iOS Safari 60 FPS limit for 120 Hz rendering

The ability to achieve a full 120 Hz input and rendering rate in iOS Safari web applications, utilizing native scroll containers and OffscreenCanvas, represents a significant leap for developers.


Previously, Jordan Walke, the creator of React, shared an X video showcasing a mobile interaction that felt convincingly native, prompting a response from me after Devon Govett of React Aria posted "Scrolling is All You Need: Building a Swipeable Sheet" in October, detailing how his team engineered a sheet component that skillfully utilized native browser physics for a native-like feel. However, the video Walke posted omitted a crucial detail: without enabling the "Prefer Page Rendering Updates near 60fps" flag found deep within Safari's iOS developer settings, WebKit restricts `requestAnimationFrame` to merely 60 Hz on a 120 Hz screen, and touch and pointer events adhere to that same frequency on a standard page. This limitation contributes to the frustrating experience of even the finest mobile websites. The core question became: how to improve this usability without relying on developer flags?

Returning to the React Aria work, the reason it felt so good was that scrolling was managed by the compositor, operating in its own thread; it moved, clipped, and faded without needing a JavaScript round-trip—from finger to digitizer, to compositor, to GPU. This mechanism became the foundation for our new interaction. Two grids were demonstrated: one on the left relied on JavaScript events to set CSS transform attributes, while the one on the right simply placed a square within a scrollable area. On an iOS Safari, one could instantly discern the difference: the left grid refreshed at most 60 times per second in a renderer pass, whereas the right utilized the compositor.

To harness the scroll area's capabilities, the challenge was discovering a method to access the scroll position outside of the renderer. Success in this would allow us to treat the scroll like a trackpad or to "extract" native momentum, bounce, and physics directly from the compositor into our animations. The potential for flexibility was immense if we could retrieve these values frequently enough. During momentum scrolling on an iPhone Duo, I observed scroll events updating between five and twenty-six times per second; the best scenario, during slow, deliberate scrolling, reached nearly 60 updates per second—which was insufficient.

Instead, the focus shifted to reading `scrollTop` and `scrollLeft` synchronously. My initial attempt involved a recursive `MessageChannel` call, which functioned but resulted in 50,000 reads per second using only 80 distinct values, representing substantial waste and heat due to pinning a CPU core. The next failure involved using `Atomics` to awaken at the screen's refresh rate; this extracted 80 distinct positions every second, but the associated drawbacks were too severe since it necessitated `SharedArrayBuffer`, forcing the use of COOP/COEP headers that disrupt cross-origin assets on the site.

The breakthrough arrived by employing a `MessageChannel` similar to the first attempt, but by throttling the subsequent measurement using a `setTimeout` synchronized to the device's refresh rate, phase-locked via `requestAnimationFrame` timestamps. Despite initial apprehension regarding this technique, it proved effective. The sole remaining hurdle with this specific solution was easily overcome: iOS rounds `performance.now()` to the millisecond, so I calculated the minimum time between draws based on the refresh interval.

Each method achieved 80 position reads per second, representing two-thirds of the 120 Hz input goal. Safari's UI process sends the web process one scroll position at a time, pausing until it receives confirmation from the web process before dispatching another, which caused dropped positions for anything arriving in the interim. Diving into WebKit revealed the necessary workaround: Safari flushes the position without waiting on every tick where a rendering update is queued. An empty `requestAnimationFrame` loop accomplished this, yielding an approximate 12.5% increase in reads, bringing the total to 90 unique position reads per second.

I initially assumed this marked the limit of the Inter-Process Communication (IPC), but it turned out ProMotion was merely configured to avoid rendering above 90 Hz. Achieving the final 30 Hz was more complex. A CSS animation accelerated by the GPU allows the screen to reach 120 Hz, but only while scrolling is active. Therefore, a minuscule, unseen scroller is set to smooth-scroll in the background, poised to boost performance to the full ProMotion rate whenever needed. Naturally, we do not want the display locked at 120 Hz constantly, so we reserve the techniques used to reach this peak for moments when animations are anticipated: touch events, scroll-derived animations, and so forth. If the interaction being built lacks momentum, rubber banding, or snapping, developers can bypass these features and simply use a passive `touchmove` listener on the controller, which fires at the full 120 Hz. This immediately delivers updates from the controller at the full 120 Hz.

One issue persisted: `scrollTop` and `scrollLeft` are rounded to the nearest whole number, even though iOS scrolls with sub-point precision. Fortunately, this was a simple fix: scaling the scrollable surface up by the device pixel ratio and subsequently scaling its container back down by its inverse. If one chooses to use the viewport itself as the controller, an invasive method involves setting the initial-scale in the same manner, but this entails several trade-offs: units must be scaled by the DPR, text autosizing must be disabled, and safe areas require manual scaling, alongside the appearance of small text-selection indicators. These are all trade-offs, but none are mandatory.

From this point forward, I will refer to these scrolling grids as "controllers" because they function precisely as one. The requirement is simply to make one invisible and position it over the area where high-frequency input needs to be monitored. It is worth noting that the page itself can function as a controller, but Safari throttles reported scroll positions to 10 Hz when the URL bar resizes during a scroll direction change. WebKit avoids this throttling if the page features a scroll-driven animation that animates a non-GPU-accelerated attribute. I opted for transitioning between two transparent colors for this page. This grants high-frequency input, yet since the DOM still only updates 60 times per second, leveraging it as is would mean updating a value twice for every drawn frame, offering the user no tangible advantage.

The majority of dragging interactions are already covered by the custom controllers, and pre-defined animations are handled by CSS animations. But what about more intricate interactions? What about layouts derived from computation? What about shaders? Consulting a search engine or AI today regarding "How to render canvas content on iOS at 120 Hz without feature flag?" will yield the response that this is fundamentally impossible in iOS Safari. Even WebKit's own bug tracker is filled with requests for this functionality. Game-engine developers like Ink & Switch even cite Capacitor & Tauri for utilizing private APIs. Google's search results provide this context: "There is no public web API or standard JavaScript workaround to force HTML5 <canvas> (requestAnimationFrame) to run at 120 Hz on iOS Safari without changing the system feature flag." Fable 5.2 shares this perspective. The concise answer is: it cannot be done for JavaScript-drawn canvas frames. On iOS, WebKit caps page rendering updates (when canvas content is displayed) at 60 Hz unless the user disables the flag, and no web API can override this. Furthermore, timer-based loops (`setTimeout`, `MessageChannel`) are ineffective; while one can draw more often, the presentation remains locked to the 60 Hz rendering update. Low Power Mode imposes further throttling.

Initially, my focus was solely on scrolling. I experimented with breaking workers, rendering permutation "flip-books" beforehand, and even live-generating video, but every attempt resulted in excessive lag, jaggedness, or required so much RAM that the WebKit process crashed. After seven attempts and extensive investigation into WebKit's source code by several agents, I arrived at this solution. In WebKit on iOS, creating a canvas element and executing `transferControlToOffscreen` returns an `OffscreenCanvas`. The original canvas element then acts as a placeholder, and WebKit—adhering to the HTML specification's guidance—skips waiting for the next rendering pass when an `OffscreenCanvas` submits a frame. Unlike earlier attempts, this method is gentle on battery life and only consumes memory necessary to support a higher-frequency backing store. This was a major breakthrough: we now have 120 FPS rendering on iOS WebKit canvases.

Putting It All Together Now, we can ingest input at 120 Hz and render the output at the exact same frame rate. My first project was a small UI replica of Ando’s mobile application, complete with a Liquid Glass tab bar, buttons, and incredibly smooth navigation transitions. After installing it as a PWA, I repeatedly had to verify that I wasn't using the native application. This page features two custom "Liquid Glass" elements within the viewport, each rendering at the device's full refresh rate. Achieving this in a convincing and performant manner required extreme deliberation. Upon initial page load, we capture a snapshot and load it into a WebGL texture, which serves as the basis for a composite fed into our shader. As the page scrolls, we sample the area beneath each component, which is all that is needed to generate our effect. Constructing it this way ensures that regardless of how the content underneath is structured, it can determine the optimal way to keep the texture active. On this page, components utilizing `requestAnimationFrame` update the texture from the main thread for demonstration purposes, while components using `OffscreenCanvas` post their frames directly from their workers to the worker

Why it matters

This development provides a path for web developers to overcome the native 60 FPS limitations in iOS Safari for smooth interactions. Achieving higher frame rates is crucial for building web applications that feel truly native to users. Developers should investigate this technique if they are building complex, high-fidelity mobile experiences.

Earlier coverage

Related coverage

Also worth reading

  1. Rewind adds rewind time command to analyze critical path, inspired by Brendan Gregg's work
  2. InferNode provides 64-bit edition of Bell Labs' Inferno OS
  3. UK gov invests in Agon Dynamics, defense startup for virtual AI training ground
  4. Anthropic launches Claude Ship in beta to review, fix, and approve pull requests
  5. pgrust, LLMs lower barrier to entry for complex performance optimizations