DeviceOrientation compass flips when you hold device vertical, unlike Firefox
Project Member Reported by joh...@chromium.org, Sep 17 2013
Version: Chrome Dev 31.0.1602.0 vs Firefox Beta 24.0 OS: Android 4.3 JWR66Y / Nexus 4 What steps will reproduce the problem? 1. Visit https://developer.mozilla.org/en-US/demos/detail/simple-compass/launch 2. Face North. 3. Hold the device vertical, facing you (such that the back of the device faces North). 4. Slightly tilt the device around a horizontal axis that goes through its center, such that it alternates between being angled slightly upwards and angled slightly downwards (while still predominantly facing you). What is the expected output? What do you see instead? In Firefox, tilting the device has no effect on the displayed compass direction. But in Chrome, whenever the device switches between angled up and down, the compass flips (the letters 'N' and 'S' switch places). It's possible this is caused by the invalid beta and gamma ranges mentioned in issue 244411 ? Either way, I don't know whether Chrome or Firefox is more spec compliant (or whether the spec even makes sense here); but we should either fix Chrome or get Mozilla to fix Firefox, before sites come to depend on incorrect behavior.
Sep 17 2013,
Sep 17 2013,
This is a result of the fact that in spherical polar coordinates, some orientations can be specified using multiple sets of values (this occurs when one axis is rotated to align with another axis). For example, (alpha, beta, gamma) values of (0, 90, 0) and (180, 90, 180) both describe the 'vertical facing north' orientation you mention. The particular case you're seeing is transition from (0, 85, 0) to (0, 95, 0), where the latter orientation can also be described as (180, 85, 180), which allows alpha to 'flip'. This particular case would indeed be avoided by fixing Chrome to correctly apply the value ranges. I _think_ fixing the ranges would solve the problem in general too, provided you apply the exclusive interval ends.
Nov 7 2013,
The ranges have now been fixed by https://codereview.chromium.org/40393002. There is still some increased noise around the 90 degrees pitch but that's probably due to sensor noise.
Nov 11 2013,
Apr 9 2014,
This bug happens just as OP described in Chrome 34 for Windows. Could you please port this fix to Chrome for Windows as well? Maybe it was fixed only in Android.
Sign in to add a comment