Closed Bug 1124127 Opened 9 years ago Closed 9 years ago
Round Off Navigator Battery Level on Linux
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0 Build ID: 20150112203157 Steps to reproduce: On Linux, open the developer console and check navigator.battery.level Actual results: The battery level is reported with 16 decimal places (e.g. 0.1600730371272063) Expected results: The battery level should be rounded to two decimal places (e.g. 0.16) as it’s on Windows and Mac. On Mac and Windows, Firefox reports the battery level with 2 decimal places (e.g. 0.16). On Linux, Firefox reads the battery level from D-Bus, and make it available to Web platform without rounding it off (e.g. 0.1600730371272063). By using the high-precision battery level readouts from the Battery API (navigator.battery.level), one can detect the battery capacity and use it as a short-term tracking identifier. This is done by solving a linear system of equations and exploiting floating point quirks, thanks to the double precision reading exposed to the Web platform. The battery capacity may not be a fingerprinting method with severe consequences, since it’s very short-lived -- the battery capacity may be updated when the battery is fully charged. But it’s rather unexpected, the extra precision serves no purpose, and there is a mismatch between Firefox’s behavior on Linux vs. Mac & Win.
FWIW, I can't reproduce this; I guess the number reported by dbus is hardware/kernel/whatever-dependent (I'm testing in a vmware fusion vm on a mac).
Component: DOM → Hardware Abstraction Layer (HAL)
Priority: P1 → --
Mounir, does this make sense? You seem to have written most of this.
Attachment #8552454 - Flags: review?(mounir)
Assignee: nobody → gijskruitbosch+bugs
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Comment on attachment 8552454 [details] [diff] [review] round power percentage to whole number before passing on, I hear Mounir left. Gabriele, can you review this or find someone who can?
Attachment #8552454 - Flags: review?(mounir) → review?(gsvelto)
(In reply to :Gijs Kruitbosch from comment #3) > I hear Mounir left. Gabriele, can you review this or find someone who can? Sure, for reviews of HAL patches it's either :dhylands who is the component owner or me, the sole peer ATM.
Comment on attachment 8552454 [details] [diff] [review] round power percentage to whole number before passing on, Review of attachment 8552454 [details] [diff] [review]: ----------------------------------------------------------------- LGTM with a minuscule nit. ::: hal/linux/UPowerClient.cpp @@ +431,2 @@ > /* > * The battery level might be very close to 100% (like 99.xxxx%) without nit: This comment suggests that a reading might have four decimal places, better to update it too to avoid confusion.
Attachment #8552454 - Flags: review?(gsvelto) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.