-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(physx): handle collection deletion events safely #7901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Xalzeroph
wants to merge
8
commits into
isaac-sim:develop
Choose a base branch
from
Xalzeroph:fix/rigid-collection-deletion-event
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−9
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e90b868
fix(physx): handle collection deletion events safely
Xalzeroph 4eb09bd
fix(physx): preserve string prim deletion callbacks
Xalzeroph 2ff1ff7
test(physx): cover legacy string deletion paths
Xalzeroph 945fb2c
docs(physx): document deletion callback fix
Xalzeroph c6e8ad2
chore: merge latest develop
Xalzeroph 2cd9264
docs(physx): document supported deletion callback inputs
Xalzeroph fddce69
style(physx): normalize regression test file ending
Xalzeroph ef0c25f
style(physx): terminate changelog fragment cleanly
Xalzeroph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
source/isaaclab_physx/changelog.d/rigid-collection-deletion-callback.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed rigid object collection deletion handling to preserve legacy string-path callbacks and normalize event payloads before invalidation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
source/isaaclab_physx/test/assets/test_rigid_object_collection_callbacks.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| from types import SimpleNamespace | ||
|
Xalzeroph marked this conversation as resolved.
|
||
| from unittest.mock import Mock | ||
|
|
||
| import pytest | ||
|
|
||
| from isaaclab_physx.assets.rigid_object_collection.rigid_object_collection import RigidObjectCollection | ||
|
|
||
|
|
||
| def _make_collection_for_deletion_test() -> RigidObjectCollection: | ||
| collection = object.__new__(RigidObjectCollection) | ||
| collection.cfg = SimpleNamespace( | ||
| rigid_objects={"object": SimpleNamespace(prim_path="/World/Table_[^/]*/Object_0")} | ||
| ) | ||
| collection._is_initialized = True | ||
| collection._root_view = object() | ||
| collection._debug_vis_handle = None | ||
| return collection | ||
|
|
||
|
|
||
| def test_prim_deletion_string_path_preserves_legacy_input() -> None: | ||
| collection = _make_collection_for_deletion_test() | ||
|
|
||
| collection._on_prim_deletion("/World/Table_0/Object_0") | ||
|
|
||
| assert collection.is_initialized is False | ||
| assert collection._root_view is None | ||
|
|
||
|
|
||
| def test_prim_deletion_event_invalidates_matching_collection() -> None: | ||
| collection = _make_collection_for_deletion_test() | ||
|
|
||
| collection._on_prim_deletion(SimpleNamespace(payload={"prim_path": "/World/Table_0/Object_0"})) | ||
|
|
||
| assert collection.is_initialized is False | ||
| assert collection._root_view is None | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("event", [{"prim_path": "/"}, SimpleNamespace(payload={"prim_path": "/"})]) | ||
| def test_prim_deletion_event_accepts_root_payload_forms(event) -> None: | ||
| collection = _make_collection_for_deletion_test() | ||
|
|
||
| collection._on_prim_deletion(event) | ||
|
|
||
| assert collection.is_initialized is False | ||
| assert collection._root_view is None | ||
|
|
||
|
|
||
| def test_nonmatching_prim_deletion_leaves_collection_initialized() -> None: | ||
| collection = _make_collection_for_deletion_test() | ||
|
|
||
| collection._on_prim_deletion(SimpleNamespace(payload={"prim_path": "/World/Other/Object_0"})) | ||
|
|
||
| assert collection.is_initialized is True | ||
| assert collection._root_view is not None | ||
|
|
||
|
|
||
| def test_prim_deletion_clears_callbacks_when_invalidation_fails() -> None: | ||
| collection = _make_collection_for_deletion_test() | ||
| collection._invalidate_initialize_callback = Mock(side_effect=RuntimeError("teardown failed")) | ||
| collection._clear_callbacks = Mock() | ||
|
|
||
| with pytest.raises(RuntimeError, match="teardown failed"): | ||
| collection._on_prim_deletion({"prim_path": "/"}) | ||
|
|
||
| collection._clear_callbacks.assert_called_once_with() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.