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

fix anchor sample: anchor creation timing #202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

felixtrz
Copy link
Contributor

@felixtrz felixtrz commented Dec 5, 2024

According to https://immersive-web.github.io/anchors/#anchor-updates
when an anchor is created, during the next "update anchor" task:

  1. Anchor is added to the trackedAnchors set on the frame
  2. The anchor creation promise will be resolved, and the entry removed from the list of new anchors in session

This sample makes the assumption that when iterate through the trackedAnchors on every frame, the anchor context already exists. This is incorrect.

the context is created in addAnchoredObjectToScene, which runs after the anchor creation promise resolves (not immediately, but executed asynchronously in the next microtask queue). It is possible that when iterating through the trackedAnchors on frame, the addAnchoredObjectToScene has not executed yet, and the context object won't exist, causing the logic to crash.

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

Successfully merging this pull request may close these issues.

1 participant