Bypassing iOS Safari 60 FPS Limit
In October, Devon Govett of React Aria shared a post titled "Scrolling is All You Need: Building a Swipeable Sheet," where his team developed a sheet component that utilized native browsers' physics and smooth interactions to mimic a native experience. Jordan Walke, the creator of React, later demonstrated a similar experiment on X, showcasing a convincing native-like mobile interaction using DOM & CSS.
However, the video did not reveal that unless the "Prefer Page Rendering Updates near 60fps" flag is enabled in iOS Safari developer settings, WebKit limits requestAnimationFrame to 60 Hz on a 120 Hz screen, causing touch and pointer events to be restricted to that rate. This limitation results in websites feeling sluggish and irritating to use on mobile devices.
To improve the experience, the author examined two grids moving a square when dragged; one used JavaScript events and set the transform attribute in CSS, while the other simply placed a square in a scrollable area. The latter grid was noticeably smoother, running entirely on the compositor, avoiding JavaScript round-trips. The goal was to read scroll position outside of the renderer, enabling the extraction of native bounce, physics, and momentum for animations.
The author discovered that measuring scroll events updated between 5 to 26 times per second during momentum scroll on an iPhone Duo. To overcome this limitation, they employed a MessageChannel to throttle scroll measurements to the device's refresh rate, synced with vsync timestamps using requestAnimationFrame. This approach increased scroll position readings to 80 times per second, nearing the 120 Hz ProMotion refresh rate.
Additionally, utilizing a GPU-accelerated CSS animation allowed the screen to reach full 120 Hz during scrolling, while a small invisible scroller maintained this refresh rate when needed. The final solution involved creating "scrolling controllers" that function similarly to touchpads, enabling smoother and more responsive interactions across various scenarios.
Rewritten by urgent.news; may contain errors — check the original.
Source: rida.dev