Skip to content

Commit

Permalink
Close VR without traceback when OpenXR connection is lost. Bug #16689…
Browse files Browse the repository at this point in the history
… and #16662.
  • Loading branch information
tomgoddard committed Jan 24, 2025
1 parent 0231bb6 commit de1fc4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bundles/vive/src/openxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ def end_frame(self):
def _poll_xr_events(self):
import xr
while True:
if self.connection_closed:
return
try:
event_buffer = xr.poll_event(self._instance)
try:
Expand Down Expand Up @@ -727,6 +729,10 @@ def shutdown(self):
xr.destroy_instance(self._instance)
self._instance = None

@property
def connection_closed(self):
return self._instance is None

def headset_pose(self):
# head to room coordinates. None if not available
e0, e1 = self.eye_pose
Expand All @@ -738,6 +744,8 @@ def headset_pose(self):

def poll_next_event(self):
self._poll_xr_events() # Update self._session_state to detect headset has lost focus
if self.connection_closed:
return None
q = self._event_queue
q.extend(self._button_events())
if len(q) == 0:
Expand Down
5 changes: 5 additions & 0 deletions src/bundles/vive/src/xr.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ def _next_frame(self, *_):
if self._xr is None:
return

if self._xr.connection_closed:
self._session.logger.error('OpenXR connection closed')
stop_vr(self._session)
return

self.process_controller_events()
self.user_interface.update_if_needed()

Expand Down

0 comments on commit de1fc4a

Please sign in to comment.