Skip to content
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

[MAYA-127101] VP2 crashes when rendering pointInstancer with unused prototypes since maya-usd 0.21 #2812

Closed
jufrantz opened this issue Jan 10, 2023 · 7 comments
Assignees
Labels
bug Something isn't working regression Something that used to work is no longer working reproduced Issue has been reproduced

Comments

@jufrantz
Copy link
Contributor

Describe the bug

Using maya-usd 0.21.0, we are experiencing maya crashes when VP2 rendering USD pointInstancers.
They occur when the pointInstancer has at least an invisible prototype, such as when it does not appear in protoIndices attrib.
This is a very typical case in our production scenes.

Steps to reproduce

  1. Execute following python script in maya. It will create a maya-usd proxyShape, its stage is definining a pointInstancer with an unused prototype (Sphere)
import pxr.Sdf
import maya.cmds

# Create a layer defining a PointInstancer with 2 prototypes but only Cube is used.
layer = pxr.Sdf.Layer.CreateAnonymous(".usd")
layer.ImportFromString("""#usda 1.0
def PointInstancer "PI"
{
    point3f[] positions = [(0, 0, 0), (2, 0, 2), (2, 0, -2), (-2, 0, -2), (-2, 0, 2)]
    int[] protoIndices = [1, 1, 1, 1, 1]
    rel prototypes = [</PI/Protos/Sphere>, </PI/Protos/Cube>]

    def Scope "Protos"
    {
        def Sphere "Sphere" 
        {
        }
        
        def Cube "Cube"
        {
        }
    }
}""")

# Render the stage using maya-usd proxShape
maya.cmds.loadPlugin("mayaUsdPlugin", quiet=True)
proxyShape = maya.cmds.createNode("mayaUsdProxyShape")
maya.cmds.setAttr(".filePath", layer.identifier, type="string")
  1. Notice the crash, in our case a floating point exception is raised.

Expected behavior
VP2 should render the 5 instanced cubes without crash.

Specs (if applicable):

  • CentOS 7.8
  • gcc 9.3
  • maya 2022.4 / maya 2023.3
  • maya-usd 0.21.0
  • USD 22.11

Additional context

  • With maya-usd 0.20, the crash does not occur.
  • When all protos of pointInstancers are used, the crash does not occur.
@jufrantz jufrantz added the bug Something isn't working label Jan 10, 2023
@santosd santosd assigned santosd and santosg87 and unassigned santosg87 and santosd Jan 11, 2023
@santosg87
Copy link
Collaborator

Hi @jufrantz,

thank you for logging this, I am also able to reproduce this on our side on Mac. it's logged internally as MAYA-127101

@santosg87
Copy link
Collaborator

after a bit of investigating on this, this seems to be specific to the first item on the index array. if i have the same setup - but with only the sphere as my prototype, i don't get a crash.

it might be an issue with indexing needing to have 0 on the array in order to find the beginning of the index for the prototypes.

@santosg87 santosg87 added reproduced Issue has been reproduced regression Something that used to work is no longer working labels Jan 11, 2023
@jufrantz
Copy link
Contributor Author

Thank you @santosg87 for the clarification.
FWIW we applied this patch on our side as workarround:

--- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp
+++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp
@@ -836,7 +836,8 @@ void MayaUsdRPrim::_SyncSharedData(
 
     // If instancer is dirty, update instancing map
     if (HdChangeTracker::IsInstancerDirty(*dirtyBits, id)) {
-        bool instanced = !refThis.GetInstancerId().IsEmpty();
+        bool instanced = !refThis.GetInstancerId().IsEmpty() 
+            && !delegate->GetInstanceIndices(refThis.GetInstancerId(), id).empty());
 
         // UpdateInstancingMapEntry is not multithread-safe, so enqueue the call
         _delegate->GetVP2ResourceRegistry().EnqueueCommit([this, id, instanced]() {

@santosg87
Copy link
Collaborator

@jufrantz awesome, good to know!

from more info on other issues, this might be something on the pixar USD code. #2804 has a very similar crash to yours, although hitting it from a different code path.

someone pointed out they logged a bug with pixar already PixarAnimationStudios/OpenUSD#2149

@santosg87
Copy link
Collaborator

@jufrantz given that you have a workaround for the crash - would that be something you would want to contribute the code base? feel free to push a PR for it if you'd like :)

@santosg87 santosg87 changed the title VP2 crashes when rendering pointInstancer with unused prototypes since maya-usd 0.21 [MAYA-127101] VP2 crashes when rendering pointInstancer with unused prototypes since maya-usd 0.21 Jan 24, 2023
@DanEnglesson
Copy link

We are still hitting this in:

Centos 7.9
maya 2022.4
maya-usd 0.23.0
Own build of USD 21.11

Works fine in usdview. What is the status of this bug? It says in MAYA-126933 that this is fixed too but seems like it is not.

@jufrantz
Copy link
Contributor Author

We tested it with maya-usd 0.25 and this is fixed on our side.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something that used to work is no longer working reproduced Issue has been reproduced
Projects
Status: Done
Status: Done
Development

No branches or pull requests

4 participants