We’ve started porting an existing mobile project into visionOS.
Building with the visionOS platform from Unity has been successful, however when building and running from Xcode, the game is crashing on launch on the Vision Pro Simulator with an EXC_BAD_ACCESS on GetObjectTypeTrackingFlag().
PolySpatial runtime is enabled, it was built from visionOS, are we missing anything?
Hi - that looks reminiscent of a bug that occurs when a scene is loaded async. Does the project run on
Unity editor playmode fine or does it also crash on start?
In general, if there’s calls to LoadSceneAsync() anywhere, please try replacing them with LoadScene() if possible, LoadScene() should work fine. The LoadSceneAsync() bug is known and being worked on.
Thank you @vcheung-unity. We do indeed use LoadSceneAsync, we’ll replace it and let you know.
Are there other known bugs you can think of that have got easy solutions like this?
We are still hitting this exception even after changing to use LoadScene().
We are using LoadScene() from Addressable assets in a lot of places, would this cause a potential issue?
//VISIONOS: LoadSceneAsync is not yet supported
// Either get already-loaded scene, or load it in
//AsyncOperationHandle<SceneInstance> loadingScene = sceneAsset.LoadSceneAsync(LoadSceneMode.Additive);
AsyncOperationHandle<SceneInstance> loadingScene = sceneAsset.LoadScene();
while (loadingScene.IsDone == false)
{
LoadingBehaviour.SetProgress(loadingScene.PercentComplete + (loadingScene.PercentComplete * 0.2f), LoadingBehaviour.ProgressStage.SceneLoading);
yield return null;
}
LoadingBehaviour.SetProgress(1.0f, LoadingBehaviour.ProgressStage.SceneLoading);
SceneInstance loadedScene = loadingScene.Result;
SceneManager.SetActiveScene(loadedScene.Scene);
In answer to your earlier question @vcheung-unity, when we try in Unity Editor Playmode it works fine.
Hi, I’m another developer looking at this project. Thanks for the suggestion so far
Our game initialisation/loading code all takes place in a coroutine that I’ve been liberally spamming with logs and yields to see what we can find.
Results have been inconsistent, but here’s a handful of things I’ve seen:
1
When playing in the editor, I have seen a lot of occurrences of the following error:
InvalidOperationException: Somehow got unparseable GUID from AssetDatabase
This looks potentially the most related to the ObjectType issue, and showed up in the editor play mode on one occasion, and then never again.
2
After adding yields throughout our initialisation code, the ObjectType issue does not occur ONLY on the first launch of the app in the simulator. Future launches of the app all hit the exception.
3
After adding yields all throughout the initialisation code, frame times dropped dramatically in the VisionOS simulator (always at least 2600ms), and the coroutines take several frames to resume. This could be caused by our own code, but thought I’d mention. Doesn’t occur in editor play mode.
We’ve also tried removing LoadSceneAsync() everywhere, as well as any async loading of addressable assets of all types.
Thanks for the details!
That the crash happens inconsistently is more than a little strange. The crash call stack looks reminiscent of an error that occurs when an asset is loaded in from another thread besides main, but it should be a consistent crash, so now I’m wondering if it may be a different bug.
At this point, can you file a bug report and attach a sample project that triggers this crash?
We’ve been looking further into this and have found the cause! We have a GameObject prefab reference that we initialise using Addressables.LoadAsset<T>()
, and give the Completed
field a callback that instantiates that object. We fixed this exception by swapping this out for a direct Prefab reference set in the editor, and instantiating it without the callback.
We hit several other similar async-loading issues later in our initialisation code, they’re quite hard to track down so would you have any word on whether this may be fixed soon?
In addition to what @ES_James has said, we have submitted a bug report now, with a very small project where we can reproduce the GetObjectTypeTrackingFlag() exception bug, triggered when running on the visionPro simulator.
Bug report IN-52099
Thanks for filing the bug!
We should have a fix on the roadmap for similar async issues, and I can see if that fix will get the project in the bug report working.
1 Like
Thank you @vcheung-unity.
For the moment we are working around it by immediatelly caling op.WaitForCompletion() after starting any Addressabes.Load() call, so effectively they are running synchronously.
1 Like