WebVR: getVRDisplays fails in iframe, breaks "Under Neon Lights" |
||||||||||
Issue descriptionChrome Version: Dev 62.0.3202.12 OS: Android What steps will reproduce the problem? (1) Enable chrome://flags#enable-webvr and chrome://flags#enable-gamepad-extensions (2) Open https://with.in/watch/under-neon-lights/ What is the expected result? "Start in VR" button should be active, and clicking it should enter VR What happens instead? "Start in VR" button is dimmed and does not work. Web console shows: within-player.min.js:1 THREE.VRControls: Unable to get VR Displays Uncaught (in promise) DOMException: The object is no longer associated with a document. This is reproducible in Inspector: Open Elements view, expand and click the iframe document: body div id="content" div id="fold" iframe #document On console, run: navigator.getVRDisplays().then(function() { console.log(arguments); }) This produces the same error: Uncaught (in promise) DOMException: The object is no longer associated with a document. Promise rejected (async) (anonymous) @ VM779:1 Clicking on the toplevel "body" and re-running the command works as expected and returns a 1-element vrDisplay array.
,
Sep 12 2017
,
Sep 12 2017
The iframe has a different origin than the top-level document. Starting in M62, this must be enabled via Feature Policy. For example, adding the attribute allow="vr" to childe iframes.
,
Sep 12 2017
I filed issue 764447 to replace the exception message with one that is more helpful for this case.
,
Sep 12 2017
,
Sep 27 2017
For debugging on our end.., is Canary running 62 on Chrome for Android?
,
Sep 27 2017
Dev and Canary are on M63 now, but the behavior should be the same. Beta is on M62. You can check the (rough) current status at https://omahaproxy.appspot.com/.
,
Sep 27 2017
Awesome, thanks!
,
Oct 3 2017
It looks like on non Chrome 62+ web browsers allow="vr" throws an error. "Error while parsing the 'allow' attribute: 'vr' is an invalid feature name." How do we, as developers, handle both cases?
,
Oct 3 2017
+iclelland Is that Chrome <=61 or other browsers? If others, which ones?
,
Oct 3 2017
Looks like Chrome <= 61 and Safari (I'm on 11). Checked on FF and Microsoft Edge as well.
,
Oct 3 2017
Sorry to be more explicit. Errors were thrown for Chrome <= 61 and Safari. The latest FF and Edge stable didn't throw any errors.
,
Oct 3 2017
That makes sense; FF and edge won't recognize the allow attribute at all. Chrome should support it without any issues (and the "Error while parsing" should really just be a console warning, rather than an actual error). Chrome 62+ should support the 'vr' feature, and use it to allow 3rd-party origins to use WebVR in iframes. Chrome <= 61 didn't use feature policy at all, and I don't think they supported 3rd-party origins in frames. (Or possibly didn't support WebVR in frames at all) +bshe who should know for sure.
,
Oct 3 2017
Thanks, iclelland. Prior to M62, WebVR could be use in cross-origin iframes. For the new WebVR Origin Trial started in M62, such use requires Feature Policy. So as long as this is just a console warning, M61 should work just fine. jono, is this causing problems in Chrome 61 or were you just concerned about the warning?
,
Oct 4 2017
Cool, thanks for the clarification. When I apply the attribute in JavaScript like
var iframe = document.createElement("div");
iframe.setAttribute("allow", "vr");
is a breaking error in Chrome 61 and below. It's not a dealbreaker but we'll just have to do some additional handling so it doesn't break the thread.
,
Oct 4 2017
Do you get an error when you run those two lines? I just ran them in Chrome 60 and 61 without any issues.
,
Oct 4 2017
Yes, this is the error I get: "Error while parsing the 'allow' attribute: 'vr' is an invalid feature name."
,
Oct 4 2017
The code in #15 is incorrect. It should be s/div/iframe/.
The following will show a successful "vr" call in M62+ and "foo" always reporting an invalid name. However, these are just console messages, and the script continues to execute.
var iframe = document.createElement("iframe");
iframe.setAttribute("allow", "vr");
iframe.setAttribute("allow", "foo");
console.log("finished");
The console error message in #17 was replaced with a different console warning message ("Unrecognized feature: 'foo'.") in https://chromium-review.googlesource.com/c/chromium/src/+/620948. Neither was an exception, so they can be safely ignored.
,
Oct 4 2017
Ah, sorry about that. I meant to put document.createElement('iframe'). Div is just second nature for me.., heh.
The blocking error I actually get is from jQuery because we're setting the attribute through that framework. I'll set it directly on the DOM element via setAttribute.
Thanks!
,
Oct 4 2017
This patch is staged on the Within website and should hit later today. I'll report back when it's propagated.
,
Oct 6 2017
The fix is live, and VR works again in Canary. Thank you, jono@. Out of curiosity, how were you setting the attribute before that caused a blocking error? We'd like to understand any potential issues with feature policy.
,
Oct 6 2017
verified this works with 63.0.3233.0
,
Oct 6 2017
,
Oct 6 2017
Regarding Comment 21: the blocking error was coming from jQuery because I
was setting the attribute through a selector. e.g:
$('iframe').attr('allow', 'vr'); I got around that by not relying on jQuery
and used setAttribute directly.
,
Oct 6 2017
,
Oct 7 2017
Thank you guys for the awesome WebVR API!
,
Oct 7 2017
jono -- If you can come up with a minimal test case where the allow attribute is broken with jQuery, could you file another bug for it? I'd love to look into that, and see if there's still something strange going on there. Thanks!
,
Jul 4
|
||||||||||
►
Sign in to add a comment |
||||||||||
Comment 1 by klausw@chromium.org
, Sep 12 2017