Skip to content

Fix PhysX simulation lifecycle ownership - #6588

Merged
AntoineRichard merged 4 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/fix-physx-simulation-manager-lifecycle
Jul 17, 2026
Merged

AntoineRichard merged 4 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/fix-physx-simulation-manager-lifecycle

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

PR #6505 removed the Kit extension startup that previously re-imported isaaclab_physx after Kit loaded. When task configuration imports the PhysX package before Kit, the compatibility hook returns early and is never retried. The original Isaac Sim SimulationManager STOP callback then invalidates the tensor view shared with PhysxManager, causing Franka and other PhysX articulation environments to fail during their first reset.

This PR retries the existing idempotent compatibility takeover from PhysxManager.initialize(), where Kit is available and PhysX is the selected backend. It also updates the import-order contract and adds an integration regression test that imports PhysxCfg before launching Kit.

This fix is independent of #6337.

Type of change

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

Screenshots

N/A

Validation

  • Regression RED on unmodified develop: module alias remained the original Isaac Sim SimulationManager after SimulationContext initialization.
  • Regression GREEN: 1 passed.
  • Isaac-Reach-Franka, 16 environments, PhysX: environment creation, reset, and first step completed with exit code 0 and without invalidated-view errors.
  • ./isaaclab.sh -p tools/changelog/cli.py check develop
  • ./isaaclab.sh -f

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh -f
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove the fix is effective
  • I have added a changelog fragment for every touched package
  • My name already exists in CONTRIBUTORS.md

Record the import-order regression introduced by removing Kit extension manifests and define the backend-owned initialization fix and regression coverage.
Define the red-green regression workflow, focused implementation, validation gates, and separate pull request steps.
Retry the SimulationManager compatibility takeover when PhysxManager initializes so early backend config imports cannot leave Isaac Sim callbacks subscribed.
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Jul 17, 2026
Keep the public pull request focused on the PhysX fix, regression test, and changelog while retaining the local planning history in earlier commits.
@greptile-apps

greptile-apps Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a regression introduced by PR #6505 where early imports of isaaclab_physx (before Kit startup) caused the compatibility hook to be a permanent no-op, leaving Isaac Sim's original SimulationManager STOP callback subscribed and able to invalidate the tensor view owned by PhysxManager. The fix adds a three-line idempotent retry of _patch_isaacsim_simulation_manager() at the top of PhysxManager.initialize(), where Kit is guaranteed to be present.

  • Core fix (physx_manager.py): PhysxManager.initialize() now calls the existing patch function via a local import before any backend state is set up, guaranteeing lifecycle takeover regardless of Python import order.
  • Regression test (test_simulation_manager_ownership.py): A new integration test imports PhysxCfg before AppLauncher, then asserts that after SimulationContext initialization the module alias and callback status are correct.
  • Planning artifacts (docs/superpowers/): Two agentic-workflow documents (plan and spec) were committed alongside the fix; see inline comments.

Confidence Score: 4/5

The production code change is minimal (4 lines in initialize()) and reuses an already-tested, idempotent helper; safe to merge after resolving the docs artifacts.

The fix is surgical and well-scoped, the integration test exercises the exact broken import order, and the double-call path is safe by design. The two docs/superpowers/ files are planning artifacts that were committed alongside the fix and warrant a second look before merging.

docs/superpowers/plans/2026-07-17-physx-simulation-manager-lifecycle.md and docs/superpowers/specs/2026-07-17-physx-simulation-manager-lifecycle-design.md appear to be internal agentic planning artifacts and should be reviewed for intentional inclusion.

Important Files Changed

Filename Overview
source/isaaclab_physx/isaaclab_physx/physics/physx_manager.py Adds 3-line idempotent retry of _patch_isaacsim_simulation_manager() at the top of initialize(), ensuring the compatibility takeover always runs after Kit loads, regardless of pre-Kit import order.
source/isaaclab_physx/isaaclab_physx/init.py Docstring update only — updates the lazy-hook comment to describe the two-phase patching contract (opportunistic at import, guaranteed via initialize()). No logic change.
source/isaaclab_physx/test/sim/test_simulation_manager_ownership.py New integration test importing PhysxCfg before AppLauncher, then verifying the module alias and disabled callbacks after SimulationContext init; does not capture sim return value or assert physics_manager, but the two module-level assertions adequately cover the fix.
docs/superpowers/plans/2026-07-17-physx-simulation-manager-lifecycle.md AI-agent planning document with task checklists and implementation scripts committed to the repository; likely an unintentional artifact from an agentic workflow and probably should not live in docs/.
docs/superpowers/specs/2026-07-17-physx-simulation-manager-lifecycle-design.md Design spec document that ends mid-sentence on the last bullet; another likely agentic-workflow artifact committed alongside the production fix.
source/isaaclab_physx/changelog.d/antoiner-physx-simulation-manager-lifecycle.rst Adds a correct "Fixed" changelog fragment describing the tensor-view invalidation bug.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant UserScript
    participant isaaclab_physx as isaaclab_physx.__init__
    participant Kit
    participant SimMgr as isaacsim SimulationManager
    participant PhysxMgr as PhysxManager

    Note over UserScript,PhysxMgr: Pre-Kit import (e.g. task config resolution)
    UserScript->>isaaclab_physx: import PhysxCfg
    isaaclab_physx->>isaaclab_physx: _patch_isaacsim_simulation_manager()
    isaaclab_physx-->>isaaclab_physx: no-op (isaacsim not in sys.modules yet)

    Note over UserScript,PhysxMgr: Kit startup
    UserScript->>Kit: "AppLauncher(headless=True)"
    Kit->>SimMgr: load and register PLAY/STOP/stage callbacks

    Note over UserScript,PhysxMgr: SimulationContext creation (post-Kit)
    UserScript->>PhysxMgr: "SimulationContext(physics=PhysxCfg())"
    PhysxMgr->>PhysxMgr: initialize()
    PhysxMgr->>isaaclab_physx: _patch_isaacsim_simulation_manager() [retry]
    isaaclab_physx->>SimMgr: enable_all_default_callbacks(False)
    isaaclab_physx->>SimMgr: "SimulationManager = PhysxManager"
    Note over SimMgr: Original STOP callback disabled
    PhysxMgr->>PhysxMgr: _setup_subscriptions(), _configure_physics(), ...
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant UserScript
    participant isaaclab_physx as isaaclab_physx.__init__
    participant Kit
    participant SimMgr as isaacsim SimulationManager
    participant PhysxMgr as PhysxManager

    Note over UserScript,PhysxMgr: Pre-Kit import (e.g. task config resolution)
    UserScript->>isaaclab_physx: import PhysxCfg
    isaaclab_physx->>isaaclab_physx: _patch_isaacsim_simulation_manager()
    isaaclab_physx-->>isaaclab_physx: no-op (isaacsim not in sys.modules yet)

    Note over UserScript,PhysxMgr: Kit startup
    UserScript->>Kit: "AppLauncher(headless=True)"
    Kit->>SimMgr: load and register PLAY/STOP/stage callbacks

    Note over UserScript,PhysxMgr: SimulationContext creation (post-Kit)
    UserScript->>PhysxMgr: "SimulationContext(physics=PhysxCfg())"
    PhysxMgr->>PhysxMgr: initialize()
    PhysxMgr->>isaaclab_physx: _patch_isaacsim_simulation_manager() [retry]
    isaaclab_physx->>SimMgr: enable_all_default_callbacks(False)
    isaaclab_physx->>SimMgr: "SimulationManager = PhysxManager"
    Note over SimMgr: Original STOP callback disabled
    PhysxMgr->>PhysxMgr: _setup_subscriptions(), _configure_physics(), ...
Loading

Comments Outside Diff (2)

  1. docs/superpowers/plans/2026-07-17-physx-simulation-manager-lifecycle.md, line 1-4 (link)

    P2 AI planning artifact committed to repo — This file (and docs/superpowers/specs/2026-07-17-physx-simulation-manager-lifecycle-design.md) appears to be an internal agentic-workflow planning document: it references REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development, contains step-by-step checkbox task lists, and includes raw bash commands intended for an automated worker. These documents are not user-facing documentation for the Isaac Lab project and likely landed here as a side effect of the agentic implementation workflow. If there is no established convention for storing docs/superpowers/ artifacts in this repository, consider removing both files before merging.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  2. docs/superpowers/specs/2026-07-17-physx-simulation-manager-lifecycle-design.md, line 64-66 (link)

    P2 Spec file ends mid-sentence — The Testing section closes with - redirects the Isaac Sim module alias to \PhysxManager`; and` and then stops. The second bullet (presumably about disabled callbacks) is missing, leaving the document incomplete. If this spec is intentionally kept in the repo, the dangling sentence should be finished.

Reviews (1): Last reviewed commit: "Remove internal workflow artifacts" | Re-trigger Greptile

@AntoineRichard
AntoineRichard requested a review from ooctipus July 17, 2026 10:07
@AntoineRichard AntoineRichard moved this to Ready to merge in Isaac Lab Jul 17, 2026
@AntoineRichard AntoineRichard self-assigned this Jul 17, 2026
@AntoineRichard
AntoineRichard merged commit 03904ab into isaac-sim:develop Jul 17, 2026
87 of 91 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Isaac Lab Jul 17, 2026
matthewtrepte pushed a commit to matthewtrepte/IsaacLab that referenced this pull request Aug 4, 2026
# Description

PR isaac-sim#6505 removed the Kit extension startup that previously re-imported
`isaaclab_physx` after Kit loaded. When task configuration imports the
PhysX package before Kit, the compatibility hook returns early and is
never retried. The original Isaac Sim `SimulationManager` STOP callback
then invalidates the tensor view shared with `PhysxManager`, causing
Franka and other PhysX articulation environments to fail during their
first reset.

This PR retries the existing idempotent compatibility takeover from
`PhysxManager.initialize()`, where Kit is available and PhysX is the
selected backend. It also updates the import-order contract and adds an
integration regression test that imports `PhysxCfg` before launching
Kit.

This fix is independent of isaac-sim#6337.

## Type of change

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

## Screenshots

N/A

## Validation

- Regression RED on unmodified develop: module alias remained the
original Isaac Sim `SimulationManager` after `SimulationContext`
initialization.
- Regression GREEN: `1 passed`.
- `Isaac-Reach-Franka`, 16 environments, PhysX: environment creation,
reset, and first step completed with exit code 0 and without
invalidated-view errors.
- `./isaaclab.sh -p tools/changelog/cli.py check develop`
- `./isaaclab.sh -f`

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the pre-commit checks with `./isaaclab.sh -f`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove the fix is effective
- [x] I have added a changelog fragment for every touched package
- [x] My name already exists in `CONTRIBUTORS.md`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants