Skip to content

Fixes XR instruction widget: scene_view.xr_utils, Fabric CopyFabricPrim support - #4795

Merged
kellyguo11 merged 5 commits into
isaac-sim:developfrom
hougantc-nvda:hougantc/fix-xr-instruction-widget
Mar 4, 2026
Merged

kellyguo11 merged 5 commits into
isaac-sim:developfrom
hougantc-nvda:hougantc/fix-xr-instruction-widget

Conversation

@hougantc-nvda

Copy link
Copy Markdown
Contributor

Description

Fixes XR instruction widget for Fabric and current scene view APIs

  • Use omni.kit.scene_view.xr_utils and XRSceneView instead of deprecated
    omni.kit.xr.scene_view.utils
  • When Fabric is enabled, use CopyFabricPrim so the widget transform is
    preserved in XR; add omni.fabric.commands kit dependency
  • Clear selection of the instruction prim after copy to avoid "Accessed
    invalid null prim" on env reset
  • Fix session lifecycle pre-shutdown by removing invalid unsubscribe() call

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

@github-actions github-actions Bot added bug Something isn't working isaac-sim Related to Isaac Sim team isaac-lab Related to Isaac Lab team labels Mar 3, 2026
@hougantc-nvda
hougantc-nvda requested a review from rwiltz March 3, 2026 03:03
@greptile-apps

greptile-apps Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the XR instruction widget by migrating from the deprecated omni.kit.xr.scene_view.utils API to omni.kit.scene_view.xr_utils/XRSceneView, adds a CopyFabricPrim code path to preserve widget transforms when the Fabric Scene Delegate is active, clears the post-copy prim selection to prevent "Accessed invalid null prim" errors on env reset, and removes an invalid .unsubscribe() call in the teleop session pre-shutdown handler.

  • API migration (instruction_widget.py): Replaces omni.kit.xr.scene_view.utils imports with omni.kit.scene_view.xr and omni.kit.scene_view.xr_utils; UiContainer constructor now takes XRSceneView as its first argument.
  • Fabric support (instruction_widget.py): When /app/useFabricSceneDelegate is true, uses CopyFabricPrim (with a prior DeleteFabricPrims for idempotency), falling back to the existing CopyPrim path otherwise.
  • Selection cleanup (instruction_widget.py): After a successful copy, deselects target_prim_path for both Fabric and USD source types to avoid manipulator errors on environment reset.
  • Kit dependency (isaaclab.python.xr.openxr.kit): Adds omni.fabric.commands dependency required for CopyFabricPrim.
  • Session lifecycle fix (session_lifecycle.py): Removes the invalid self._pre_shutdown_subscription.unsubscribe() call; the carb.eventdispatcher subscription object cleans up when set to None.
  • Version bump: extension.toml patched from 4.5.0 → 4.5.1 with corresponding CHANGELOG entry.

Confidence Score: 3/5

  • Safe to merge for XR-only workflows; callers in non-XR environments may now receive an unhandled ImportError where they previously got None.
  • The Fabric/USD copy logic and session lifecycle fix are well-structured with appropriate fallbacks, but the removal of the ImportError guard changes the public return contract of show_instruction from silent None to a raised exception, which could affect non-XR callers. The Vec3Type annotation/default mismatch is minor but adds type-checker noise.
  • source/isaaclab/isaaclab/ui/xr_widgets/instruction_widget.py — ImportError guard removal and translation type inconsistency.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/ui/xr_widgets/instruction_widget.py Migrates from deprecated omni.kit.xr.scene_view.utils to omni.kit.scene_view.xr_utils; adds CopyFabricPrim path for Fabric-enabled environments; clears selection post-copy. The removal of the ImportError guard changes the return contract (None → exception) and the tuple default for translation is inconsistent with the Vec3Type annotation.
source/isaaclab_teleop/isaaclab_teleop/session_lifecycle.py Removes an invalid .unsubscribe() call on the pre-shutdown event subscription before setting it to None; cleanup is now left to Python GC / carb.eventdispatcher's own ref-counting, which matches the correct API contract for observe_event subscriptions.
apps/isaaclab.python.xr.openxr.kit Adds omni.fabric.commands kit dependency required for the new CopyFabricPrim code path in the instruction widget; comment explains the rationale.
source/isaaclab/config/extension.toml Patch version bump 4.5.0 → 4.5.1 to accompany the bug fixes.
source/isaaclab/docs/CHANGELOG.rst Adds 4.5.1 changelog section with two entries matching the PR description; formatting follows existing RST conventions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["show_instruction()"] --> B{prim_path_source\nprovided?}
    B -- No --> G[space_stack = empty]
    B -- Yes --> C{Fabric enabled?\n/app/useFabricSceneDelegate}
    C -- Yes --> D["DeleteFabricPrims\nat target_prim_path\n(if exists in rt_stage)"]
    D --> E["CopyFabricPrim\nprim_path_source → target_prim_path"]
    E -- success=True --> F[copy_succeeded = True]
    E -- exception/failure --> H["Fallback: delete USD prim\nat target_prim_path (if valid)"]
    C -- No --> H
    H --> I["CopyPrim\nprim_path_source → target_prim_path"]
    I -- success --> F
    I -- failure --> G
    F --> J["Deselect target_prim_path\n(Fabric + USD source types)"]
    J --> G
    G --> K["Build space_stack\n+ translation + look-at-camera"]
    K --> L["UiContainer(XRSceneView, widget_component,\nspace_stack=space_stack)"]
    L --> M["Schedule auto-hide timer\n(if display_duration set)"]
    M --> N[Return UiContainer]
Loading

Last reviewed commit: a717d37

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@@ -125,7 +128,7 @@ def compute_widget_dimensions(
def show_instruction(
text: str,
prim_path_source: str | None = None,
translation: Gf.Vec3d = Gf.Vec3d(0, 0, 0),
translation: Vec3Type = (0, 0, 0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

translation default type doesn't match Vec3Type annotation

Vec3Type is defined as Gf.Vec3f | Gf.Vec3d, but the default value (0, 0, 0) is a plain Python tuple, which is outside that union. Since from __future__ import annotations makes all annotations lazy strings, this causes no runtime error — but static type checkers (mypy/pyright) will flag it, and the docstring below still describes the parameter as Gf.Vec3d.

Either:

  • Broaden Vec3Type to include tuple[float, float, float] / Sequence[float], or
  • Keep the default as a Gf.Vec3d: translation: Vec3Type = Gf.Vec3d(0, 0, 0) (moving the import out of TYPE_CHECKING for the default expression), or
  • Update the docstring to reflect the new accepted types.

@hougantc-nvda
hougantc-nvda force-pushed the hougantc/fix-xr-instruction-widget branch from 2adbbab to 0234e92 Compare March 3, 2026 18:25
@kellyguo11
kellyguo11 merged commit 67b60de into isaac-sim:develop Mar 4, 2026
6 of 11 checks passed
@hougantc-nvda
hougantc-nvda deleted the hougantc/fix-xr-instruction-widget branch April 30, 2026 16:23
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 isaac-sim Related to Isaac Sim team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants