Skip to content

UsdImagingDrawModeSceneIndex can return valid prims while sending out PrimsRemoved notifications #3892

@debloip-adsk

Description

@debloip-adsk

Description of Issue

The UsdImagingDrawModeSceneIndex can send out PrimsRemoved notifications, but still return valid prims for the paths it said it just removed. This leads to an incoherent view of the scene, and when combined with other parts of the codebase, can lead to a failing TF_VERIFY in HdChangeTracker.

We hit this issue in MayaHydra when opening root.usda in the attached folder, which uses the "cards" draw mode : root.zip

This is what seems to be going on :

  1. UsdImagingDrawModeSceneIndex receives PrimsAdded notifications.
  2. UsdImagingDrawModeSceneIndex sends out PrimsRemoved notifications to
    deal with an edge case (explained here :
    https://github.com/PixarAnimationStudios/OpenUSD/blob/v25.08/pxr/usdImaging/usdImaging/drawModeSceneIndex.cpp#L271-L300)
  3. HdMergingSceneIndex receives the PrimsRemoved notifications.
  4. HdMergingSceneIndex checks if a prim needs to actually be fully removed
    or if it needs to be resynced, as the prim could also be present in the
    other input scenes of the merging scene index. To do this, it calls GetPrim
    and GetChildPrimPaths on itself, and if a prim has a valid type, data source
    or child paths, then it is considered valid and resynced instead of removed.
    However, this GetPrim/GetChildPrimPaths call will end up recursing into all
    of the merging scene index's input scenes, including the UsdImagingDrawModeSceneIndex,
    which will (incorrectly) return a valid prim and child prim paths.
    https://github.com/PixarAnimationStudios/OpenUSD/blob/v25.08/pxr/imaging/hd/mergingSceneIndex.cpp#L507-L533
  5. HdMergingSceneIndex considers the prim to still be present, and sends out
    PrimsAdded notifications to resync.
  6. Any downstream scene index observer will receive the PrimsAdded notifications
    and will resync, most likely calling GetPrim/GetChildPrimPaths and again
    retrieving the valid-but-should-not-be prims and paths from the
    UsdImagingDrawModeSceneIndex.

Result : The downstream observers of the scene index chain have an incorrect view
of the scene.

In our case, when combined with the HdSceneIndexAdapterSceneDelegate's special handling
of geomSubsets, this can lead to HdChangeTracker trying to dirty a mesh prim that does not
exist, leading to a failing TF_VERIFY :
https://github.com/PixarAnimationStudios/OpenUSD/blob/v25.08/pxr/imaging/hd/changeTracker.cpp#L141

To note, this bug was previously avoided by HdMergingSceneIndex explicitly avoiding calling
GetPrim/GetChildPrimPaths on the scene index that sent the PrimsRemoved notifications. This
change is what unearthed the latent issue in UsdImagingDrawModeSceneIndex :
b4112c7

It seems like this HdMergingSceneIndex change also uncovered other latent issues such as #3563

System Information (OS, Hardware)

Linux, Windows, Mac

Package Versions

USD 25.05, USD 25.08

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions