Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server_openvr): Fix CPU/GPU deadlocking at 100% usage before the headset connects #2495

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions alvr/server_openvr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,24 @@ extern "C" fn wait_for_vsync() {
.video
.optimize_game_render_latency
{
SERVER_CORE_CONTEXT
.read()
.as_ref()
.and_then(|ctx| ctx.duration_until_next_vsync())
// We default to 10ms in the event that a headset hasn't connected,
// because otherwise systems can lock up with 100% GPU.
Some(
SERVER_CORE_CONTEXT
.read()
.as_ref()
.and_then(|ctx| ctx.duration_until_next_vsync())
.unwrap_or(Duration::from_millis(10)),
zmerp marked this conversation as resolved.
Show resolved Hide resolved
)
} else {
None
};

if let Some(duration) = sleep_duration {
thread::sleep(duration);
} else {
// Don't deadlock people's systems even if they ask nicely
zmerp marked this conversation as resolved.
Show resolved Hide resolved
thread::sleep(Duration::from_millis(1));
zmerp marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading