Autodesk / Autodesk/maya-usd

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

Open
#4,207 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

# 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 ](https://github.com/Autodesk/maya-usd/blob/dev/lib/usd/ui/layerEditor/layerTreeModel.h) object. This object has the responsibility to update the layer editor of any USD layer change, especially through the [usd_layerChanged ](https://github.com/Autodesk/maya-usd/blob/dev/lib/usd/ui/layerEditor/layerTreeModel.h#L130) 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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/usd/ui/layerEditor/layerTreeModel.h, especially the usd_layerChanged method, and trace how the Maya Reference Editor observes USD layer changes. Also inspect the widget’s stage.Reload() call and the reported threading violation. Done means the Reference Editor reflects externally changed resolved names and stage updates no longer trigger the reported violation.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.