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

Remove incorrect Populate() on invalidate. #184

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,22 @@ void MayaUsdProxyShapeSceneIndex::_StageInvalidate(const MAYAUSDAPI_NS::ProxySta
{
_usdImagingStageSceneIndex->SetStage(nullptr);
_populated = false;
Populate();
// Simply mark populate as dirty and do not call
// Populate();
// here. Doing so is incorrect for two reasons:
// - _StageInvalidate() is a callback called during Maya invalidation.
// Populate() calls MayaUsdProxyShapeBase::getUsdStage(), which calls
// MayaUsdProxyShapeBase::compute(), which should not be done during
// dirty propagation.
// - Calling getUsdStage() through Populate() creates an invalidate
// callback dependency between _StageInvalidate() and
// the mayaUsd plugin MayaStagesSubject::onStageInvalidate(). During
// getUsdStage(), MayaStagesSubject::setupListeners() is called, and it
// depends on MayaStagesSubject::onStageInvalidate() being called first,
// otherwise setupListeners() and therefore getUsdStage() will fail.
//
// Invalidate callbacks should not have dependencies on one another ---
// it should be possible to call them in random order.
}

void MayaUsdProxyShapeSceneIndex::_ObjectsChanged(
Expand Down
14 changes: 14 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdStageFromFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import fixturesUtils
import mtohUtils
import usdUtils
import mayaUsd

import testUtils
from testUtils import PluginLoaded
Expand Down Expand Up @@ -51,11 +52,24 @@ def test_UsdStageFromFile(self):

cmds.setAttr('cubeShape.filePath', usdScenePath, type="string")

cmds.refresh()

populateCallsPost = cmds.mayaHydraInstruments("MayaUsdProxyShapeSceneIndex:NbPopulateCalls", q=True)

self.assertEqual(populateCallsPre+1, populateCallsPost)

cmds.mayaHydraCppTest(self.CONE_PATH, f="TestHydraPrim.fromAppPath")

def test_getStage(self):

# Any file will do.
usdScenePath = testUtils.getTestScene('testUsdNativeInstances', 'instancedCubeHierarchies.usda')

proxyShapePathStr = usdUtils.createStageFromFile(usdScenePath)

stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage()

self.assertIsNotNone(stage)

if __name__ == '__main__':
fixturesUtils.runTests(globals())