Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 22 additions & 0 deletions src/python/isaaccapture/cloudxr/oob_teleop_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,27 @@ async def _cleanup_owned_rules(self) -> None:
"Owned ADB mapping cleanup failed: %s", command, exc_info=True
)

async def _close_teleop_tab(self) -> None:
"""Close the headset's teleop tab on shutdown so it leaves the CloudXR session.

Without this the page treats the vanished server as a dropped stream and keeps
retrying inside the XR session.
"""
if not self.selected:
return
try:
closed = await asyncio.shield(
asyncio.to_thread(adb._close_stale_teleop_tabs)
)
except Exception:
log.debug("Teleop tab close on shutdown failed", exc_info=True)
return
if closed:
oob_progress(
"usb-local" if self.usb_local else "setup-oob",
f"closed {closed} teleop tab(s) on the headset; session ended",
)

async def _shielded_cleanup(self) -> None:
task = asyncio.create_task(self._cleanup_owned_rules())
await asyncio.shield(task)
Expand Down Expand Up @@ -2045,6 +2066,7 @@ async def run(self) -> None:
):
self._record_usb_wait("STOPPED", "stopped_before_checks")
await self._stop_monitor()
await self._close_teleop_tab()
await self._shielded_cleanup()
if self.coturn is not None:
await asyncio.to_thread(adb.stop_coturn, self.coturn)
Expand Down
3 changes: 2 additions & 1 deletion tests/python/core/cloudxr/test_oob_teleop_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,8 @@ async def rebuild():
assert lifecycle.browser_client == "surviving-page"
automate.assert_not_called()
run_oob_connect.assert_not_called()
close_tabs.assert_not_called()
# The repair closes no tab; the one call is run()'s shutdown close.
close_tabs.assert_called_once_with()
navigate.assert_not_called()


Expand Down
Loading