HN
Today

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

This article details an ingenious deep dive into iOS Safari's rendering engine, revealing how to bypass its 60 FPS limit to achieve true 120 Hz input and rendering for web applications. The author masterfully leverages scroll mechanics and OffscreenCanvas trickery to create web experiences that feel genuinely native. Hacker News found this fascinating, admiring the technical prowess while simultaneously lamenting Apple's restrictive web platform policies that necessitate such elaborate workarounds.

86
Score
22
Comments
#5
Highest Rank
10h
on Front Page
First Seen
Nov 25, 4:00 AM
Last Seen
Nov 25, 1:00 PM
Rank Over Time
991088557810

The Lowdown

The article presents a groundbreaking method to overcome iOS Safari's default 60 FPS cap for web applications, enabling truly native-feeling interactions on high-refresh-rate ProMotion displays. This addresses a persistent challenge for web developers aiming to build performant Progressive Web Apps (PWAs) that can compete with native experiences.

  • The 60 FPS Problem: iOS Safari deliberately limits requestAnimationFrame and touch events to 60Hz, even on 120Hz screens, making even well-optimized web apps feel sluggish compared to native counterparts.
  • High-Frequency Input: The author's first major step was to achieve 120Hz input. This involved leveraging the browser's compositor for scrolling (which runs on a separate thread) as a high-frequency input source. After several failed attempts with MessageChannel recursion and Atomics, a successful approach combined a throttled MessageChannel with requestAnimationFrame timestamps for vsync locking.
  • Squeezing Out Hertz: To reach the full 120Hz input, the author discovered tricks like maintaining an empty requestAnimationFrame loop to force Safari to flush scroll positions and using a tiny, invisible background scroller to activate ProMotion's 120Hz mode when needed. Sub-pixel precision for scroll values was achieved through clever scaling.
  • Breaking the Render Barrier: The ultimate breakthrough for 120 FPS rendering on canvases involved OffscreenCanvas with transferControlToOffscreen. WebKit, following the HTML spec, skips waiting for the main thread's rendering pass when OffscreenCanvas pushes a frame, effectively allowing frames to be presented at the full device refresh rate.
  • Real-World Application: The techniques are demonstrated with

The Gossip

Safari's Secret Surprises: A Technical Triumph

Many commenters expressed profound admiration for the author's technical ingenuity and the depth of the research involved in uncovering these WebKit workarounds. The post was lauded as 'incredible' and 'very useful,' particularly for web game developers seeking better performance. However, this praise was often accompanied by frustration directed at Apple's restrictive stance on web technologies, with some directly criticizing Apple's policies for making such elaborate hacks necessary to achieve what should ideally be natively supported.

Frames Per Second: Finer Feeling or Faint Flaws?

The discussion revealed a clear divide in how users perceived the 120 FPS difference. Some users immediately noticed and appreciated the smoother interactions, describing the experience as 'feeling good.' Conversely, a significant portion reported being unable to discern any difference between the 60 FPS and 120 FPS examples, or argued that 60 FPS was 'perfectly serviceable' and the article might be 'disingenuous.' A notable sub-thread emerged regarding the 'liquid glass' UI element, which some found visually appealing, while others reported it induced ocular migraines or motion sickness, highlighting the subjective nature of visual perception and UI effects.