ExtendedReality XR/VR portal #1165
Replies: 8 comments 25 replies
-
The only thing I can say is that we might prefer to see a set of XR devices (display + input + ...) as a single device. Some questions:
|
Beta Was this translation helpful? Give feedback.
-
Speaking as a user of VR software (primarily SteamVR + Steam VR titles), this statement seems counter-intuitive. I fully consider the VR/XR compositor to be a user/session service, I would never run more than a single VR/XR compositor at a time and I would expect all my running VR/XR applications to use the same compositor. Also AFAIK the compositor has stringent low-latency requirements to implement timewarp/reprojection/motion smoothing and other critical features that prevent VR-sickness on app framerate drop/stutter. That requirement alone puts it in a different class from your typical desktop app IMHO, and closer to other latency-critical software such as the sound stack (e.g. JACK or Pipewire). As such, I don't immediately see the appeal in running my VR/XR compositor under Flatpak. AFIAK one mission of Flatpak is to provide a permissions model to prevent apps from accessing or modifying anything on the system without the user's explicit consent. I would grant a VR/XR compositor low-level access to all sorts of hardware on my system in a heartbeat: my VR hardware, connected GPUs, and realtime scheduling priority on my CPU. Without those permissions, I'm either not running any VR titles or they are uncomfortable to experience. Any "security" provided by the Flatpak permissions model is utterly insignificant here IMHO. Maybe someone with more technical knowledge can explain what the benefit is to running a VR/XR compositor in a Flatpak, rather than an end-user application (e.g. Blender)? Thanks ❤️. |
Beta Was this translation helpful? Give feedback.
-
My understanding from talking to @swick is that the process of leasing devices is not strictly bound to Wayland or X11, so in the grand scheme of things, it's more of a desktop API rather than a compositor API. From this perspective, if I understood it correctly, it feels natural for this API to live in XDG desktop portal, and the security / permissions boundaries are secondary and somewhat opportunistic. I don't understand enough of the problem domain to be able to agree or disagree with this. It just sounds right to me. I also don't understand enough of XR to review the D-Bus interfaces in full detail, I can just comment on whether or not it follows the good practices of XDG portals. What would be helpful is for someone to give a panorama of the current state of XR devices on Linux - what components are involved, how do they communicate, what information they need to exchange, etc - and, from there, we can try and escalate that into a portal interface (or not - if we conclude that's not a good idea after all). Can someone do such a writeup? |
Beta Was this translation helpful? Give feedback.
-
Here's a rough overview of how OpenXR works, technologically from a systems perspective: Any process that wants to display its content in XR will dynamically or statically link to the OpenXR runtime loader. The runtime loader, on application intialization, will search directories at standard/env defined paths or environment variable overrides for an XR runtime manifest json as well as API layer json files. Inside each one is metadata about what dynamic library to link. The openxr runtime loader dynamically links the libraries and the application uses xrGetProcAddress to get all the function pointers it needs. Those dynamic libraries for XR runtimes and API layers could theoretically talk to devices directly, but in practice none actually do and accounting for that is not worth the security and complexity and time. If a dynamic library were to talk to them directly, then only that 1 application could run (monado and steamvr both have overlays of different kinds and monado allows multiple XR apps with 1 focused). As well, when the XR app closed it would deinitialize the headset hardware meaning no launcher could exist. Nobody would do that. In practice, what happens is an XR service runs in the background (SteamVR or Monado for now, but I am working on my own) and exposes a unix domain socket in $XDG_RUNTIME_DIR just as any display server does. The runtime library connects to that service and sends messages/dmabufs/fds/whatever. The only exception is Ultraleap's hand tracking API layer which uses TCP loopback sockets instead of unix domain sockets. The service does connect to devices directly and requires DRM leasing as well as hidraw access and CAP_SYS_NICE (until other solutions are found) as well as possibly other permissions like Bluetooth. This combined with the fact that it just exposes a socket means it acts like a display server would, a system service. The only practical difference is that it's not pre-installed because XR isn't yet a dominant computer interface. We do have XR service runtimes already (not to be confused with XR runtime services) like Steam's Linux runtime (sniper i believe) as well as Envision for Monado. These allow an XR runtime service as well as its libraries to be run on any Linux device without the need to be installed to the system. Flatpak is not necessary, and given no other system services are put in flatpaks I'm not sure it would fit. So to summarize: for XR apps we need to find the right OpenXR libraries and expose loopback/unix domain sockets, XR runtimes are best left as system services. |
Beta Was this translation helpful? Give feedback.
-
These discussions always get bogged down into specific implementation details. I'm not all too familiar with flatpak but I'll dump some text here anyway. There are different scenarios with different requirements. The first thing that should be said is that OpenXR works quite similar to Vulkan and ideally OpenXR could be made to work similarly: A Vulkan application links to the Khronos Vulkan loader. The Vulkan loader loads a json manifest from some standard directory (driver ICD). With information from the json manifest, the Vulkan loader loads a shared library with the vendor implementation. An OpenXR application links to the Khronos OpenXR loader. The OpenXR loader loads an OpenXR runtime json manifest from some standard directory. With information from the json manifest, the OpenXR loader loads a shared library with the vendor implementation. The difference is that with Vulkan that's usually the end of the line before going directly to a kernel driver, wheras the OpenXR backend is often another userspace application/service. Runtime architecture 1: Client-Server based runtimesThis is what runtimes most often do today. Scenario 1: OpenXR runtime service on the host, OpenXR application in flatpakThe OpenXR application needs access to the OpenXR loader shared library (may be statically linked into the app (unusual on linux), may be shipped with the app, may rely on it being available in the system. I believe it is not available in the Steam runtime as of now). The OpenXR loader shared library needs access to a runtime json manifest in the filesystem. It would be very inconvenient to have to ship them with the app, so ideally it would be loaded from the host. The same goes with the OpenXR runtime client side library, ideally it would be loaded from the host. The client side library then needs some connection to the runtime on the host. This is very runtime specific, but often it's a socket or so. There is no need for flatpak to handle drm leasing, device permissions here, it all happens on the host side. Scenario 2: OpenXR runtime service in flatpak, OpenXR application in flatpakYes, we here don't want to particularly do this, but there are people out there who want to distribute and run the entire stack in docker, flatpak etc. In this scenario, flatpak doesn't need to care about OpenXR loaders, runtime manifest, etc. But it does need to handle drm leasing and device permisisons. Scenario 3: OpenXR runtime service in flatpak, OpenXR application on the hostI'm not sure if people want to do that. The OpenXR application needs access to the OpenXR loader shared library, which we can just pretend is a host system problem. The OpenXR loader shared library needs access to a runtime json manifest in the filesystem. flatpak would need to let the OpenXR runtime provide it to the host system. The same goes with the OpenXR runtime client side library, flatpak would need to provide it to the host. The client side library then needs some connection to the runtime in flatpak. Again this is very runtime specific, often a socket etc. Here flatpak needs to handle drm leasing, device permissions, and in addition handle quite some OpenXR-y stuff Runtime architecture 2: All-in-One (in-process) runtimesEssentially this is the same as Client-Server based runtimes with OpenXR application and OpenXR runtime in flatpak. What nowThe question is not which of those is the one true scenario that should be supported and nothing else. The question is, should the flatpak implementation / the protocol dictate which of those scenarios you can or can not do? Imo the more of those can be enabled, the better. |
Beta Was this translation helpful? Give feedback.
-
I believe it would be worthwhile to also add DRM leasing support to logind, both to help in implementing some parts of a VR portal (this way, we don't need the compositor to lease out resources, the portal can do so separately), and to help further some other parts of the Linux ecosystem (like running several compositors on one GPU's displays). |
Beta Was this translation helpful? Give feedback.
-
I'm going to close this issue. The fact that all the VR compositors right now have a client server architecture means that no flatpak app has to be able to lease resources from the compositor. It also means that a wayland protocol is a very bad choice because they are exposed to all flatpak apps. A d-bus service for leasing out resources from a compositor such as displays and input devices (there is a MR for logind for hidraw devices already) would still be a better design but they are not regular apps so a portal is the wrong approach. We'll also have to figure out how flatpak apps can access the XR runtimes. The OpenXR implementation in the flatpak runtime really has to be shared and the way it punches a hole for the XR compositor IPC has to be standardized. |
Beta Was this translation helpful? Give feedback.
-
For those following along, I believe this is There are also some other related discussions: |
Beta Was this translation helpful? Give feedback.
-
This is a strawman proposal for adding an XR portal.
The long term goal here is to make it possible to ship and run an XR compositor with flatpak. This means DRM leasing, access to sensors, input devices etc.
For now the goal is to provide DRM leasing infrastructure but design the portal in such a way that adding access to the other types of devices will be possible.
Beta Was this translation helpful? Give feedback.
All reactions