-
Notifications
You must be signed in to change notification settings - Fork 323
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
Initial orientation correction in hotfix (chrome m65) #310
Comments
Thanks for this! On my Pixel, it seems the orientation is off only by 10 degrees or so, you're seeing 45 degrees? I haven't tried this patch yet but I'll give this a go later |
I tried that patch and starting from all 3 orientations, after the 'snap' from receiving data, they're all facing away from the cube (Pixel, same Chrome m65 build). Without the patch there's a snap, but that's always the case going from default looking straight down <0,0,-1>, can see on a Canary build, but pretty accurate: With this patch, I'm looking in a different direction at the start (different depending on initial orientation): |
This is interesting, I also tried out the patch on a older phone I have lying around (a LG G3). When the patch is applied, the cube is no longer centered. To summarize, I have tried 2 phones: LG G3 - No patch is needed I'm thinking this may have something to do with the initial deviceorientation reading? I haven't had time to setup a test case to compare the 2 phones I have yet. Any ideas? |
There are some devices that have different directions for the devicemotion event (see this line of code), but if this is only happening in Chrome m65 with this patch, that could mean the devicemotion (what polyfill usually uses) rotation and the deviceorientation (what the m65 fallback uses) rotation are possibly different units -- does the MotoZ work fine with Canary (and the latest polyfill)? Or Firefox? |
So just tried it on firefox and the behavior is the same as Chrome M65. I need to apply the patch to have the start orientation center properly. So this may be something specific to the MotoZ? Incidentally, the MotoZ does not seem to suffer from the low refresh rate, but the LG G3 does. I'll check out the code and maybe setup a test to examine the numbers coming from deviceorientation and devicemotion from those phones. |
FWIW, I've seen the refresh rate issue sometimes work just fine in Chrome m65 and other time 10hz on the same device, and can recreate outside the polyfill (demo). I haven't tried the MotoZ but thoght I've heard people having used it. It sounds like all A-Frame/Polyfill experiences wouldn't work correctly if one of the axes are different than expected. You can enable Generic Sensors API on Chrome m63+, and the polyfill will attempt to use the Sensor API, which doesn't require the deviceorientation workarounds for m65, and may have the correct coordinate system (you may have to check |
This is great! I'll do some investigation later on and report back. Thanks for all your help on this! |
@env3d thanks for your research and reports! Looking forward to hearing what you find |
Ok, so I ran a couple of tests, with interesting results. All tests are conducted using chrome m65 on Android. I have 3 phones: a MotoZ Play, a LG G3, and an Acer Zest Plus. On the first test, I attach a deviceorientation event and print out the alpha, beta, and gamma values for each. I have the following results: As can be seen, the alpha value reported (which translates to the 'look' orientation, rotateY if you will of the head), is all different on all 3 phones. For the second test, I have 2 event handlers, top is deviceorientation and bottom is devicemotion. Noticed for 2 phones (motoZ and LG G3), they are showing null for all values, while the Acer has nulls on the deviceorientation but starting reporting on the devicemotion, but only in the acceleration with gravity field. Hopefully this will give us more insights into what is happening. Thanks |
More more thing to note on the MotoZ. When I downgrade the browser (m57), all fields in the devcemotion api start reporting proper values. |
devicemotion not reporting |
Ok, I tried the following patch. Basically I recorded the initial reported degree in deviceorientation and use it as an offset to return the position to 0 degrees. I also need to adjust the getOrientation angle when in landscape. This code should only affect the fallback path. Do you see any issues with this approach?
|
@env3d does that work on all the devices you have? Getting the initial alpha value as a base scares me a bit since it could be rotated in any direction upon load, but you're correct in that this keeps it scoped within the m65 fallback |
@jsantell, yes it works for all my devices running m65. I totally understand the apprehension but it seems to be the best compromise at this point, at least for my use case. |
Is this still an issue in Chrome m66+? |
This is an issue for me (described here). Some way to apply a "global" offset would be ideal... // crude example
alpha = ((alpha || 0) * Math.PI / 180) + window.ALPHA_OFFSET; |
@homerjam as this is a device specific issue, I'm not sure how to fix it on this end. The polyfill projects (cardboard-vr-display, webvr-polyfill, webxr-polyfill) all polyfill the WebVR/WebXR APIs where ultimately some pose as position/quaternion, or matrix is returned. At that point, you could manipulate the pose anyway you'd like. As a rough/untested example using THREE: // Rotate orientation by 90 degrees on the Y
const ROTATION_FIX = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI/2);
const q = new THREE.Quaternion().fromArray(vrFrameData.orientation);
if (DEVICE_NEEDS_OFFSET) {
q.multiply(ROTATION_FIX);
} If there's not a consistent rule for what sensors are incorrect/unstandard, it'll be hard to land this in the polyfill. If altering the final quaternion is sufficient (e.g., you don't need the individual XYZ values reported in |
Description:
In Chrome m65, after the latest hotfix patch, the starting orientation is off by 45 degrees. To reproduce, simply visit the example page https://immersive-web.github.io/webvr-polyfill/examples/ with an affected browser. You will see the cube flashed and then the orientation is turned at 45 degree angle.
I patched the cardboard-vr-display with the following, which seems to fix the issue:
Additional Information:
The text was updated successfully, but these errors were encountered: