Skip to content

feat(server_openvr): ✨ Defer TrackedDevices initialization - #2754

Merged
zmerp merged 3 commits into
masterfrom
deferred-steamvr-init
Mar 17, 2025
Merged

zmerp merged 3 commits into
masterfrom
deferred-steamvr-init

Conversation

@zmerp

@zmerp zmerp commented Mar 14, 2025 •

Copy link
Copy Markdown
Member

In this PR I make the following changes:

  • Move TrackedDevices initialization and registration from DriverProvider::Init() to InitializeStreaming()
  • Don't wait for the HMD activation to start the alvr_server_openvr event loop
  • Because of this, to avoid race conditions, TrackedDevice::registrer_device() now waits for the ITrackedDeviceServerDriver::Activate() call.
  • Don't store tracked devices in g_driver_provider until they are successfully activated. This requires changing the signature of SetOpenvrProps() and RegisterButtons() to reference the devices by pointer instead of ID. Allow controllers and trackers to fail registration (we are already handling the absence of any of these devices)

Notably, In this PR i'm not implementing the skip of the first SteamVR restart when the client first connects, this will be done in the next PRs.

@zmerp
zmerp force-pushed the deferred-steamvr-init branch from c581a03 to 45477fb Compare March 14, 2025 02:56
@zmerp
zmerp force-pushed the deferred-steamvr-init branch from 45477fb to e06ab43 Compare March 14, 2025 03:25
@zmerp
zmerp force-pushed the deferred-steamvr-init branch from bd3855a to 511a005 Compare March 14, 2025 04:01
this->device_class,
(vr::ITrackedDeviceServerDriver*)this
)) {
Error("Failed to register device");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could maybe use some additional information like the serial number, to aid in debugging

Comment thread alvr/server_openvr/src/lib.rs
Comment thread alvr/server_openvr/cpp/alvr_server/TrackedDevice.cpp
Comment thread alvr/server_openvr/src/props.rs

@The-personified-devil The-personified-devil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk if you wanna action on that logging thing, but apart from that LGTM

@zmerp

zmerp commented Mar 17, 2025

Copy link
Copy Markdown
Member Author

Sorry, I made the commit but I didn't push

@zmerp
zmerp merged commit dfaa137 into master Mar 17, 2025
@The-personified-devil
The-personified-devil deleted the deferred-steamvr-init branch March 17, 2025 13:49
SingleInfiniteLoop added a commit to SingleInfiniteLoop/ALVR that referenced this pull request May 2, 2025
SingleInfiniteLoop added a commit to SingleInfiniteLoop/ALVR that referenced this pull request May 2, 2025
zmerp added a commit that referenced this pull request Jun 27, 2025
* feat(server_openvr): ✨ Defer TrackedDevices initialization

* Use a condition_variable to wait for TrackedDevice activation

* Address comment
@zmerp zmerp mentioned this pull request Jun 28, 2025
zmerp added a commit that referenced this pull request Jun 30, 2025
* feat(server_openvr): ✨ Defer TrackedDevices initialization

* Use a condition_variable to wait for TrackedDevice activation

* Address comment
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