Skip to content

Commit

Permalink
fix(client_openxr): 🐛 Fix crash on Focus 3 with 0 timestamp (#2440)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp authored Oct 4, 2024
1 parent 9de7438 commit e2a50ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 9 additions & 7 deletions alvr/client_openxr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,15 @@ pub fn entry_point() {
let time = to_xr_time(display_time);
error!("End frame failed! {e}, timestamp: {display_time:?}, time: {time:?}");

xr_frame_stream
.end(
frame_state.predicted_display_time,
xr::EnvironmentBlendMode::OPAQUE,
&[],
)
.unwrap();
if !platform.is_vive() {
xr_frame_stream
.end(
frame_state.predicted_display_time,
xr::EnvironmentBlendMode::OPAQUE,
&[],
)
.unwrap();
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions alvr/client_openxr/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ impl StreamContext {
if let Some((timestamp, buffer_ptr)) = frame_result {
let view_params = self.core_context.report_compositor_start(timestamp);

// Avoid passing invalid timestamp to runtime
let timestamp =
Duration::max(timestamp, vsync_time.saturating_sub(Duration::from_secs(1)));

(timestamp, view_params, buffer_ptr)
} else {
(vsync_time, self.last_good_view_params, ptr::null_mut())
Expand Down

0 comments on commit e2a50ba

Please sign in to comment.