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-127478 fix bulk save of root layer filename #2864

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

pierrebai-adsk
Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk commented Feb 3, 2023

When doing a bulk-save of layers when saving a Maya scene for the first time, the multiple-parts of the saving process could end-up using stale data. That is because there is a first batch-save delegate (customizable callback) that can do a partial save, then a fallback save is done for any layer that did not get saved.

When a stage has just been created, it contains an anonymous root layer which gets replaced by a non-anonymous by the batch save delegate. When the root layer is swapped, the stage proxy shape is updated by setting its stage name attribute. Unfortunately, the USD stage object was being cached and the attribute change was thus not use immediately. Thus the 2nd part fallback-save thought that the root layer was still anonymous.

The fix is to refresh the cached USD stages by pulling again on the proxy stage node so that it updates itself when its attributes have been changed.

When doing a bulk-save of layers when saving a Maya scene for the first time, the multiple-parts of teh saving process could end-up using stale data. That is because there is a first batch-save delegate (customizable callback) that can do a partial save, then a fallback save is done for any layer that did not get saved.

When a stage has just been created, it contains an anonymous root layer which gets replaced by a non-anonymous by the batch save delegate. When the root layer is swapped, the stage proxy shape is updated by setting its stage name attribute.  Unfortunately, the USD stage object was being cached and the attribute chage was thus not use immediately. Thus the 2nd part fallback-save thought that the root layer was still anonymous.

The fix is to refresh the cached USD stages by pulling again on the proxy stage node so that it updates itself when its attributes have been changed.
@pierrebai-adsk pierrebai-adsk added adsk Related to Autodesk plugin bug Something isn't working labels Feb 3, 2023
// to be saved because the saving might have modified the proxy shape
// attributes and we need to re-evaluate these nodes so that the stages
// are re-created with the new attribute values if needed.
refreshProxiesToSave();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By doing this pull here does it cause any notifications to be sent and could that potentially mess up the clients since we've only done a partial save?

Copy link
Collaborator Author

@pierrebai-adsk pierrebai-adsk Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the point this is called, we are in a pre-save callback AFAIK, so there should be no issue. The "partial" of the comment is in reference to the fact not all layers may have been saved and we are about to save the layers that have not been saved by that partial operation.

OTOH, if the partial save saved only a subset of a complex hierarchy of layers, and the subsequent saving of the remaining layer change their name, they, yes we could be inconsistent in theory. But this was always the case, this PR does not change this nor fix this.

That is, if a stage has the layer hierarchy:

A
|--B
   |-- C

And the partial save only saved 'B' and the the fallback save saves A and C but changes C filenames for any reason, then the sub-layer reference in B won't be the one saved. There is not much we can do about it, but fortunately, this never happens in practice. It may be feasible to artificially trigger this bad behavior in head-less Maya by creating such a hierarchy and writing a batch save delegate that only saves B, but that would be stretching it...

@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Feb 6, 2023
@seando-adsk seando-adsk merged commit 1767b35 into dev Feb 16, 2023
@seando-adsk seando-adsk deleted the bailp/MAYA-127478/wrong-root-filename branch February 16, 2023 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin bug Something isn't working ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants