Skip to content
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

Anchor fails to create in some cases #5391

Open
kfarr opened this issue Nov 20, 2023 · 6 comments
Open

Anchor fails to create in some cases #5391

kfarr opened this issue Nov 20, 2023 · 6 comments

Comments

@kfarr
Copy link
Contributor

kfarr commented Nov 20, 2023

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:

  • delete local storage of the device (clear all saved history, etc. from the browser and/or remote debug inspector)

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:

  • During testing of a new app I put anchored component on different parts of a scene including a-scene and a-entity components. Some had an id (as required in the docs) and some did not.
  • I had been doing all of this testing in 1 room at home. Then I moved to the office to do more testing after kids are in bed and setup a new room configuration and then noticed that the anchors were not persisting.
  • I used remote debugging to see the console error and remembered what happened at the hackathon -- I think I eventually hit the 8 unique anchor limit

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

  • add an anchor to a new unique entity id in an existing or new a-frame scene, once per session (per browser load / close)
  • upon 9th iteration thereof, you should see the console error

Instead:

  • as a user developing for the webxr persistent anchors using a-frame, I expect anchors to be created and to persist as defined declaratively via html

How to achieve this? A few options

  • Application change -- when a user creates a new anchor delete all others -- this is not desirable, there may be other valid global anchors used by other webxr applications / other saved room point cloud configurations
  • Library change -- flush all anchors when exceed 8 - how to know when it exceeds 8? Is current anchor usage # exposed in the API? Answer: See XRSession.persistentAnchors
  • Library change -- flush oldest anchor when exceed 8 - how to know which is oldest and when it exceeds 8?
  • API change -- allow greater than 8 unique anchors

Environment

Note / research:

  • Is the anchor expensive? When doing logging of anchor quaternion, it seems to update frequently indicating that each frame the anchor slightly adjusts from scene, therefore maybe each anchor is expensive so therefore limit of 8
  • Should it be throttled? how often should the anchor update pose?
@kfarr
Copy link
Contributor Author

kfarr commented Nov 20, 2023

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
Copy link

docEdub commented Nov 20, 2023

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
Copy link
Contributor

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
Copy link
Contributor Author

kfarr commented Nov 20, 2023

@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
Copy link
Member

dmarcos commented Nov 20, 2023

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
Copy link
Contributor Author

kfarr commented Nov 29, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants