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

Fixed crash caused by out of date stage map #1116

Conversation

kxl-adsk
Copy link

When using the onStageInvalidate notification, extra care has to be taken to NOT trigger any notification that would result in pulling on stage map. This notification is sent during dirty propagation, and we can't trigger compute from it (number one DG rule).
We didn't fully follow this rule and started to send Ufe::SubtreeInvalidate. One of the listeners, i.e. Outliner, was trying to refresh the tree by pulling on the list of stages. This caused a lack of refresh and what's more important, the potential use of released memory in future calls.

The fix is to delay this notification till later when we know the stage map has been already populated.

@kxl-adsk kxl-adsk added ufe-usd Related to UFE-USD plugin in Maya-Usd workflows Related to in-context workflows labels Jan 26, 2021
@kxl-adsk kxl-adsk requested a review from seando-adsk January 26, 2021 17:32
@kxl-adsk
Copy link
Author

Linking with #1103

Comment on lines 407 to 413
#ifdef UFE_V2_FEATURES_AVAILABLE
auto p = notice.GetProxyShape().ufePath();
if (!p.empty()) {
Ufe::SceneItem::Ptr sceneItem = Ufe::Hierarchy::createItem(p);
if (sceneItem) {
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(sceneItem));
}
// We can't send notification to clients from dirty propagation.
// Delay it till the new stage is actually set during compute.
fInvalidStages.insert(p);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you didn't put fInvalidStages inside the ifdef V2 block. So I think that either all the code that uses this var should be inside an ifdef or remove the ifdef from this block. The block above should be ifdef protected because subtreeinvalidate is V2 only. But then line 396 should be moved outside the block.

Copy link
Author

Choose a reason for hiding this comment

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

It was mostly to leave the header file cleaner since code that is not guarded has no real performance impact (very low-frequency operation on empty set). It also builds with all flavors of the build, because the entire ufe folder is not included when building without UFE.

Let me know if you feel strongly about it and I can add the guards.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My one concern is that the population of fInvalidStages is done inside an ifdef V2 block. So if someone later adds code to use this fInvalidStages var and that code is not inside a V2 block, the new code will not work since the set will never have anything in it.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in ea81f44

@kxl-adsk kxl-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jan 27, 2021
@kxl-adsk kxl-adsk merged commit b97f2af into dev Jan 27, 2021
@kxl-adsk kxl-adsk deleted the kxl-adsk/MAYA-109348/notify_when_stage_changes_and_not_when_invalidates branch January 27, 2021 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd workflows Related to in-context workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants