Skip to content

Fix camera streamer reconnection with re-exec#239

Open
nv-mhaselton wants to merge 1 commit intomainfrom
mhaselton/fix-camera-streaming-reconnect
Open

Fix camera streamer reconnection with re-exec#239
nv-mhaselton wants to merge 1 commit intomainfrom
mhaselton/fix-camera-streaming-reconnect

Conversation

@nv-mhaselton
Copy link
Contributor

@nv-mhaselton nv-mhaselton commented Mar 10, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved XR headset connection handling: the app now fully restarts to reset XR state when a headset isn't detected, providing more reliable recovery and improved stability.

@nv-mhaselton nv-mhaselton requested a review from farbod-nv March 10, 2026 20:11
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ad624a15-050e-49bf-aa8a-a5c6522c224e

📥 Commits

Reviewing files that changed from the base of the PR and between 63a5510 and ccc5fbe.

📒 Files selected for processing (1)
  • examples/camera_streamer/teleop_camera_app.py

📝 Walkthrough

Walkthrough

Replaces in-process garbage collection retry logic with a full Python process re-execution using os.execv() and adds logging prior to restart, changing XR headset retry behavior to reset state by relaunching the interpreter.

Changes

Cohort / File(s) Summary
XR Recovery Mechanism
examples/camera_streamer/teleop_camera_app.py
Removes gc import and gc.collect() call; adds logging and performs os.execv() to re-exec the Python process on XR retry instead of in-process cleanup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I nudge the process, soft and quick,

When headset gremlins play their trick.
No sweeping crumbs or dusty stack—
I hop and re-launch, then get back.
Fresh start, fresh view, a nimble flick.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing camera streamer reconnection by using process re-execution (re-exec) instead of in-process garbage collection.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mhaselton/fix-camera-streaming-reconnect

Comment @coderabbitai help to get the list of available commands and usage tips.

@nv-mhaselton nv-mhaselton force-pushed the mhaselton/fix-camera-streaming-reconnect branch from 63a5510 to ccc5fbe Compare March 10, 2026 20:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/camera_streamer/teleop_camera_app.py (1)

15-15: ⚠️ Potential issue | 🟡 Minor

Remove unused gc import.

The gc import is no longer used since garbage collection cleanup was replaced with os.execv(). This is causing the pipeline failure.

🧹 Proposed fix
 import argparse
-import gc
 import os
 import sys
 import time
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/camera_streamer/teleop_camera_app.py` at line 15, Remove the unused
gc import from teleop_camera_app.py: delete the line importing gc (the unused
module symbol "gc") at the top of the file so the pipeline/linter no longer
fails; then run the test/linter to confirm no other references to gc remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/camera_streamer/teleop_camera_app.py`:
- Around line 179-182: Replace the list concatenation used in the re-exec call
with iterable unpacking for readability: change the os.execv call that currently
uses os.execv(sys.executable, [sys.executable] + sys.argv) (near
logger.info("Re-executing for clean XR state...")) to use a list literal with
the spread/unpacking syntax e.g. os.execv(sys.executable, [sys.executable,
*sys.argv]); keep the logger.info line and the os.execv invocation otherwise
unchanged and leave the S606 static-analysis warning acknowledged as safe in
this context.

---

Outside diff comments:
In `@examples/camera_streamer/teleop_camera_app.py`:
- Line 15: Remove the unused gc import from teleop_camera_app.py: delete the
line importing gc (the unused module symbol "gc") at the top of the file so the
pipeline/linter no longer fails; then run the test/linter to confirm no other
references to gc remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 483b7fb6-49fb-4ad7-bac4-d503964c3211

📥 Commits

Reviewing files that changed from the base of the PR and between e8b682c and 63a5510.

📒 Files selected for processing (1)
  • examples/camera_streamer/teleop_camera_app.py

Comment on lines +179 to +182
# Re-exec for a clean process — in-process GC cannot break the
# C++ shared_ptr cycles holding the OpenXR instance alive.
logger.info("Re-executing for clean XR state...")
os.execv(sys.executable, [sys.executable] + sys.argv)
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Sound approach for resetting C++ state; consider using spread operator for cleaner syntax.

Using os.execv() to reset the process is appropriate here since Python's GC cannot break C++ shared_ptr cycles holding the OpenXR instance. The static analysis warning S606 about "starting a process without a shell" is expected and safe in this context—os.execv intentionally avoids shell invocation.

Per RUF005, prefer the spread operator for readability:

✨ Minor style improvement
             logger.info("Re-executing for clean XR state...")
-            os.execv(sys.executable, [sys.executable] + sys.argv)
+            os.execv(sys.executable, [sys.executable, *sys.argv])
🧰 Tools
🪛 Ruff (0.15.5)

[error] 182-182: Starting a process without a shell

(S606)


[warning] 182-182: Consider [sys.executable, *sys.argv] instead of concatenation

Replace with [sys.executable, *sys.argv]

(RUF005)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/camera_streamer/teleop_camera_app.py` around lines 179 - 182,
Replace the list concatenation used in the re-exec call with iterable unpacking
for readability: change the os.execv call that currently uses
os.execv(sys.executable, [sys.executable] + sys.argv) (near
logger.info("Re-executing for clean XR state...")) to use a list literal with
the spread/unpacking syntax e.g. os.execv(sys.executable, [sys.executable,
*sys.argv]); keep the logger.info line and the os.execv invocation otherwise
unchanged and leave the S606 static-analysis warning acknowledged as safe in
this context.

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.

1 participant