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

Deleted Anchors still present in frame.trackedAnchors for that frame #66

Open
AdaRoseCannon opened this issue Aug 5, 2021 · 4 comments

Comments

@AdaRoseCannon
Copy link
Member

This is in Samsung Internet Beta (Chromium M90) i'm not sure if this is a spec issue or an implementation issue but is something I am encountering.

i.e.

anchor.delete()

trackedAnchors.forEach(function (anchor) {
  // Uncaught DOMException: Failed to read the 'anchorSpace' property from 'XRAnchor': Unable to access anchor properties, the anchor was already deleted.
  const anchorPose = frame.getPose(anchor.anchorSpace, refSpace);
});
@bialpio
Copy link
Contributor

bialpio commented Aug 5, 2021

Looks like a spec issue, the algorithm for XRAnchor.delete() only modifies the session's set of tracked anchors, which would only affect subsequent frames.

The fix I think would be to adjust XRAnchor to also hold an associated XRFrame - this association would need to be updated every time an anchor is added to XRFrame's set of tracked anchors (step 3.3 in update anchors algorithm), & modify the frame's set of tracked anchors when an anchor gets deleted.

Note that the change would break the current behavior. Additionally, we'll potentially be removing anchors from a collection when iterating over that collection (e.g. if the app deletes some anchors in the .forEach()) - I think it's OK to do, but I'm not certain. We could also stick to the current behavior and add a note to the spec that an application should be careful about not using anchors that have been deleted, & provide this snippet as an example to watch out for.

@AdaRoseCannon
Copy link
Member Author

AdaRoseCannon commented Aug 5, 2021 via email

@AdaRoseCannon
Copy link
Member Author

Adding an anchor.isDeleted property so it's possible to check on the fly isn't as neat but at least it would be better than catching and ignoring an error and wouldn't break existing implementations.

@bialpio
Copy link
Contributor

bialpio commented Aug 10, 2021

From today's meeting: Another alternative would be to no longer throw exceptions on property access for anchors that have been deleted, but instead have the returned XRSpace be no longer locatable. This'd be my preferred choice I think, but note the following:

let anchor = ...; // some anchor
let pose_1 = frame.getPose(anchor.anchorSpace, refSpace); // returns non-null
anchor.delete();
let pose_2 = frame.getPose(anchor.anchorSpace, refSpace); // returns null

I can see this as something that may not be expected by the app developers. If others think it's actually not something that would raise their eyebrows, let's go with this approach.

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

2 participants