Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
lib: add navigator.deviceMemory#50229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
nodejs-github-bot commented Oct 18, 2023
Review requested:
|
0e2a9ed to edb63e3Comparesrc/node_os.cc Outdated
| // Max-limit the reported value to 8GB to reduce fingerprintability of | ||
| // high-spec machines. | ||
| if (approximated_device_memory_gb_ > 8) approximated_device_memory_gb_ = 8.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think finger-printability is an issue on Node, but I'm not sure about this, so raising this comment just to get some feedback.
At least on spec, this is just a recommendation: https://www.w3.org/TR/device-memory/#computing-device-memory-value
If we do not limit the amount of memory, it will have the same behavior of
getTotalMemory, so I don't know if worth to have this function without this behavior of limiting the amount of memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fingerprinting is not a concern in Node.js. Also, even if it was, why not use os.totalmem()/1024**3 to get the value?
UzlopakOct 18, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just ensured that the code is in sync with chrome and according to the documentation/spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Max-limit the reported value to 8GB to reduce fingerprintability of | |
| // high-spec machines. | |
| if (approximated_device_memory_gb_ > 8) approximated_device_memory_gb_ = 8.0; |
I prefer we remove this check
tniessen commented Oct 18, 2023
|
aduh95 commented Oct 18, 2023
+1 to what Tobias said, and also I'd be -1 on introducing properties to our implementation of |
GeoffreyBooth commented Oct 26, 2023
Let’s please ping @nodejs/web-standards for all issues and PRs related to |
Uh oh!
There was an error while loading. Please reload this page.
jasnell commented Oct 28, 2023
Whether or not folks think |
Uzlopak commented Oct 29, 2023
To be honest, I think nodejs should consider itself as the "brother" of Chrome because both use v8. Bun uses the same engine as Safari, so their behavior is closer than it is to Chrome and nodejs. Thats why I also directly took the code from the chromium sourcecode, as I would prefer function parity with Chrome. |
tniessen commented Oct 29, 2023
Why should the choice of using V8 imply anything about feature parity between Node.js and Chrome? This API is not part of V8, not part of the JS language specification, and currently not even part of the HTML specification. Deno, Cloudflare Workers, etc. are also based on V8, and none of them have implemented this API as far as I know. |
targos left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation is unnecessarily complex
benjamingr left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the fingerprinting check removed
0aa3941 to 169c7d0CompareUzlopak commented Oct 30, 2023
@targos @benjamingr @nodejs/web-standards |
tniessen left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should land, for the reasons outlined in #50229 (comment).
I also don't understand @Uzlopak's argument that "nodejs should consider itself as the "brother" of Chrome because both use v8" and that one might thus "prefer function parity with Chrome."
169c7d0 to 0a3899cCompare0a3899c to 6c99feeCompareUzlopak commented Oct 30, 2023
My thoughts were, as I stated before, that navigator.deviceMemory is a feature in Chrome. Just want to remind you that implementing the navigator global in node is about browser compatibility. Also this feature has a market share of 75% (chrome 63%, edge 5%, opera 3%, Samsung Internet 2%, etc..). And just because Firefox and Safari didnt implement it, doesnt result in the conclusion that we should not implement it - same as Chrome supporting this feature is not an argument for you. A good argument against this feature is, that it is still a draft since 2018. Maybe there is a rule already covering these cases navigator.deviceMemory is also used in few github projects https://github.com/search?q=navigator.deviceMemory&type=code So we could agree on not implementing a draft spec. Or we can agree on implemeting something which is supported by the most used browser. I personally dont have a strong opinion on this feature. I just saw a low hanging fruit, so I picked it. |
panva left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to remind you that implementing the navigator global in node is about browser compatibility
I would argue the point is interoperability, not compatibility.
Since this is a) draft, b) Chrome-only property and so c) one already has to work around its lack of presence in other browsers and runtimes if they wish to have interoperable code, I don't think we should be landing this.
Uzlopak commented Oct 31, 2023
Allrighty. :) |
Shamelessly copied approximation logic from chromium
https://github.com/chromium/chromium/blob/main/third_party/blink/common/device_memory/approximated_device_memory.cc