lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Change Default value of navigator.DeviceMemory

Open gilbertococchi opened this issue 3 years ago • 7 comments

Hi all, I would to request to consider changing the default value of navigator.DeviceMemory as being emulated by Lighthouse.

DeviceMemory can be used by Developers as proxy signal to identify High or Low End devices and this may be particularly helpful to improve the accuracy of Synthetic Lab Testing for sites in NBU countries such as India, Brasil and others.

There is a strong correlation with LCP and DeviceMemory value measured by many sites, example: https://www.smashingmagazine.com/2022/03/signals-customizing-website-user-experience/#device-capability-signals

If Lighthouse would change the default to 2-3GB (the area where LCP gets worse on these devices overall) Developers would see their Performance Score reflecting this.

Currently Lighthouse always returns 8GB as DeviceMemory value according to my understanding.

Reference about DeviceMemory in the context of Adaptive Content Strategies: https://developer.chrome.com/blog/device-memory/

gilbertococchi avatar Mar 21 '22 09:03 gilbertococchi

To be clear, we would at most be changing the value navigate.deviceMemory returns, not the amount of memory being utilized by the underlying system (which is infeasible for us to do). So this change would only allow Lighthouse to exercise strategies that sites adopt to reduce loading times based on the amount of memory the browser says is available. Is this your expectation wrt this feature request? (it sounds like a good idea to me)

As far as actually doing it, the chrome devtools protocol does not support this so we will need protocol work. I've filed an issue for this: https://bugs.chromium.org/p/chromium/issues/detail?id=1308873

connorjclark avatar Mar 21 '22 21:03 connorjclark

Hi @connorjclark, good hear back from you! Yes, my initial idea was only in the real of what would be the value returned by navigator.deviceMemory, not the overall amount of memory effectively allocated by the emulated environment.

You've raised a really valid point about DevTools, I am not surprised that the protocol doesn't support this, actually this is a great hint.

@jackfranklin any idea whether there is an existing FR on DevTools to be able to customize the DeviceMemory value? I wished many times I could change that on top of the Network ETC value.

gilbertococchi avatar Mar 21 '22 22:03 gilbertococchi

If FR = feature request, then no, I don't believe there is any work planned in that area. The bug that @connorjclark opened is the best avenue here.

jackfranklin avatar Mar 22 '22 09:03 jackfranklin

I'm not sure I agree with this proposal to be honest.

Looking at stats I've gathered 1-2GB of RAM seems to be the minority, even on mobile and even in poorer countries (17% of users and 16% page views of Smashing Magazine mobile users in India to take one example - though how representive that is, is of course a good question). Now, while lighthouse settings typically target the lower end of what's in use (and should btw IMHO!) I think that's verging on too low. And that is only going to get less as technology marches on.

Plus the fact this is only the reported DeviceMemory and not the actual memory used for the site makes it a bit of a moot point. I'd warrant the actual memory is a bigger factor in the performance.

If Lighthouse would change the default to 2-3GB (the area where LCP gets worse on these devices overall) Developers would see their Performance Score reflecting this.

I disagree with this, since the conversation made clear this would only be targeting the reported memory, not the actual memory used for the test. I think people should treat device memory in a similar fashion to Data Saver: give a slightly different experience for 1GB or 2GB. So, making the (massive!) assumption that others are of the same mind, by turning this on, we'd be effectively downloading the smaller site for sites that use this even if that's not used by vast majority of visitors to the site. Lighthouse would therefore be under reporting performance issues, and missing out on highlighting opportunities to site owners for the full site load.

Would we want to enable the Data Saver flag for Lighthouse? No (I presume).

Though at the end of the day, I'm not sure it would make much of a difference either way to be honest as not convinced enough sites are optimising using this (think more should!). Then again, usage of this API does seem to be a lot higher than I thought it would be: https://chromestatus.com/metrics/feature/timeline/popularity/2121. But whether that's actually being used to optomise the site is a different question - it could just be analytics providers reporting this, or for tracking, rather than for optimising the site.

tunetheweb avatar May 20 '22 09:05 tunetheweb

Hi @tunetheweb, thanks for your feedback, that's really helpful!

Are your stats referring to one country in particular or global?

I know that India for example has a lower % of traffic on Devices with <=2GB compared to other countries, that's the reason why I believe there is a sizable amount of Chrome Mobile traffic still there and underperforming LCP.

I agree with you that DeviceMemory is not perfect, but compared to the others ad different entropies values it seems the one with stronger correlations with LCP (with INP too).

Data Saver is another big argument because since the Lite Mode deprecation its usage must have been decreased a lot, in Chrome 102 we will rely on the Android OS Data Saver signal only but I expect it to be was less useful than it was in the past unfortunately.

Do you have some suggestions of better signals to identify Low End Devices or Conditions for Developers to make their life easier to optimize content? Do you think Browser should come up with the new signal instead of rely on the existing inperfect ones?

Happy to chat around that.

gilbertococchi avatar May 20 '22 09:05 gilbertococchi

Are your stats referring to one country in particular or global?

Those stats were Mobile India Chrome users. Looking at all Chrome users it's about 21%. Again that is just one example, but I like using it as it's a global site - and I have access to the data ;-)

I know that India for example has a lower % of traffic on Devices with <=2GB compared to other countries

Why's that? I thought they'd be on cheaper devices, so higher % of traffic? But admittedly it does seem to be slightly higher globally.

Data Saver is another big argument because since the Lite Mode deprecation its usage must have been decreased a lot, in Chrome 102 we will rely on the Android OS Data Saver signal only but I expect it to be was less useful than it was in the past unfortunately.

Yes I see a big drop off in that usage with this change. Used to be 66% of Mobile India chrome users and now it's 18% :-( I'm curious why you don't think this will be less useful when Chrome 102 rolls out and it uses the OS setting? Would have thought that would be an easier way to set it? Or does Chrome prompt data save as part of it's install and not won't get that? CC: @addyosmani for opinions here.

Anyway, my argument is not that navigator.deviceMemory is not a good signal to use (it is!), my argument is against setting that as the default setting for Lighthouse.

What Lighthouse could do, is offer that as one of the optimisation suggestions for site not using it!

tunetheweb avatar May 20 '22 10:05 tunetheweb

Thanks @tunetheweb!

Why's that? I thought they'd be on cheaper devices, so higher % of traffic? But admittedly it does seem to be slightly higher globally.

I don't know it yet, it's in my TODO list to find out.

Data Saver:

I remember that Chrome Lite Mode included a prompt if I am not mistaken suggesting user to enable Lite Mode, so it's quite natural that usage was quite higher than relying on Android Data Saver Setting alone. That's a bit of a shame indeed...

Do you think that having the DeviceMemory value as customizable in Lighthouse would be useful? I personally would find it useful to emulate on DevTools, but only that's just me.

About the Optimisation suggestion that's a great idea, it would be great to draft some potential suggestion of an Opportunity for sites to use that.

gilbertococchi avatar May 20 '22 10:05 gilbertococchi