VR Apps Fail to Run in Simulator

It is expected that applications built with the App Mode set to Virtual Reality - Fully Immersive Space crash when run in the Simulator?

Steps to reproduce:

  1. Create an empty Unity project using the 3D Core template.
  2. Add the com.unity.xr.visionos package to the project.
  3. Open XR Plug-in Management in Project Settings and check the Apple visionOS box on the last tab.
  4. Select Apple visionOS under XR Plug-in Manage in Project Settings and change the App Mode to Virtual Reality - Fully Immersive Space.
  5. Build the Xcode project from Unity and attempt to run it in the Simulator.

Expected Result: Application runs successfully in the Simulator and the Unity skybox is seen rendered as described here: Starting a new visionOS project from scratch | PolySpatial visionOS | 0.1.2

Actual Result: Application crashes when run in the Simulator.

Note: If you change the App Mode back to Mixed Reality - Volume or Immersive Space, rebuild, and run in the Simulator the application does not crash.

This is the same crash I was seeing in my port testing project and posted about here: Build Failing to Run in Simulator

Before someone else from my team jumps in, just to confirm, do you experience this issue when using Xcode beta 2?

The issue is that the Simulator doesn’t support layered textures. Can you make sure you have Device Target = Simulator and Render Mode = Multi Pass?

Screenshot 2023-07-25 at 14.24.54

Alternatively there’s a visionos_config.h in Xcode, you can change the #define VISIONOS_SINGLE_PASS from 1 to 0.

Yes, @mfuad. I switched over to Xcode beta 2 already; this was one of the issues I was hoping would be fixed with the downgrade.

@thep3000 I updated the visionos_config.h and that gave me a new crash. After that I rebuilt the project from Unity using the Device Target setting and still got the same new crash.

Can you try disabling metal API validation in the xcode scheme? Validating your app’s Metal API usage | Apple Developer Documentation

We haven’t prioritized looking into this yet at we were mainly focused on device - but disabling validation seems to get things working on simulator (not necessary on device). We have seen another crash related to mip uploads on simulator so you may run into that but it seems to only happen sometimes. (don’t know of a workaround for that one, yet… seems to be related to the simulator implementation of astc texture decoding, some sort of race condition … you can maybe try not using astc textures if you see it)

@thep3000 Turning off Metal API validation does allow my empty VR test project to work in the simulator. Unfortunately, my port project hits the mip upload crash bug.

I’ll see if any of the textures are ASTC compressed.

@thep3000 Confirmed that ASTC compression is being used in this project. Is the default compression of visionOS ASTC then? I thought importing it for the visionOS platform would have changed that to something else. ASTC does make sense for the project as that is what I used for the Quest/Quest 2 release.

I am hesitant to change the texture compression for everything in the project just to be able to run it in the Simulator.

Would there be a fix on the Unity side? Should I report a bug somewhere for Unity or does this need to go to Apple?

I just tested my empty Unity project setup with an ASTC compressed texture added to the project and rendered on a quad. With this change the project still runs in the Simulator without issue. I’ll continue to test image setting tweaks to see if I can find the mip issue.

I just tested my empty Unity project setup with an ASTC compressed texture added to the project and rendered on a quad. With this change the project still runs in the Simulator without issue. I’ll continue to test image setting tweaks to see if I can find the mip issue.

It’s a race condition, we think within the apple simulator’s astc decompression logic. Only happens on more complex scenes.

Would there be a fix on the Unity side? Should I report a bug somewhere for Unity or does this need to go to Apple?

We have a workaround on the Unity side - it’s going through verification now and will be in a future 2022.3 release. We might be able to get you a fix out of band, I’ll check into it. We’re also going to bring it up to apple - but from what I can see this has been around for a while - we had apparently had reports of the same issue on tvOS simulator years ago.

1 Like

Here’s a 2022.3.5f1 patched build of the VisionOSPlayer fixing the ASTC texture issue.

You’ll need to replace the VisionOSPlayer in your unity install with the folder in this zip. By default w/ hub, here: /Applications/Unity/Hub/Editor/2022.3.5f1/PlaybackEngines/VisionOSPlayer

There is a native dylib that you’ll need to remove quarantine flag on : xattr -d com.apple.quarantine VisionOSPlayer/arm64/UnityEditor.VisionOS.Native.dylib

Let us know if you have any success.

Success!

Well… at least it didn’t crash. Now to solve issues in my project. :slight_smile:

There are a lot of these warnings in the console output:

WARNING: RGBA Compressed ASTC6X6 sRGB format is not supported, decompressing texture

Should visionOS textures actually not be ASTC compressed? What is the best texture compression to use for this platform?

You’ll only see this on the simulator - it’s the workaround for the crash. On device ASTC works.

1 Like

I got my VR port project issues fixed up and now when I run against the Simulator I can hear the game sounds but it only renders black. Are there any specific gotchas I should check that might be causing this?

You should be able to attach unity’s Frame Debugger and get a better picture of what’s going on. The textures that end up going to the screen are named XR Texture [#], so see what they look like.

On device, the usual suspect for rendering black is depth not being written to or written to as zero. But the simulator seems to ignore that so I don’t think it would be depth related.

actually now that I think about it - let me check with the team - iirc there may have been an issue with the VR package that was fixed.

we think that issue was only for device builds - simulator has been working all along.

going to double check here with some test projects on the released version of the com.unity.xr.visionos package …

let me know if you have success with a simple project as well if you have time.

@thep3000 Please ignore this. It was a project issue that I missed; I failed to update our screen fader to work for visionOS so it happily rendered overtop of everything with full black. Thanks for all of the help!

1 Like