aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.42k stars 3.91k forks source link

Anchor fails to create in some cases #5391

Open kfarr opened 7 months ago

kfarr commented 7 months ago

Description: In some cases, attempting to create an anchor will fail which results in the desired anchor points not persisting across sessions despite setting anchored="persistent: true" on the entity.

In the case where the anchor is not created, there is a console error:

Uncaught (in promise) DOMException: Failed to execute 'restorePersistentAnchor' on 'XRSession': Anchor creation failed.

Workaround:

In a vanilla three.js project we also encountered this error, and the answer from quest browser team was:

The reason this is happening is probably because you are exceeding the 8 anchor limit on your device, and yes, clearing out application storage will remove those anchors

I did some digging and notice that there is already an attempt to delete an anchor if a new one is being created in its place https://github.com/aframevr/aframe/blob/v1.5.0/src/components/anchored.js#L76

However in this case I think that while developing new scenes and testing different entities on which to attach anchors, a user can easily exceed the 8 anchor limit.

Here is the scenario that I think happened in my testing:

Steps to reproduce (not verified yet, anyone up for it?):

Instead:

How to achieve this? A few options

Environment

Note / research:

kfarr commented 7 months ago

Maybe there should be a check here to see if there are already 8 anchors? https://github.com/aframevr/aframe/blob/v1.5.0/src/components/anchored.js#L94C20-L94C25

docEdub commented 7 months ago

Maybe there should be a check here to see if there are already 8 anchors? https://github.com/aframevr/aframe/blob/v1.5.0/src/components/anchored.js#L94C20-L94C25

Is the 8 anchor max device-specific, or do all devices that support anchors have the same limit?

vincentfretin commented 7 months ago

Where do you need more than 8 anchors? Just having one anchor per room is enough, all the entities you add should be relative to the anchor. In aframe that should just be children of an entity where you added an anchor to it I guess. Do you have more than 8 rooms in your house or venue?

From Rik Cabanier (Meta) we limit you to 8 persistent anchors per origin. We can raise this in the future but each area should have only 1 anchor and you place content relative to that

kfarr commented 7 months ago

@vincentfretin the issue is not that a user intends to have 8 anchors, it is that through a variety of steps during the course of development and then subsequent usage a user is likely to reach this limit unintentionally without understanding how and not have a clear recourse to resolve given the cryptic error message.

The deletion mechanism in line 76 https://github.com/aframevr/aframe/blob/v1.5.0/src/components/anchored.js#L76 assumes that a prior anchor of the same ID existed that it is deleting, it doesn't cover the case where other anchors have been created and not deleted in prior sessions.

I'm simply suggesting that we implement slightly better error handling on the a-frame side such that when an a-frame developer adds anchored: persistent: true to an entity that it will reliably place that anchor (including deleting old anchors that may have been created outside of this immediate session) if it will exceed the 8 anchor limit.

dmarcos commented 7 months ago

Also consider that persistent anchors are per domain. If you deploy different pages on same domain you might get to the 8 anchors inadvertently. Even if the logic of each page correctly considers the 8 limit.

kfarr commented 7 months ago

Adding update, I keep running into this issue on a regular basis. I often encounter it after using the headset again after a few days off, which is odd since it would have already had a valid anchor from before but it is lost for some reason. Is there expiration for anchors?