13

Fortrikka

Yep as mentioned in post, it works in Orion nicely now 🙂 The question I’m posing is if it should be more of a user facing feature yet, given it’s all there and ready. And then secondarily how it should interact with the system and app level power save settings.

    gp Can you measure the energy impact of enabling higher refresh rates?

    I am concerned that enabling this by default, even only if plugged in, will lead to posts of "Orion is using more energy than Safari!"

      My understanding:

      Promotion is variable refresh rate, not 120Hz. Promotion allows for even better power efficiency because it can drop as low as 10Hz depending on the context and content. Without promotion, everything refreshes at 60Hz unless something slows down. So having this on by default can offer a net reduction in power usage.

      Very likely I am not understanding this correctly, or how it relates to web browsing and animation frames and stuff 🙂

        Cannabat What you say also makes sense.

        Can you measure energy impact with and without this feature and share your findings?

          I believe Cannabat is absolutely correct here - it appears in Mac OS that screen refresh rate on a Pro Motion screen is "dynamic". I am not aware of any tooling that lets you see the "current" refresh rate.

          Does anyone know if such a tool or option exists yet? I assume it would run at Mac OS level, since the panel is refreshed based on a request from the OS, which interfaces with the hardware.

          It would be cool to see refresh rates slowed too, so that when you are reading, the system is slowing the refresh rate down as required. Absent access to tooling that shows current refresh rate though, it will be hard to really test this with certainty.

          Information I've found so far:

          Sounds like Adaptive Sync is only available for fullscreen apps. But other features should be available for anything. I wouldn't be confident doing many tests until we have a way to reliably see the system-level refresh rate of the screen.

            Vlad gp

            Did some tests and it looks like disabling "Prefer Page Rendering Updates near 60fps" (I'll call this the ProMotion setting) actually increases energy impact by a small but detectable amount.

            Did three tests using the macOS-provided Energy Impact value.

            1 - UFO test page
            https://www.testufo.com/
            This maxes out the refresh rate, so we expect the ProMotion setting to do worse. Left it running for 60s.

            60Hz: 9.181
            ProMotion: 15.701

            2 - A Reddit post, static, no user interaction
            Left it running for 5 min.

            60Hz: 0.666
            ProMotion: 0.727

            3 - A Reddit post, using JS to scroll 400px every 5 sec and then return to top
            Left it running for 5m.

            60Hz: 8.313
            ProMotion: 9.215

            Methodology

            I set the tests running and didn't touch the laptop until I was sure enough time had passed. 14" M1 Pro. Tested with charger connected, not that that should matter on this machine.

            Run macOS built in command powermetrics repeatedly for however long via shell script:

            powersh.zip
            470B

            It takes 5 or 6 seconds for the command do do its sampling, so you get about 12 samples per minute.

            Uses the flag --show-process-coalition to group processes, then got the coalition for com.kagi.kagimacOS.

            For the scroll test, ran this JS to keep the page regularly scrolling, in hopes of simulating actual user interaction:

            autoscrolljs.zip
            379B

            Copy the relevant column into Numbers.app, take average of samples excluding a few obvious outliers. Spreadsheet:

            orion-power-test.zip
            198kB

            Thoughts:

            • I'm sure somebody cleverer than I can do better tests.

            • I thought for sure the ProMotion would be better but surprisingly, even with the static page, it's significantly less efficient. You'd guess that with a static page, it could just drop to 10Hz and that would be definitely less than the 60Hz mode...

            • After about 1 min during the scroll test, the energy impact decreases substantially. Maybe that happened after the whole page had been scrolled and the rendered page was in a buffer? If you exclude the first dozen or so samples, the ratio of impact for 60Hz:ProMotion is approximately the same, so I don't think this really matters.

            • Perhaps in the future, this will get optimised and ProMotion will provide better efficiency. Perhaps this setting does allow for higher refresh rates but doesn't exactly do the ProMotion thing just yet.

            • Somebody oughta do this kind of testing for other browsers (at least Safari) and other Macs with high refresh rate external displays.

              Very interesting results, and thanks for doing these. I think we need tooling to see the “current screen refresh rate”, as well as (maybe) the window’s redraw rate.

              I’m wondering if Mac OS uses a “hack” like only doing “true” ProMotion when an app is in full screen mode. That means they don’t have to make the display driver detect the “right” refresh rate based on multiple windows shown on the screen at once.

              If the current setting is only allowing “higher” rates, I guess your findings make sense. Maybe Orion (and/or Safari) can’t actually get down to 10 Hz (or indeed anything below 60 Hz).

                Cannabat Fantastic job, thank you! Also I did not know about powermetrics command, very handy!

                It is expected that with higher refresh rate you use more energy. I am wondering if you can confirm

                • the effect is instant as you switch the flag on/off?
                • the findings in full screen more?

                This may help us define what the option might look like. Switching to high refresh rate for now seems like something we could 'safely' do when on power adapter.

                  gp
                  Vlad

                  No worries, it's a fun bit of investigation.

                  I did a good bit of searching to find some utility to get the current screen refresh rate and came up empty-handed. I did, however, find CVDisplayLinkGetActualOutputVideoRefreshPeriod which appears to provide the number we are after. I reckon you guys would know how to use this function, but I'm clueless here, my beard is a bit too short!

                  Unfortunately, the effect of this setting is not instant, the app must be fully restarted for it to take effect. Makes it a bit less useful.

                  I did the same static and scrolling tests in fullscreen:

                  Reddit Static FS - 5m
                  60Hz: 0.618
                  ProMotion: 0.481

                  Reddit Scroll/5s FS - 5m
                  60Hz: 8.896
                  ProMotion: 10.333

                  I was scrolling every 5 seconds so powermetrics sample (which is 5s) got one scroll event. I changed it to scroll every 7.5s, in case having it synchronized with the sampling was doing anything weird.

                  Reddit Scroll/7.5s FS - 5m
                  60Hz: 7.074
                  ProMotion: 7.910

                  As you'd expect, the overall impact is lower, and the difference between the two is less - less action on the screen overall. Still, the ProMotion setting is worse.

                  Interestingly, the static test in fullscreen shows a solid improvement in energy impact with the ProMotion setting. The 60Hz is similar but there's a 34% reduction in impact w/ the ProMotion setting vs 60Hz. I guess getting my menubar (which is has constantly updating iStat menus) out of the way is helping.

                  So it appears that, indeed, fullscreen changes how this works. As I was trawling through trac.webkit.org and various resources related to this stuff, I saw mentions of how fullscreen is needed to get the most out of variable refresh rates (both adaptive sync monitors and ProMotion displays). Makes sense.

                  I'm calling disabling this experimental setting "ProMotion", but it's actually not that at all, it's just asking webkit to draw close to 60fps. And it should probably just be "60fps" and not "60Hz" - it's only aiming for 60Hz because I'm on a ProMotion display. In the case of a 144Hz monitor, for example, this setting tells webkit to draw at 72Hz. The actual rate is determined by the system and provided via CoreAnimation (iOS/iPadOS/Catalyst) or CoreVideo (macOS) to the application. Some more tidbits:

                  https://developer.apple.com/videos/play/wwdc2021/10147/
                  https://developer.apple.com/documentation/quartzcore/optimizing_promotion_refresh_rates_for_iphone_13_pro_and_ipad_pro

                  PS: asitop (pip3 install asitop) is a nice terminal UI for powermetrics, pretty cool.

                  • Vlad replied to this.

                    Cannabat Phenomenal insights!

                    What would be your recommendation regarding Orion's handling of this setting after learning all this information?

                      Vlad

                      I reckon leave the setting enabled (the default) is best for now. The efficiency of the default setting seems more important than the page redraw speed improvements, and feels more in line with Orion's approach to a browser. If the default is ever changed in Safari, perhaps Orion could follow suit.

                      It's worth noting that preferring 60fps was permanently set in previous Safari versions and was only moved to the Experimental Features menu on 4 Nov 2021, presumably in response to the release of the MacBooks with ProMotion displays.

                      Also worth nothing that the webkit team appears to still be working on the high/variable refresh rate stuff, for example, there was a problem with scrolling and 120Hz that was resolved on 31 Oct 2021.

                      I suspect this stuff will be optimised (upstream of Orion) in the coming months as the new MacBooks become more widespread.

                        No one is typing