mozilla-mobile / webxr-ios

An iOS app for testing WebXR
Mozilla Public License 2.0
211 stars 42 forks source link

Is it possible to leave ARKit active between pages? #53

Closed blairmacintyre closed 6 years ago

blairmacintyre commented 6 years ago

The need to reinitialize ARKit each time we go to a page is frustrating.

Would it be possible to leave it running? We could

blairmacintyre commented 6 years ago

I've asked @che1404 about this, since it's so frustrating to have to completely reinitialize ARKit on each page. Essentially, I asked him for exactly the same things, with the same suggestions you have (timeout to shutdown, delete page-created anchors, and so forth). We're looking at it, there have just been other things higher priority (and, we've been looking at iOS 11.3 beta and ARKit 1.5).

(If there are any iOS devs watching, a PR for something like this (on the develop branch, of course), would be whole wholeheartedly welcomed.)

blairmacintyre commented 6 years ago

Additional question: since we have a random string id for each anchor, we should think about implementing some kind of same-domain policy to control when anchors are destroyed. Specifically, if an AR page is the same domain as the previous AR page, we should not destroy the anchors that page created.

We can pass them in, with their ID's, and if they app knows what to look for (i.e., a multi-page app saved and shared the id's of anchors, perhaps in a cookie or some app-specific mechanism) it can find anchors created by the previous page.

Need to talk to the security folks about this, tho.

che1404 commented 6 years ago

@blairmacintyre I think we could just use the ARKit ARSession API to "pause" the session. That way, we wouldn't get any updates until we call "run" again, and we'll keep all the anchors.

More on this: https://developer.apple.com/documentation/arkit/arsession/2865619-pause

blairmacintyre commented 6 years ago

I guess the question is, will pausing it for a long time cause ARKit to lose track of where it is, etc. Does it really stop tracking?

If pausing causes it to get lost and need to be initialized, that might not be as useful. HOWEVER, if pausing works for a short time (a minute or so) or works as long as you don't move too far, that would be fine.

che1404 commented 6 years ago

@blairmacintyre I will do quick demo to test this and will post here the results.

blairmacintyre commented 6 years ago

done