OpenUSD icon indicating copy to clipboard operation
OpenUSD copied to clipboard

Non-deterministic composition with nested instancing and inherits / specializes arcs

Open chrizzFTD opened this issue 1 year ago • 2 comments

Description of Issue

Hello USD team, big fan!

I've encountered an issue where nested instancing + use of inherits / specializes leads to non-deterministic composition. I'd like to clarify if it's a bug or expected behavior from miss-use of these features.

Steps to Reproduce

Short version (visual check):

  1. Unzip broadcast_nested_instances.zip (it contains broadcast_nested_instances.usdz)
  2. Open broadcast_nested_instances.usdz in USDView and take a look at the viewport
  3. Re-open the same file through File -> Reopen Stage a couple of times. Without changing anything, the same stage composes differently:

non_deterministic_composition

Long version (Stats and variant selection check):

  1. Download and unzip the same broadcast_nested_instances.usdz file
  2. Save this python script and update the stage filepath to where broadcast_nested_instances.usdz is downloaded:
    """This script checks for the current "color" variant selection from an instanced "Window" model, as well as total prototype prim count.
    
    Results will differ per script execution.
    """
    from pxr import Usd, UsdUtils
    stage = Usd.Stage.Open("/path/to/downloaded/broadcast_nested_instances.usdz")
    window_instance_path = "/Catalogue/Model/Blocks/Block_With_Inherited_Windows/Building1/Windows/Window"
    window_instance = stage.GetPrimAtPath(window_instance_path)
    window_color_selection = window_instance.GetVariantSet("color").GetVariantSelection()
    print(f"Window color: {window_color_selection}")
    stats = UsdUtils.ComputeUsdStageStats(stage)
    print(f"Total Prototypes Prim Count: {stats['prototypes']['primCounts']['totalPrimCount']}")
    
  3. Run the script once to see the output of current color variant selected and total prototype prim count:
    Window color: blue
    Total Prototypes Prim Count: 17
    
  4. Run the python script a couple of times; the print output will be different from time to time, e.g in a bash shell:
    for i in `seq 10`;do python /path/to/check_composition.py;done
    
    outputs:
    Window color: red
    Total Prototypes Prim Count: 20
    Window color: 
    Total Prototypes Prim Count: 14
    Window color: blue
    Total Prototypes Prim Count: 17
    Window color: blue
    ...
    Total Prototypes Prim Count: 17
    Window color: 
    Total Prototypes Prim Count: 14
    Window color: blue
    Total Prototypes Prim Count: 17
    
  5. Note how values for window color vary between red, blue, "", as well as total prototype prim count between 14, 17, 20.

For convenience, I am also attaching a zip with the split usd files (before running usdzip): broadcast_nested_instances_uncompressed.zip

It contains the following files:

City-Entry-Assembly.1.usda
Model-Blocks-Block.1.usda
Model-Blocks-Block_With_Inherited_Windows.1.usda
Model-Blocks-Block_With_Specialized_Windows.1.usda
Model-Buildings-Multi_Story_Building.1.usda
Model-Elements-Window.1.usda

And the same issue will appear when opening City-Entry-Assembly.1.usda in usdview

Details on the structure

For full context, click for the long description on the composition choices (it's quite long):

broadcast_nested_instances

Expectations

This is what I would expect to see:

image

I'm also at SIGGRAPH this week, in case anyone wants to speak in person 😄

System Information (OS, Hardware)

  • CentOS-7 & Windows-10

Package Versions

  • USD-21.8 to USD-24.8 (tested many releases in between and all have the same behavior)

Build Flags

  • Windows: default build
  • CentOS: need to check

Thanks!

chrizzFTD avatar Aug 01 '24 07:08 chrizzFTD

Filed as internal issue #USD-9919

jesschimein avatar Aug 02 '24 16:08 jesschimein

There should be no way to misuse the composition arcs or instancing that does not produce error output (eg. introducing a reference cycle), so this surely sounds like a bug to me. Thanks for the great report- we’ll have a look!

spiffmon avatar Aug 18 '24 05:08 spiffmon

Hi @chrizzFTD, just wanted to let you know I've been looking into this issue. I've identified the root cause and the team is discussion potential solutions. We'll keep you and everyone posted here -- thanks again!

sunyab avatar Dec 05 '24 23:12 sunyab

Hi both, & thanks for the update!

chrizzFTD avatar Dec 09 '24 10:12 chrizzFTD