aframevr / aframevr/aframe

Anchor fails to create in some cases

Open
#5,391 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
17.6k
Forks
4.4k
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/components/anchored.js at the linked deletion logic and review the WebXR persistent anchor handling, especially XRSession.persistentAnchors. Reproduce the failure on an Oculus Quest 3 by creating anchors for distinct entity IDs across sessions until the reported limit is reached, then inspect the console error. Done should include a confirmed handling strategy and verified anchor behavior without the reported creation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.