Bug 199084
Summary: | Feature: Implement Device Memory API | ||
---|---|---|---|
Product: | WebKit | Reporter: | Thomas Steiner <tomac> |
Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | mjs, nicolas, rniwa, simon.fraser, webkit-bug-importer, webkit |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 12 | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Thomas Steiner
The Device Memory API allows an application to reason about the available RAM it can use.
- Spec: https://www.w3.org/TR/device-memory/
- Remarks on limiting the fingerprint surface through coarse reporting: https://w3c.github.io/device-memory/#computing-device-memory-value
This API is used by Google Search as one of the signals to determine whether a service worker is being offered: https://web.dev/google-search-sw/#service-worker-overhead.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/51967753>
Maciej Stachowiak
Thanks for the bug report! Does Google search need the Client Hint form of this, or is the API sufficient? The post seems to mention that the only use is to make a rough cut of "low end device" vs "high end device" based on >= 2 GB. It's a shame that the API exposes much more than that. Maybe we could expose 2GB as a fixed value for macOS, iOS and iPadOS devices, since all currently supported models would likely meet the true "high end" criteria.
Thomas Steiner
(In reply to Maciej Stachowiak from comment #2)
> Thanks for the bug report! Does Google search need the Client Hint form of
> this, or is the API sufficient? The post seems to mention that the only use
> is to make a rough cut of "low end device" vs "high end device" based on >=
> 2 GB. It's a shame that the API exposes much more than that. Maybe we could
> expose 2GB as a fixed value for macOS, iOS and iPadOS devices, since all
> currently supported models would likely meet the true "high end" criteria.
The JavaScript API. The current (minified) code uses this:
```
function u(a) {
var b = window.navigator;
if (!b)
return !1;
b = b.deviceMemory;
return a.dm && (b < Number(a.dmn) || 0 != Number(a.dmx) && b >= a.dmx) ? !1 : !0
}
```
Capping at (or fixed reporting of) 2GB seems fine (for all iOS/iPadOS devices); actually, Chrome caps at 8GB (https://crbug.com/787473).
Both Chrome's as well as potentially your threshold probably need to be re-evaluated once 2GB of RAM means one owns a "low end" device.