Skip to content

Fix duplicate Nvidia Vulkan/EGL drivers under Flatpak (steam-runtime#624)

Simon McVittie requested to merge wip/sr624-flatpak-nvidia-dedup into main

This fixes a regression in 0.20230919.0 for Flatpak Nvidia users. I'd like to get a new beta out soon with this in it, so I've kept refactoring to a minimum (another MR will follow with some related refactoring). Only lightly tested in non-Flatpak environments so far.

/cc @denittis @timo


  • graphics: Separate creation of ICD-like objects from prepending to list

    This avoids some overly long lines, and will make subsequent changes more straightforward.

  • graphics: Make SrtLoadable-based object layout visible internally

    This will let us use generic functions to manipulate the SrtLoadable's contents without affecting the public API.

  • graphics: Remember original contents of drivers' JSON manifests

    Unlike layers, Vulkan/EGL drivers and EGL external platforms have relatively small JSON manifests and no built-in way to exclude duplicates. We can use the full content of the manifest to detect trivial cases of duplication.

    We don't do this for Vulkan layers, because Vulkan-Loader can already deduplicate those by the layer name, and they're substantially larger than drivers (which would make them more memory-consuming).

  • pv-runtime: Deduplicate Vulkan drivers, etc. by their manifest content

    The unofficial Steam app on Flathub uses an extension to provide i386 graphics drivers, alongside the x86_64 graphics drivers provided by an extension to the base runtime. Unlike typical Linux distribution packaging where the JSON manifests are in /usr/share, the JSON manifests for these drivers are installed into architecture-specific locations.

    When using Mesa, this is fine, because each driver's JSON manifest refers to the Mesa driver by its absolute path, and Vulkan-Loader will ignore the drivers that are for the other word-size.

    However, when using the Nvidia proprietary driver, the JSON manifest refers to the driver by its basename, which is equally good for both word-sizes. In a typical Linux distribution, both word-sizes would share a single JSON manifest and there would still be no duplication, but in Flatpak, we get two JSON manifests in different locations with identical content. This has been implicated in crashes in some games, such as The Elder Scrolls Online (although I have not been able to reproduce this with the games I've tried).

    Before pressure-vessel 0.20230919.0, we accidentally avoided this failure mode by generating broken symlinks for the i386 manifests in /app, which meant that only the manifest originally intended to be for x86_64 was loaded; but that was more a case of compensating errors than anything else, and was probably breaking the ability to load Mesa drivers for i386 games (mitigated by the fact that games requiring Vulkan are more likely to target x86_64). 0.20230919.0 fixed that bug, at the cost of introducing this duplication for Nvidia drivers.

    We can avoid this becoming an issue by only providing the first one of each set of duplicate JSON manifests.

    Resolves: https://github.com/ValveSoftware/steam-runtime/issues/624

Edited by Simon McVittie

Merge request reports