Restarting a stopped ARKitSession in VisionOS causes app to crash

Flow:

  1. User enters app and starts an arkit session with worldtracking and scene reconstruction.
  2. User closes app so we stop the session.
  3. User re-enters app and we try to run the session but app crashes with error: "It is not possible to re-run a stopped data provider.

If we remove code to stop the session, when the user re-enters the app the scene reconstruction doesn't work properly and shows inaccurate meshing data.

Is this a bug or am I doing something wrong here? Any ideas or insight are appreciated

Replies

I'm basically looking for something like "resetSceneReconstruction" in arkit on iOS but I can't find any documentation on how to achieve this in VisionOS.

If your old provider instances are stopped, then you need to create new world tracking & scene reconstruction provider instances before calling session.run() - as the error message indicates:

It is not possible to re-run a stopped data provider

Creating a new provider is a pretty cheap operation. Re-running stopped providers is not allowed as it is not clear what their state ought to be - would you expect the provider to retroacively receive scene understanding data about anything that happened while the provider was stopped? Or would you expect them to resume as if anything the user looked at while the provider was stopped was never seen?

I'm basically looking for something like "resetSceneReconstruction" in arkit on iOS

There is no way for you to reset tracking on visionOS, and it is not clear to me why you would need that. If you start a new provider ARKit will determine which scene understanding data your app is eligible to receive and that data will be set to the app via anchor updates. If you do not care about some of these anchors you can ignore them in your app.

Thanks for the reply. I've done as you said and created new providers when the app re-enters the foreground. I've got "Collision Shapes and Axes" visualizations on to see exactly where my app is mapping the environment. For some reason when a user re-enters the app, the new SceneReconstructionProvider doesn't always fully mesh the entire environment. It misses some spots. Any idea why this would be?

I'm scanning thoroughly and getting close to walls etc. and waiting several seconds and some areas it simply won't mesh.

(As a side note, force quitting the app doesn't seem to help but when I unplug the headset and run the app after that, everything meshes perfectly.)

  • This sounds like a bug. Can you file a radar about it via Feedback Assistant? Thanks a lot!

Add a Comment