Search code examples
c++cmakeuwpopenxr

Cannot access filesystem in CMake UPW Project


I built an application that uses OpenXR with DirectX to display a simple scene in VR. As I'm tasked with implementing this in an already existing project, it's built using CMake, which works perfectly fine with Visual Studio 2019.

The application can run without any issues on the Windows MR Portal, as well as on the Oculus Rift S with the Oculus OpenXR runtime.

Now the next step is to get it running on the hololens. As I need an UWP project to do this, I created a .sln for the application I want to run on the hololens with CMake as follows:

cmake -G "Visual Studio 16 2019" -A x64 ..\.. -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0

With this, I can open the project and compile it as UWP, works without any issues. Now, when I want to run the application to debug it, I get the following error:

Exception thrown at 0x00007FFD3CC83E49 in openxr_test_app.exe: Microsoft C++ exception: std::filesystem::filesystem_error at memory location 0x00000046791CCF50.
Error [GENERAL |  | OpenXR-Loader] : Unknown failure: canonical: Access denied: "C:\WINDOWS\system32\MixedRealityRuntime.json"

After some googling, I found out that I might need to add the relevant capability to the Package.appxmanifest, so I added

<rescap:Capability Name="broadFileSystemAccess"/>

as well as

xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

and

IgnorableNamespaces="uap mp rescap"

to my Package.appxmanifest and enabled filesystem access for my application in the windows settings panel.

However, I still get the error above, I also tried to access other files on my PC (as I thought maybe system32 is a bit more restricted), but with no success.

I'm especially confused, because the OpenXR sample app from Microsoft works without any issues, and they did not declare the broadFileSystemAccess capability.

Are there any other ways to allow file access, or am I just missing something that I need to enable?


Solution

  • So as a quick follow-up, if anyone runs into the same issue: The problem here was a bug in the OpenXR loader that was introduced in version 1.0.10 of OpenXR. Updating to OpenXR 1.0.11 solved the issue of the loader not being able to access the MixedRealityRuntime.json file.