Skip to content

Fix renderer cadence after environment reset#6610

Open
ruziniuuuuu wants to merge 2 commits into
isaac-sim:developfrom
ruziniuuuuu:ruziniuuuuu/ovrtx-reset-lifecycle
Open

Fix renderer cadence after environment reset#6610
ruziniuuuuu wants to merge 2 commits into
isaac-sim:developfrom
ruziniuuuuu:ruziniuuuuu/ovrtx-reset-lifecycle

Conversation

@ruziniuuuuu

Copy link
Copy Markdown

Description

Environment resets can change simulation state without advancing the physics
step counter. RenderContext deduplicates scene-state publication by that
counter, so the first camera read after reset could skip renderer transform
updates and reuse pre-reset geometry.

This change invalidates scene-state cadence at the end of every environment
reset implementation that owns _reset_idx():

  • ManagerBasedEnv
  • ManagerBasedRLEnv
  • DirectRLEnv
  • DirectMARLEnv

The change remains backend-neutral and leaves scene population, transform
publication, temporal history, and CUDA synchronization with RenderContext
and the renderer adapters.

Fixes #6609

Type of change

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

Screenshots

Not applicable. The regression asserts renderer lifecycle state directly; the
linked issue contains quantitative Newton/OVRTX matrix and depth-AOV evidence.

Validation

  • Verified the regression fails without the fix:
    assert 7 is None for ManagerBasedEnv.
  • Verified each new regression in a fresh Isaac Lab process:
    • ManagerBasedEnv: 1 passed
    • ManagerBasedRLEnv: 1 passed
    • DirectRLEnv: 1 passed
    • DirectMARLEnv: 1 passed
  • ./isaaclab.sh -p tools/changelog/cli.py check develop
  • ./isaaclab.sh -f (run before commit and again before push)

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
  • I have added a changelog fragment under source/isaaclab/changelog.d/
  • I have added my name to CONTRIBUTORS.md

Environment resets can change simulation state without advancing the physics-step counter. Invalidate render-context scene-state cadence in every reset implementation so the next render republishes transforms.

Fixes isaac-sim#6609
@ruziniuuuuu
ruziniuuuuu requested a review from a team July 19, 2026 11:41
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Jul 19, 2026
@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a renderer cadence bug where RenderContext deduplicates scene-state publication by physics step counter, so an environment reset — which changes simulation state without advancing that counter — could cause the first camera read after reset to skip transform/geometry updates and reuse pre-reset scene geometry. The fix calls reset_scene_state_cadence() at the end of _reset_idx() in all four env base classes, which clears _last_scene_state_step so the next camera render triggers a full update_transforms() + update_geometries() cycle.

  • Four env classes (ManagerBasedEnv, ManagerBasedRLEnv, DirectRLEnv, DirectMARLEnv) each get a one-line addition to _reset_idx().
  • Regression tests directly assert _last_scene_state_step is None after reset; the test_env_rendering_logic.py tests use the established env = None sentinel pattern while the new test_direct_marl_env.py test constructs the env outside its try block (minor cleanup opportunity).

Confidence Score: 4/5

The fix is safe to merge; it makes a one-line idempotent change across four env classes, and reset_scene_state_cadence() is a no-op when no renderers are registered.

The env changes are minimal, correct, and consistent. The only imperfection is the DirectMARLEnv test constructing the env outside its try block, which would hide the original exception on a constructor failure.

source/isaaclab/test/envs/test_direct_marl_env.py — env constructor is outside the try/finally guard

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/envs/manager_based_env.py Appends reset_scene_state_cadence() at end of _reset_idx(); minimal and correct
source/isaaclab/isaaclab/envs/manager_based_rl_env.py Appends reset_scene_state_cadence() at end of _reset_idx(); does not call super so no double-call risk
source/isaaclab/isaaclab/envs/direct_rl_env.py Appends reset_scene_state_cadence() at end of _reset_idx(); consistent with other env types
source/isaaclab/isaaclab/envs/direct_marl_env.py Appends reset_scene_state_cadence() at end of _reset_idx(); consistent with other env types
source/isaaclab/test/envs/test_env_rendering_logic.py Adds parametrized regression test for ManagerBasedEnv, ManagerBasedRLEnv, DirectRLEnv; uses safe env=None/finally pattern
source/isaaclab/test/envs/test_direct_marl_env.py Adds DirectMARLEnv regression; env constructed outside try block — a constructor failure would cause NameError in finally

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Caller
    participant Env as Env._reset_idx()
    participant RC as sim.render_context
    participant Camera as Camera._update_buffers()

    Caller->>Env: reset()
    Note over Env: physics step counter unchanged
    Env->>Env: scene.reset(env_ids)
    Env->>Env: event_manager, managers reset
    Env->>RC: reset_scene_state_cadence()
    Note over RC: _last_scene_state_step = None
    Caller->>Camera: read observation (camera)
    Camera->>RC: render_into_camera(physics_step_count)
    RC->>RC: update_scene_state(physics_step_count)
    Note over RC: _last_scene_state_step != None ✓ update_transforms() + update_geometries() run
    RC->>Camera: render + read_output
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 Caller
    participant Env as Env._reset_idx()
    participant RC as sim.render_context
    participant Camera as Camera._update_buffers()

    Caller->>Env: reset()
    Note over Env: physics step counter unchanged
    Env->>Env: scene.reset(env_ids)
    Env->>Env: event_manager, managers reset
    Env->>RC: reset_scene_state_cadence()
    Note over RC: _last_scene_state_step = None
    Caller->>Camera: read observation (camera)
    Camera->>RC: render_into_camera(physics_step_count)
    RC->>RC: update_scene_state(physics_step_count)
    Note over RC: _last_scene_state_step != None ✓ update_transforms() + update_geometries() run
    RC->>Camera: render + read_output
Loading

Reviews (1): Last reviewed commit: "Fix renderer cadence after environment r..." | Re-trigger Greptile

Comment thread source/isaaclab/test/envs/test_direct_marl_env.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant