Last Comment Bug 1124127 - Round Off Navigator Battery Level on Linux
: Round Off Navigator Battery Level on Linux
Status: RESOLVED FIXED
: privacy
Product: Core
Classification: Components
Component: Hardware Abstraction Layer (HAL) (show other bugs)
: 35 Branch
: x86 Linux
-- normal (vote)
: mozilla38
Assigned To: :Gijs
:
: Gabriele Svelto [:gsvelto]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-21 02:46 PST by Lukasz
Modified: 2015-08-04 08:24 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
round power percentage to whole number before passing on, (1.74 KB, patch)
2015-01-21 06:07 PST, :Gijs
gsvelto: review+
Details | Diff | Splinter Review

Description User image Lukasz 2015-01-21 02:46:51 PST
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.
Comment 1 User image :Gijs 2015-01-21 06:04:57 PST
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).
Comment 2 User image :Gijs 2015-01-21 06:07:49 PST
Created attachment 8552454 [details] [diff] [review]
round power percentage to whole number before passing on,

Mounir, does this make sense? You seem to have written most of this.
Comment 3 User image :Gijs 2015-01-28 03:57:37 PST
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?
Comment 4 User image Gabriele Svelto [:gsvelto] 2015-01-28 05:29:15 PST
(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 5 User image Gabriele Svelto [:gsvelto] 2015-01-28 05:34:13 PST
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.
Comment 7 User image Ryan VanderMeulen [:RyanVM] 2015-01-28 11:40:16 PST
https://hg.mozilla.org/mozilla-central/rev/7d8d4ff84ddb

Note You need to log in before you can comment on or make changes to this bug.