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

Fix crash in Attribute Editor when renaming a prim with pulled descendants #3979

Merged
merged 5 commits into from
Nov 21, 2024

Conversation

jufrantz
Copy link
Contributor

@jufrantz jufrantz commented Oct 28, 2024

This PR addresses a crash that occurs when renaming a USD prim with descendant prims edited as Maya, while the Attribute Editor is visible and displaying the prim being renamed. I observed the issue on Maya 2023 and 2025 on Linux. It occurs since PR #3861.

The crash can be reproduced using this maya scene. To trigger the issue, open the AE, select and rename a prim such as /Root1. This should result in a hard crash within TPSdatabase::doRebuild, typically producing the following stack trace:

  TPSdataNode::typeName(bool) const
  TPSdatabase::generateUI(QLayout*, TPSdataNode*, bool)
  TPSdatabase::generateUI(QLayout*, TdependNode*, bool)
  TPSdatabase::doRebuild(Tevent const&)
  /usr/autodesk/maya2025/lib/libSharedUI.so(+0x3cae17) [0x7f694dc14e17]
  TeventHandler::doIdles()
  /usr/autodesk/maya2025/lib/libExtensionLayer.so(+0x33ccf5) [0x7f6947411cf5]
  QObject::event(QEvent*)
  QApplicationPrivate::notify_helper(QObject*, QEvent*)
  /usr/autodesk/maya2025/lib/libExtensionLayer.so(+0x3271a3) [0x7f69473fc1a3]
  QCoreApplication::notifyInternal2(QObject*, QEvent*)
  QTimerInfoList::activateTimers()
  /usr/autodesk/maya2025/lib/libQt6Core.so.6(+0x3e36ac) [0x7f69440bb6ac]
  g_main_context_dispatch
  /lib64/libglib-2.0.so.0(+0x4dea8) [0x7f6926a24ea8]
  g_main_context_iteration
  QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
  QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
  QCoreApplication::exec()
  Tapplication::start()
  /usr/autodesk/maya2025/bin/maya.bin() [0x41ba3e]
  /usr/autodesk/maya2025/bin/maya.bin() [0x416b60]
  __libc_start_main
  /usr/autodesk/maya2025/bin/maya.bin() [0x41a1ce]

While investigating the cause of the crash, I simplified the context and was able to reproduce it using the following script. It triggers the crash by disconnecting a proxyAccessor output during Ufe::ObjectRename, which is a subset of the operations performed by OrphanedNodesManager on rename since PR #3861.

import ufe
from maya import cmds, mel

# Open the test scene
cmds.file("crash_ae_on_ufe_rename.ma", open=True, force=True)

# Add observer
class CrashyObserver(ufe.Observer):
    def __call__(self, notif):
        if isinstance(notif, ufe.ObjectRename):
            for dest in cmds.connectionInfo("stageShape1.AP__Root1_combinedVisibility", dfs=True):
                cmds.disconnectAttr("stageShape1.AP__Root1_combinedVisibility", dest)

obs = CrashyObserver()
ufe.Scene.addObserver(obs)

# Select the prim to rename and ensure the AE is shown
cmds.select("|stage1|stageShape1,/Root1")
mel.eval('showEditor("|stage1|stageShape1,/Root1")')

# Wait and rename the prim. Maya shoud crash.
cmds.rename("NewRoot1")

I could not find the root cause of this crash within the maya-usd codebase. The issue may lie on the Maya or UFE side, related to the timing of AE updates and Ufe::ObjectRename events. The workaround proposed in this PR defers the proxyAccessor connection updates, having them occur at a more appropriate time for the AE, preventing the crash.

Included Changes:

  • Modified mayaUsd.lib.proxyAccessor parent and unparent functions to accept an optional list of UFE children and parent paths: jufrantz/maya-usd@7bf2b98.
  • Thanks to this, OrphanedNodesManager does not alter Maya's selection when updating proxyAccessor connections: jufrantz/maya-usd@008b0da.
  • Updated OrphanedNodesManager to execute ProxyAccessorUndoItem::parentPulledObject on idle to avoid the crash. This change is enclosed within a #ifdef scope, making it easier to remove if a better fix becomes available: jufrantz/maya-usd@776e65d

This crash occurs when the Attribute Editor is visible and displaying a
USD prim that is being renamed, while we are updating proxyAccessor
connections for its descendant pulled objects.
@seando-adsk
Copy link
Collaborator

@jufrantz Would it be possible to create a unit test out of the script you posted above? I guess it will have to an interactive test (run within Maya) in order to have the AE.

Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk left a comment

Choose a reason for hiding this comment

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

Just waiting for the answers before approval.

@jufrantz
Copy link
Contributor Author

jufrantz commented Nov 12, 2024

@jufrantz Would it be possible to create a unit test out of the script you posted above? I guess it will have to an interactive test (run within Maya) in order to have the AE.

@seando-adsk, Alright, I can add a unit test that opens the AE and renames the selected prim to verify that the crash issue is resolved. I'll add this as soon as possible.

pierrebai-adsk
pierrebai-adsk previously approved these changes Nov 12, 2024
@jufrantz
Copy link
Contributor Author

jufrantz commented Nov 13, 2024

@seando-adsk I attempted to add a test.

I made a simple script that crashes when run manually in a maya session, but only if I wait between showing the AE and renaming the prim. When executed in one go, it doesn’t crash. I attempted to add it as an interactive unit-test, using cmds.flushIdleQueue and maya.utils.processIdleEvents before and after renaming the prim, as I suspect the crash might be related to queued AE refreshs, but this doesn’t crash.

It seems tricky to reproduce the crash in this context. Would it be acceptable if we skip adding this test?

@seando-adsk
Copy link
Collaborator

@jufrantz I've asked our QA team to create an automation test for this, so yes you can skip adding the test. I'll start the preflight.

@seando-adsk seando-adsk added bug Something isn't working core Related to core library crash and removed bug Something isn't working labels Nov 19, 2024
@seando-adsk
Copy link
Collaborator

@jufrantz Unfortunately there were test failures on Maya 2022, python 2 builds:

  File "...\maya-usd\test\lib\testMayaUsdProxyAccessor.py", line 35, in <module>
    from mayaUsd.lib import proxyAccessor as pa
  File "W:\install\RelWithDebInfo\MayaUSD\lib\python\mayaUsd\lib\proxyAccessor.py", line 328
    def __parent(*ufeItemPathStrings, doParenting=True, forceUnparenting=False):
                                                ^
SyntaxError: invalid syntax

I think its because the keyword-only args are not allowed after the capture of positional args. This is a python3 feature.

Sean

@jufrantz
Copy link
Contributor Author

@jufrantz Unfortunately there were test failures on Maya 2022, python 2 builds:

  File "...\maya-usd\test\lib\testMayaUsdProxyAccessor.py", line 35, in <module>
    from mayaUsd.lib import proxyAccessor as pa
  File "W:\install\RelWithDebInfo\MayaUSD\lib\python\mayaUsd\lib\proxyAccessor.py", line 328
    def __parent(*ufeItemPathStrings, doParenting=True, forceUnparenting=False):
                                                ^
SyntaxError: invalid syntax

I think its because the keyword-only args are not allowed after the capture of positional args. This is a python3 feature.

Sean

@seando-adsk,
Sorry for this. It is fixed by commit jufrantz@a5a1178
Thank you,
Julien

@seando-adsk seando-adsk assigned jufrantz and unassigned jufrantz Nov 21, 2024
@seando-adsk seando-adsk merged commit a239482 into Autodesk:dev Nov 21, 2024
11 checks passed
@seando-adsk
Copy link
Collaborator

@jufrantz As you can see I merged this PR. Thanks for submitting the crash fix and working thru all the test failures.

Sean

@jufrantz
Copy link
Contributor Author

Thank you very much @seando-adsk. I am glad that we can contribute to the project and happy to be involved.
Julien

@jufrantz jufrantz deleted the fix_ae_crash_on_prim_rename branch November 21, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to core library crash
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants