An unofficial, read-only Hacker News reader.

Bypassing iOS Safari's 60 FPS Limit to Build Web Applications That Feel Native (opens external site)

467 points by vinhnx 3 days ago | rida.dev | 149 comments on HN

View full thread · View on Hacker News

Comment thread (6)

  1. I’m on the Duo and I didn’t notice anything beyond what could be reasonably argued as a placebo effect.
    Replies (1)
    1. If you shake your hand in front of a strobe light, you should be able to count the afterimages, as if your hand was copied into multiple places in the same instant.

      Same goes here. If you go to the first two grids, and you shake the square until you can count the afterimages, check to see if one shows more afterimages than the other despite the same speed.

      If your device is genuinely limited to 60Hz for any reason or another, you'll see a little warning icon on the top-right.

      It might be easier in Low Power Mode, as well. This'll reduce the requestAnimationFrame loop to 30 Hz, but the higher refresh rate examples in this post will show at 60 Hz.

      Replies (1)
      1. If it takes that much effort then what’s the actual benefit of this vs the trade offs (battery life, more complicated code base and all the edge case rendering glitches)?
        Replies (1)
        1. It's a series of learnings, rather than an actual step-by-step on making a website feel native on iOS Safari. A good example for this would be a drawing application isolating the controller idea to get better responsiveness when someone draws, or a mobile game PWA using the refresh rate boosting to make the game feel better to players.

          I've been making websites for over a decade now, and yet even with AI in the loop, the blog post and demos took almost 5 days to become publishable, and another 4 to get the performance in a place where I was happy. This is because of the hybrid approach, and needing to build the entire page around that fact.

          Would I ever use liquid glass in an actual website? I would not, and certainly not as I did here with an annoying `_UILiquidLensView`-inspired scroll indicator. Do I think it serves as a good illustration/example for high-refresh rate websites on mobile? Absolutely!

          Replies (1)
          1. The Liquid Glass part of the page didn’t bother me because it was clearly just there as a demo widget.

            the question I have is this: if the difference between 60hz and 120hz matters, then why wouldn’t you choose a different software stack that compiles down to native code? You end up with better performance, better battery life, and cleaner code.

            I get this page should be treated as a lab demonstrating a solution. But it is, in my humble opinion, the wrong solution to that problem presented because it comes with far too many negative trade offs.

            And the AI point you raise is a great one. Because the old argument of sticking firmly with the web stack (“I only know how to use JavaScript so therefore I’m going to shoehorn JavaScript into every problem”) no longer applies.

            Replies (1)
            1. That's fair if you evaluate this demo as a single holistic "solution," but I think it should be seen as a set of learnings that enable different behaviour.

              As for whether refresh rate matters, the community seems to think so. The WebKit bug forum alone is filled with framework authors, drawing applications, game engine developers, etc., all begging Apple to drop the cap.

              That drawing application? It could use the controllers on their canvas and immediately double the resolution of their brush stroke interpolation. PWAs never had the ability to render above 60 FPS, even if the user opted out of the limit, now they can. These two things can be easily implemented with minimally invasive code. This demo is just a hybrid on the extreme end.

              Even if you throw away the I/O frequency, even if a developer were to now ask "hey, should this be on the compositor instead?" is a massive win for performance and battery life.

              People have already begun to take small learnings from this and apply them to their projects, my favourite is this user's portfolio (https://github.com/decepulis/portfolio-svelte-site/pull/12) where they were able to figure out why, on scroll direction change, their rAF was slowing to 10 Hz, and citing this post as the source for the fix.

              For some reason, people continue to build for the web. Whether it's an attempt to opt out of the underside of Apple's thumb, a preference for web frameworks, wanting cross-platform or ease-of-access, not wanting to go through App Store Connect, etc., this puts more tools in their tool belt. It's not meant to be an alternative for people considering building a native application.

              There is a reason I chose not to make this a library, or a framework. This is meant to be something people can throw their agents at, and fix the problems they encounter.