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

WebXR init accessing trackedAnchors causes error: "TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))" #5843

Closed
benferns opened this issue Nov 23, 2023 · 3 comments · Fixed by #5879

Comments

@benferns
Copy link

This issue tracker is only for bug reports and feature requests. For general support/help, visit https://forum.playcanvas.com

For bug reports, include:

Description

On trying to start WebXR on non-Android platforms, the error "TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))", or "undefined is not an object" occurs on the same line. Context below:

Screenshot 2023-11-22 at 13 14 09

So far I have confirmed this issue on my own iOS WebXR implementation ( https://launch.variant3d.com/docs ) and in WebXR emulator extensions. It appears not to happen on Android Chrome.

The change is recent (within the last few weeks) as I've just had a bunch of support requests pop-up this week around the issue.

Steps to Reproduce

The fastest path to reproducing is to download a webxr emulator like https://chrome.google.com/webstore/detail/webxr-api-emulator/mjddjgeghkdijejnciaefnkjmkafnnje then follow the below:

  1. Create a blank WebXR starter project from the template
  2. Publish the build with the latest version (1.66.3)
  3. Hit the button to enter AR and observe the console errors
  4. Delete the published build and change to previous minor version, or visit https://playcanv.as/p/XxDyZ9ZL/ (minor version pinned to 1.65.5)
  5. Observe no errors in console

I can provide Variant Launch test projects/accounts if helpful, but since the same error shows across other implementations I think the underlying issue will be the same.

@Maksims
Copy link
Collaborator

Maksims commented Nov 23, 2023

Hi @benferns, thank you for the report. Do you have any reproduction using actual devices (not with emulators)? I have not been able to reproduce an issue. Based on the specs trackedAnchors should exist on XRFrame if platform supports XRAnchor: https://immersive-web.github.io/anchors/

I have tried using link to the project you've provided on Windows Chrome, but the extension you've provided does not seem to implement WebXR AR polyfill.

Can you verify there are no other extensions running in your browser that might implement the WebXR polyfill?

@benferns
Copy link
Author

benferns commented Dec 5, 2023

Hi Maksims - just to update this, I've resolved the issue on my end by making anchors non opt-in for users of my SDK (previously it needed to be explicitly enabled). I might be able to shed some more light on the underlying cause though:

Here's the console logs from the immersive web anchors example, using the mozilla emulator to mimic a non-anchor-supporting client - you can see anchors are requested, and the session denied as they aren't supported.
image

On the playcanvas repro logs, light estimation is denied (as an optional feature), but anchors is not mentioned as required, or optional, which might be the issue:
image

I suspect the detection of anchor support is somehow set as true if a polyfill is used, even if the actual requestSession doesn't allow it. This could maybe be clarified by adding 'anchors' to the requiredFeatures list so the error is thrown at session creation, or the internal support flag updated on requestSession to be false.

@Maksims
Copy link
Collaborator

Maksims commented Dec 5, 2023

Hi @benferns, I've investigated more into that, and can confirm that when anchors were not requested for the session, it would still try to iterate through anchors properties on XRFrame. But only if anchors API is supported by the platform.
As I follow the implementation of Specs very precisely, it worked well, as tackedAnchors property should be defined on XRFrame, regardless if anchors feature is requested for the session, as far as anchors API is supported generally - this is what Specs states (notice that this property is not optional).

In short: polyfill implementation - is the one that leads to issues.

Please ensure your implementation also will follow specs, which basically is pretty much true for all WebXR extensions I've read: if API is supported then properties should be defined on their objects (accessors on prototypes) and in type specified in specs, regardless if feature is requested for the session or not.

Nevertheless I've implemented a PR that will take such case into the account, and will prevent attempt to access anchors API in case when it is not enabled on the session: #5879

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 a pull request may close this issue.

2 participants