maya-usd icon indicating copy to clipboard operation
maya-usd copied to clipboard

Updating references in the reference editor when they have been changed from external code

Open adubois-spin opened this issue 1 year ago • 2 comments

Problem

We have created a widget, made accessible from the outliner, that allows the user to change the expression variables of every USD layer in the stage. The possible values for each expression variable is accessible through a combo box.

Once we change one of the layer path through this widget, Maya reacts most of the time correctly to this change by doing the update in the outliner. The problem arise when we change an expression variable of a USD layer that contains a MayaReference, in our case we are updating an expression variable in a layer representing a rig. In this case, the outliner updates correctly, but the Maya Reference Editor does not, it still represents the old resolved name.

Proposed solutions

In Maya USD, you already have a USD listener for the Layer Editor, the LayerTreeModel object. This object has the responsibility to update the layer editor of any USD layer change, especially through the usd_layerChanged method. A first solution would be to filter the changes here and to update the reference editor from there in the code. This would be a quick and dirty solution.

A second solution would be to create a second USD listener in the code of the Maya Reference Editor. This listener only task would be for now to update the Maya Reference that would have been changed through the USD interface.

I personally think the second solution is better in term of design but it is also more costly to implement.

Support request

We have a second problem that arise in our widget. After modifying the expression variable, we reload the USD stage in our code calling stage.Reload(). Doing so raises an error in the script editor log. The error is the following:

Detected USD threading violation. Concurrent changes to layer(s) composed in stage {adress} rooted at {path}

Do you have an idea that would allow us to not get this error? From what I understand we made a change to the layer in a thread that is different from the changes made afterwards from a different thread. Do you know how we could update our USD stage without violating the thread rule?

adubois-spin avatar May 02 '25 11:05 adubois-spin

Hi, We need support regarding this issue. I did not put it as a bug because it seems like a big change to make, but could we get support regarding how to create a temporary patch that solves this problem?

adubois-spin avatar May 08 '25 14:05 adubois-spin

Thank you for sharing this with us. We will discuss the topic and get back to you.

wallworm avatar May 08 '25 19:05 wallworm