Skip to content

Fixes crashes when Stop XR is pressed and when Kit is closed while Teleop is running#4752

Merged
kellyguo11 merged 3 commits intoisaac-sim:developfrom
hougantc-nvda:hougantc/fix-crash-stop-xr
Feb 27, 2026
Merged

Fixes crashes when Stop XR is pressed and when Kit is closed while Teleop is running#4752
kellyguo11 merged 3 commits intoisaac-sim:developfrom
hougantc-nvda:hougantc/fix-crash-stop-xr

Conversation

@hougantc-nvda
Copy link
Contributor

Description

Before Kit tears down the OpenXR instance and session, we need to cleanup IsaacTeleop as the cached handles will become invalidated on Kit cleanup.

Stop XR: In the /xr/enabled callback, call _teardown_dead_session() instead of stop(). Only the session is torn down; pipeline and retargeting UI stay. step() then returns None (same as deferred start), the recording loop keeps rendering, and starting XR again works without restarting the script.

Kit close: Subscribe to GLOBAL_EVENT_PRE_SHUTDOWN with order=-100 so our cleanup runs before XRCore (order=0). We release our session and stop using our cached OpenXR handles before Kit XR tears down the OpenXR instance/session, avoiding use of invalid handles.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@hougantc-nvda hougantc-nvda requested a review from rwiltz February 26, 2026 22:39
@github-actions github-actions bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Feb 26, 2026
@hougantc-nvda
Copy link
Contributor Author

Rebased on top of #4746
That PR will need to be merged prior to this PR.

@rwiltz for vis

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR fixes crashes when Stop XR is pressed or Kit closes while Teleop is running by adding proper cleanup callbacks before OpenXR handles become invalidated.

Key changes:

  • Subscribes to /xr/enabled setting to tear down the session (but not UI/pipeline) when XR is stopped, allowing seamless restart
  • Subscribes to GLOBAL_EVENT_PRE_SHUTDOWN with order=-100 to ensure IsaacTeleop cleanup runs before Kit's XRCore tears down OpenXR resources
  • Simplifies button polling to read directly from pipeline controller data

Critical issue found:

  • The two new event subscriptions (_xr_enabled_subscription and _pre_shutdown_subscription) are never cleaned up, which will cause memory leaks if the TeleopSessionLifecycle object is recreated multiple times. A cleanup method should be added to unsubscribe these, similar to XrAnchorManager.cleanup() and CommandHandler.cleanup() patterns used elsewhere in the codebase.

Confidence Score: 3/5

  • PR addresses critical crash bugs but introduces a resource leak that needs fixing
  • The crash fixes are well-designed and properly sequenced (order=-100 ensures correct shutdown order), but the missing subscription cleanup is a legitimate resource management issue that could cause problems in production with repeated session creation
  • source/isaaclab_teleop/isaaclab_teleop/session_lifecycle.py needs subscription cleanup added

Important Files Changed

Filename Overview
source/isaaclab_teleop/isaaclab_teleop/session_lifecycle.py Adds XR shutdown callbacks to prevent crashes, but subscriptions lack cleanup leading to potential memory leaks
source/isaaclab_teleop/isaaclab_teleop/isaac_teleop_device.py Simplified button polling logic - no issues found

Last reviewed commit: f2e235c

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

kellyguo11 and others added 2 commits February 27, 2026 11:08
@hougantc-nvda hougantc-nvda force-pushed the hougantc/fix-crash-stop-xr branch from f2e235c to 8399d85 Compare February 27, 2026 16:13
…nsubscribe from GLOBAL_EVENT_PRE_SHUTDOWN event for completeness.
@hougantc-nvda
Copy link
Contributor Author

Rebased on develop and ready to merge.

@kellyguo11 kellyguo11 merged commit f29853e into isaac-sim:develop Feb 27, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants