Hard freeze with `Edit as Maya` prims and `Usd.Notice` Python listeners
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
We are hiting maya hard freezes in production scenes.
This happens when the following are true:
- an USD prim is "edited as maya" (very common in our production scenes).
- a Python tool is listening for USD change notifications via Tf.Notice (also very common).
- a Python command - that triggers maya parallel evaluation - is executed, such as `maya.cmds.mayaUSDExport` / `mayaUSDMergeToUsd`.
**Steps to reproduce**
The Python reproduction below is intentionally minimal, but it still reflects the production scenario well.
```python
from pxr import Tf, Usd
from maya import cmds
from maya.api.OpenMaya import MGlobal
import mayaUsd.ufe
import mayaUsd.lib
# 1) Use parallel evaluation, disable evaluation cache.
cmds.evaluationManager(mode="parallel")
cmds.evaluator(enable=False, name="cache")
# 2) Create a simple scene with a prim edited as Maya.
stageShape = mayaUsd.ufe.createStageWithNewLayer('')
stage = mayaUsd.ufe.getStage(stageShape)
prim = stage.DefinePrim("/xform", "Xform")
with mayaUsd.lib.OpUndoItemList():
mayaUsd.lib.PrimUpdaterManager.editAsMaya(f"{stageShape},/xform")
# 3) Register a Python listener (similar to a python GUI tool).
def dummyNoticeHandler(*_):
return
listener = Tf.Notice.Register(Usd.Notice.StageEditTargetChanged, dummyNoticeHandler, stage)
# 4) Force evaluation from Python (similar to cmds.mayaUSDExport).
MGlobal.viewFrame(1)
MGlobal.viewFrame(2)
# --> Maya freezes.
```
**Expected behavior**
Maya should evaluate the scene without freezing.
**Additional context**
Inspecting the maya process thread backtraces suggests a deadlock, where:
- The main thread
- executes the `viewFrame` python command
- waits for parallel evaluation to finish.
- is very likely still holding the Python `GIL`.
- A worker thread
- during `MayaUsdProxyShapeBase::compute` / `ProxyAccessor::compute`.
- changes the stage edit-target using `pxr::UsdEditContext`
- tries to acquire the Python `GIL` to deliver the edit-target notice (`Usd.Notice.StageEditTargetChanged`) to Python handlers.
##### The main thread
```
Thread 1 (Thre07f547632ab8b in sched_yield () at /lib64/libc.so.6
#1 0x00007f5479374ed5 in em::ThreadRun::run(std::function) () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#2 0x00007f5479336bbf in tbb::detail::d1::task_arena_function::operator()() const () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#3 0x00007f54792a020e in tbb::detail::r1::isolate_within_arena(tbb::detail::d1::delegate_base&, long) () at /usr/local/autodesk/maya2026-x64/lib/libtbb.so.12
#4 0x00007f547932d5fa in em::ParallelExecution::evaluateImplementation() () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#5 0x00007f547936c184 in em::EvaluationGraph::evaluate(bool) () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#6 0x00007f547a404819 in TevaluationManager::evaluate(TdgContext&, bool) () at /usr/local/autodesk/maya2026-x64/lib/libDependEngine.so
#7 0x00007f547a3fc70b in () at /usr/local/autodesk/maya2026-x64/lib/libDependEngine.so
#8 0x00007f547a4a825e in TdependGraph::setTime(TanimTime const&, bool) () at /usr/local/autodesk/maya2026-x64/lib/libDependEngine.so
#9 0x00007f5482c0ab5d in Autodesk::Maya::OpenMaya20260000::MGlobal::viewFrame(Autodesk::Maya::OpenMaya20260000::MTime const&) () at /usr/local/autodesk/maya2026-x64/lib/libOpenMaya.so
#10 0x00007f5482c0acb5 in Autodesk::Maya::OpenMaya20260000::MGlobal::viewFrame(double) () at /usr/local/autodesk/maya2026-x64/lib/libOpenMaya.so
#11 0x00007f5424182841 in viewFrame(PyObject*, PyObject*) (arg=0x7f546f1a63e8 <_PyRuntime+1800>) at /mnt/data/jenkins/workspace/maya/src/Maya/src/OpenMayaPython/src/OpenMaya/Global/MPyMGlobal.cpp:1054
#12 0x00007f546ee2e8ad in cfunction_vectorcall_O (func=0x7f5424c776a0, args=0x7f542c7bf078, nargsf=, kwnames=) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Include/cpython/methodobject.h:52
#13 0x00007f546edee444 in _PyObject_VectorcallTstate (kwnames=0x6ee361f8, nargsf=, args=0x7f542c7bf078, callable=0x7f5424c776a0, tstate=0x7f546f1ce698 <_PyRuntime+166328>) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Include/internal/pycore_call.h:92
#14 0x00007f546edee444 in PyObject_Vectorcall (callable=callable@entry=0x7f5424c776a0, args=args@entry=0x7f542c7bf078, nargsf=, kwnames=kwnames@entry=0x0) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Objects/call.c:299
#15 0x00007f546ed9ddac in _PyEval_EvalFrameDefault (tstate=, frame=, throwflag=) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/ceval.c:7307
#16 0x00007f546eeb9281 in _PyEval_EvalFrame (throwflag=0, frame=0x7f542c7bf020, tstate=0x7f546f1ce698 <_PyRuntime+166328>) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Include/internal/pycore_ceval.h:73
#17 0x00007f546eeb9281 in _PyEval_Vector (tstate=tstate@entry=0x7f546f1ce698 <_PyRuntime+166328>, func=func@entry=0x7f53034fbce0, locals=locals@entry=0x7f54253db000, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/ceval.c:6434
#18 0x00007f546eeb9326 in PyEval_EvalCode (co=0x7f52ca4f47b0, globals=, locals=0x7f54253db000) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/ceval.c:1148
#19 0x00007f547a7053c6 in TpythonInterpreter::executeCommand(Tstring const&, bool, bool, TinterpreterResult*) () at /usr/local/autodesk/maya2026-x64/lib/libCommandEngine.so
```
##### The maya EM worker thread
```
Thread 58 (Thread 0x7f53957fe700 (LWP 386404)):
#0 0x00007f54766d6878 in pthread_cond_timedwait@@GLIBC_2.3.2 () at /lib64/libpthread.so.0
#1 0x00007f546eeb839f in PyCOND_TIMEDWAIT (us=, mut=0x7f546f1a5e98 <_PyRuntime+440>, cond=0x7f546f1a5e68 <_PyRuntime+392>) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/condvar.h:73
#2 0x00007f546eeb839f in take_gil (tstate=tstate@entry=0x7f5234002bc0) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/ceval_gil.h:231
#3 0x00007f546eeb888e in PyEval_RestoreThread (tstate=tstate@entry=0x7f5234002bc0) at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/ceval.c:521
#4 0x00007f546eef6bf8 in PyGILState_Ensure () at /mnt/data/jenkins/workspace/3dsmax-conan-recipes@tmp/.conan/data/cpython/3.11.9/3dsmax/testing/build/b9d388bf5e1f3cb7483a70ee89d43fe322c022b2/src/Python/pystate.c:1712
#5 0x00007f52f1e11215 in pxrInternal_v0_24_11__pxrReserved__::TfPyLock::Acquire() () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/libusd_tf.so
#6 0x00007f52d9b6eefe in () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/python/pxr/Tf/_tf.so
#7 0x00007f52d9b6e7d9 in () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/python/pxr/Tf/_tf.so
#8 0x00007f52f1dc708b in pxrInternal_v0_24_11__pxrReserved__::Tf_NoticeRegistry::_Deliver(pxrInternal_v0_24_11__pxrReserved__::TfNotice const&, pxrInternal_v0_24_11__pxrReserved__::TfType const&, pxrInternal_v0_24_11__pxrReserved__::TfWeakBase const*, void const*, std::type_info const&, std::vector, std::allocator > > const&, std::pair >*, std::_List_iterator > const&) () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/libusd_tf.so
#9 0x00007f52f1dc8225 in pxrInternal_v0_24_11__pxrReserved__::Tf_NoticeRegistry::_Send(pxrInternal_v0_24_11__pxrReserved__::TfNotice const&, pxrInternal_v0_24_11__pxrReserved__::TfType const&, pxrInternal_v0_24_11__pxrReserved__::TfWeakBase const*, void const*, std::type_info const&) () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/libusd_tf.so
#10 0x00007f52f1e0f42f in pxrInternal_v0_24_11__pxrReserved__::TfNotice::_Send(pxrInternal_v0_24_11__pxrReserved__::TfWeakBase const*, void const*, std::type_info const&) const () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/libusd_tf.so
#11 0x00007f52f30f828f in pxrInternal_v0_24_11__pxrReserved__::UsdStage::SetEditTarget(pxrInternal_v0_24_11__pxrReserved__::UsdEditTarget const&) () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/libusd_usd.so
#12 0x00007f52f307d018 in pxrInternal_v0_24_11__pxrReserved__::UsdEditContext::UsdEditContext(pxrInternal_v0_24_11__pxrReserved__::TfWeakPtr const&, pxrInternal_v0_24_11__pxrReserved__::UsdEditTarget const&) () at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/lib/libusd_usd.so
#13 0x00007f52f9fbc21b in MayaUsd_v0::ComputeContext::ComputeContext(MayaUsd_v0::ProxyAccessor&, Autodesk::Maya::OpenMaya20260000::MObject const&, bool) (this=0x7f53957f5bb0, accessor=..., ownerNode=..., useTargetLayer=) at /usr/local/build/maya-usd/deps/OpenUSD/maya2026-x64/include/pxr/base/tf/refPtr.h:1093
#14 0x00007f52f9fbb18e in MayaUsd_v0::ProxyAccessor::compute(Autodesk::Maya::OpenMaya20260000::MPlug const&, Autodesk::Maya::OpenMaya20260000::MDataBlock&, bool) (this=0x16398c00, plug=..., dataBlock=..., useTargetLayer=) at /u/local/src/maya-usd/lib/mayaUsd/nodes/proxyAccessor.cpp:505
#15 0x00007f52f9fcbcb8 in MayaUsd_v0::ProxyAccessor::compute(std::unique_ptr > const&, Autodesk::Maya::OpenMaya20260000::MPlug const&, Autodesk::Maya::OpenMaya20260000::MDataBlock&, bool) (useTargetLayer=, dataBlock=..., plug=..., accessor=std::unique_ptr = {...}) at /u/local/src/maya-usd/lib/mayaUsd/nodes/proxyAccessor.h:147
#16 0x00007f52f9fcbcb8 in pxrInternal_v0_24_11__pxrReserved__::MayaUsdProxyShapeBase::compute(Autodesk::Maya::OpenMaya20260000::MPlug const&, Autodesk::Maya::OpenMaya20260000::MDataBlock&) (this=this@entry=0x20bd6d20, plug=..., dataBlock=...) at /u/local/src/maya-usd/lib/mayaUsd/nodes/proxyShapeBase.cpp:716
#17 0x00007f52fa5869a3 in MayaUsd_v0::ProxyShape::compute(Autodesk::Maya::OpenMaya20260000::MPlug const&, Autodesk::Maya::OpenMaya20260000::MDataBlock&) (this=0x20bd6d20, plug=..., dataBlock=...) at /u/local/src/maya-usd/plugin/adsk/plugin/ProxyShape.cpp:109
#18 0x00007f5482c8a75b in THsurfaceShape::computePlug(Tplug const&, TdataBlock&) () at /usr/local/autodesk/maya2026-x64/lib/libOpenMaya.so
#19 0x00007f547a40991e in TevaluationNode::evaluateDirtyPlugs(TdataBlockDG*, TevaluationNode::TdirtyPlugType) () at /usr/local/autodesk/maya2026-x64/lib/libDependEngine.so
#20 0x00007f547a40b33c in TevaluationNode::evaluate(em::SyncMessage const&) () at /usr/local/autodesk/maya2026-x64/lib/libDependEngine.so
#21 0x00007f54793329f0 in em::SchedulingTask::Spawner::execute(em::SchedulingNode&) () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#22 0x00007f5479332dd9 in em::SchedulingGraph::executeTheGraph(tbb::detail::d1::task_group&, em::SyncMessage const&) () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#23 0x00007f5479332e10 in em::ParallelExecution::taskEvaluation() () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#24 0x00007f5479332e49 in std::_Function_handler::_M_invoke(std::_Any_data const&) () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#25 0x00007f54793742fb in std::thread::_State_impl > >::_M_run() () at /usr/local/autodesk/maya2026-x64/lib/libEvaluationManager.so.1.1.27.0
#26 0x00007f547717eb23 in execute_native_thread_routine () at /lib64/libstdc++.so.6
#27 0x00007f54766d01ca in start_thread () at /lib64/libpthread.so.0
#28 0x00007f547632b8d3 in clone () at /lib64/libc.so.6
```
**Specs (if applicable):**
- Rocky Linux 8.10
- gcc 11.2.1
- Maya 2026
- Maya USD dev at 336c878
- OpenUSD v24.11
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.