Closed takahirox closed 1 week ago
are we not definitely navigator.xr in the shim? Didn't something change to navigator.XR or something? (fuzzy memory here)
I need to investigate but I guess WebXR API detection with navigator.xr is somehow done before loading shim. When is shim exactly loaded?
That's not possible or shouldn't be. The shim is loaded using the WkWebView feature that preloads some JS before loading the page. Are you sure the shim that's bundled with xcode is actually setting .xr and not something else like .XR?
Yes, navigator.xr.
I'll investigate closer today.
I found an interesting fact.
They are the same Three.js AR paint example. Our WebXR API is recognized in 2. while it isn't in 1.
The difference is whether using <iframe>. 2. is the WebXR AP paint example itself and 1. opens 2. in <iframe>.
I set break point in the example in 1 and realized that navigator.xr
seems to be never defined in <iframe>.
So my speculation is the shim has no effect to a page loaded in <iframe>. Can this likely happen from the view of preloading with WkWebView?
Yes, that could definitely be the case.
Is webxr supposed to work in iFrames? A subset of it? Seems dangerous.
I seem to recall us discussing webxr in iframes about a year ago. I think we agreed to have some property set on the iframe to enable it.
From Three.js html code
<iframe id="viewer" name="viewer" allowfullscreen allowvr onmousewheel="">
It has allowvr
(not "xr" tho), is this what @joshmarinacci pointed out?
And, I'm not familiar with WebKit at all. Is it technically possible to preload the shim even in <iframe>?
It has
allowvr
(not "xr" tho), is this what @joshmarinacci pointed out?
Probably.
And, I'm not familiar with WebKit at all. Is it technically possible to preload the shim even in
I think so but I can't remember, nor remember how.
I seem to recall us discussing webxr in iframes about a year ago. I think we agreed to have some property set on the iframe to enable it.
WebXR uses feature policy to enable or disable it in iframes:
https://immersive-web.github.io/webxr/#feature-policy
In particular, “xr-spatial-tracking”.
Thanks @kearwood. My understanding is if xr-spatial-tracking
attribute isn't specified navigator.xr
should be defined but isSessionSupported('immersive-vr/ar')
should return false and requestSession('immersive-vr/ar')
should fail, correct?
If it's correct, we need to request firefox-ios to load the shim even in iframe.
I guess we can't know iframe attribute from inside of iframe. Then we add another shim for xr-spatial-tracking
disabled case and firefox-ios preloads an appropriate one depending on iframe attribute?
Let's leave this open for now and investigate
On Fri, Mar 27, 2020 at 1:37 PM Takahiro notifications@github.com wrote:
Thanks @kearwood https://github.com/kearwood. My understanding is if xr-spatial-tracking attribute isn't specified navigator.xr should be defined but isSessionSupported('immersive-vr/ar') should return false and requestSession('immersive-vr/ar') should fail, correct?
If it's correct, we need to request firefox-ios to load the shim even in iframe.
I guess we can't know iframe attribute from inside of iframe. Then we add another shim for xr-spatial-tracking disabled case and firefox-ios preloads an appropriate one depending on iframe attribute?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MozillaReality/webxr-ios-js/issues/80#issuecomment-605145691, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKJJ7P3L6LL4XBTOKC3X7TRJTP57ANCNFSM4LTC3ZSQ .
Let's ask Firefox iOS team about how we should do, and update if needed later.
I had a comment from firefox-ios team
Look for where your script is injected using WKUserScript constructor. That takes an argument forMainFrameOnly , a boolean, set that to false.
I did it and our WebXR API is recognized even in a web page in iframe. But I face another error.
ReferenceError: Can't find variable: arkitCallback_initAR_1588968895079_942515975864898 Global Code -- Script Element 3:1
I guess the bridge between a web page in iframe and arkit doesn't work. I'm not familiar with the bridge yet but does my guess sound correct? And anyone knows how to resolve?
Ah, of course. iFrames can't talk to the native app. It can only talk to the parent of the frame (the page), I believe.
If we want to enable iFrames we have to do this in the shim:
This will be a non-trivial amount of work; straightforward I think, but still not trivial.
We'll also need the page to keep track of multiple iFrames (e.g., only one can create an immersive session at a time, and we need to relay the data to the right one).
Three.js WebXR AR examples don't recognize our AR capability. When the application starts up Three.js
ARButton
checksnavigator.xr
but at that time it seemsnavigator.xr
isn't defined yet.Android Chrome (native WebXR API) and WebXR Emulator Extension work fine. So maybe there is something problem in our side.