Skip to content

fix(steamvr): name the tracking sample each frame was rendered with - #8

Merged
aaf2tbz merged 2 commits into
metalsharp:mainfrom
multision:fix/steamvr-frame-sample-id
Nov 20, 2026
Merged

aaf2tbz merged 2 commits into
metalsharp:mainfrom
multision:fix/steamvr-frame-sample-id

Conversation

@multision

Copy link
Copy Markdown
Contributor

Summary

A Quest streaming SteamVR over ALVR connects, tracks the head and controllers, and shows no video: metalvrd logs every session as headset disconnected (0 frames sent, N dropped).

The SteamVR driver's FRAME_END never sets sample_id, so it is always 0, and AlvrDriver::sendFrame (daemon/driver_alvr.cpp) drops every frame that names no tracking sample before ALVR sees it. The OpenXR runtime sets it (runtime/session.cpp); only the SteamVR path was missing it.

SteamVR does not say which pose it rendered a frame with, only the pose itself (SubmitLayer's mHmdPose). The driver now keeps the head orientations of the last 64 tracking samples and names the one nearest the first projection layer's pose, which is what ALVR's own SteamVR driver does (PoseHistory::GetBestPoseMatch). Newer samples win ties (an older one has to be about 0.1° nearer), so a still head names the newest sample rather than one float noise happens to put closer. The headset then reprojects each frame from the pose it was drawn with.

This is the change the other two SteamVR PRs (headset views, Touch grip offset) are easiest to see with, but it does not depend on them, nor they on it.

Testing

  • Built for macOS and for Windows (build/native, build/win64): not run, no CMake or Ninja on this Mac. steamvr/driver_metalvr.dll was built with x86_64-w64-mingw32-g++ 16.2 from the CMake target's sources, include paths and flags (C++20, -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers, static runtime): 0 warnings, as on main. CI covers the full builds.

  • scripts/test-native.sh and scripts/test-failures.sh: not run. They do not reach the SteamVR driver, and tests/ has no harness for it yet, so this change has no automated check; happy to add one if there is a preferred shape for it.

  • scripts/test-wine.sh: not run.

  • scripts/test-openvr.sh: not run (this is the SteamVR driver, not the OpenComposite path).

  • On a headset: Meta Quest 3 over Wi-Fi with the ALVR client, metalvrd from the v0.2.1 release (ALVR server v20.14.1), SteamVR 2.18.4 on MetalSharp Wine 8.0 (Wine 11.17, x86_64 under Rosetta), Apple silicon Mac, macOS 27. Tried in SteamVR Home and Blade & Sorcery.

    Before: headset disconnected (0 frames sent, 5039 dropped), black in the headset. After: headset disconnected (2489 frames sent, 0 dropped) and SteamVR's picture in the headset. With a temporary log of the match (since removed), the named sample's orientation was within 0.01 to 0.03° of SteamVR's render pose on average, usually the newest sample or one to four back.

Checklist

  • The change is my own work, or open-source code whose license allows it here; nothing is taken from a closed-source product
  • Changes to ALVR or OpenComposite are patches under patches/, not edits in external/
  • New downloads are pinned to a commit
  • Documentation is updated where behaviour, options or the protocol change (no documented behaviour changes)
  • No Wine prefixes, logs with personal paths, or other personal data

The SteamVR driver's FRAME_END never set sample_id, and metalvrd's ALVR driver
drops a frame that names no tracking sample, so a Quest streaming SteamVR over
ALVR connected and tracked but received no video: every session ended with
"headset disconnected (0 frames sent, N dropped)".

SteamVR does not say which pose it rendered a frame with, only the pose itself
(SubmitLayer's mHmdPose). Keep the head orientations of the last 64 tracking
samples and send the one nearest the first projection layer's pose, as ALVR's
own SteamVR driver does (PoseHistory::GetBestPoseMatch). Newest samples win
ties, so a still head names the newest sample rather than an older one that
float noise happens to put closer. The headset then reprojects each frame from
the pose it was drawn with.
…ple-id

# Conflicts:
#	steamvr/driver_metalvr.cpp
@aaf2tbz
aaf2tbz merged commit c83d51f into metalsharp:main Nov 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants