LumaPictures / usd-qt

Reusable Qt Components for Pixar's USD
Other
153 stars 41 forks source link

usd-qt outliner dialog crashing on show() #22

Closed DanEnglesson closed 5 years ago

DanEnglesson commented 5 years ago

Hi, I'm building the usd-qt code after seeing it being used at Siggraph this year with AL_USDMaya and it looks really useful!

I'm using cmake version 3.12.1 to build it and I figured I should use the same boost as what the core USD has been built with, in this case boost 1.55, like this:

cmake3  \
-DCMAKE_INSTALL_PREFIX='/usr/local/USD.18.09/USD_QT'  \
-DBOOST_INCLUDEDIR=/usr/local/USD.18.09/USD-core/include\
/mnt/home/dan.englesson/USD/usd-qt
make -j12 install

It builds and installs just fine. Output from build:

 CMake Warning (dev) at CMakeLists.txt:23 (find_package):
 Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
 Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
 command to set the policy and suppress this warning.

 Environment variable USD_ROOT is set to:

   /usr/local/USD.18.09/USD-core

 For compatibility, CMake is ignoring the variable.
 This warning is for project developers.  Use -Wno-dev to suppress it.

 -- Boost version: 1.55.0
 -- Found the following Boost libraries:
 --   python
 -- Configuring done
 -- Generating done
 -- Build files have been written to: /mnt/home/dan.englesson/USD/usd-qt_new/build

This installs fine, and most of it seems to work. Opening up Maya2018 with my installpath added to the PYTHONPATH environment variable and everything seems to work fine, until I do dialog.show().

def GetStage():
    from AL import usdmaya
    stageCache = usdmaya.StageCache.Get()
    stages = stageCache.GetAllStages()
    if stages:
        return stages[0]
    else:
        raise RuntimeError('No stage loaded in AL_USDMaya!')

def OpenOutliner():
    from pxr.UsdQtEditors.outliner import UsdOutliner
    stage = GetStage()
    dialog = UsdOutliner(stage)
    dialog.show() <----------------------------------------------------- segfault
    return dialog

dlg = OpenOutliner()

Attaching the maya crash-log, and I think it's boost related. crashLog.txt _ZN5boost4asio6detail15task_io_service3runERNS_6system10error_codeE

If I lock it with dialog.exec_() just after dialog.show() I don't get it to crash, which point to some threading issue. However, with this working the updates only shows up if I click in the maya viewport after each change and it doesn't seem to sync with the selection in the viewport. I'm just curious to hear how you compiled it. When I compile it with boost 1.61 which is the boost for maya2018 I get some weird issues with not finding __MFB_FULL_PACKAGE_NAME

# Error: 'NoneType' object has no attribute '__MFB_FULL_PACKAGE_NAME'
# Traceback (most recent call last):
#   File "<maya console>", line 18, in <module>
#   File "<maya console>", line 11, in OpenOutliner
#   File "/usr/local/USD.18.09/USD_QT/lib/python/pxr/UsdQtEditors/outliner.py", line 36, in <module>
#     from pxr.UsdQt.hierarchyModel import HierarchyBaseModel
#   File "/usr/local/USD.18.09/USD_QT/lib/python/pxr/UsdQt/hierarchyModel.py", line 30, in <module>
#     from ._bindings import PrimFilterCache, _HierarchyCache
#   File "/usr/local/USD.18.09/USD_QT/lib/python/pxr/UsdQt/_bindings.py", line 25, in <module>
#     import pxr.UsdQt._usdQt as _usdQt
# AttributeError: 'NoneType' object has no attribute '__MFB_FULL_PACKAGE_NAME' # 

Any help would be much appreciated. Thanks, Dan

bfloch commented 5 years ago

That's exactly the crash that we are seeing. I recognize the following symbol in @DanEnglesson crashlog: QItemSelectionModel::isSelected(QModelIndex const&) const

I've stepped through with a python debugger and was able to isolate it happening here: https://github.com/LumaPictures/usd-qt/blob/master/pxr/usdQt/hierarchyModel.py#L247

The root variable seems to be a valid python object at this point, which is a wrapped Usd object I believe. My understanding is that the Qt API at this point accepts a void pointer while PySide should allow the object to be stored. So maybe it is the boost wrapper causing problems here as Dan suggests. Ideas?

nrusch commented 5 years ago

Hi @DanEnglesson,

My immediate suspicion here is that this may be related to the fact that there are two different versions of Boost at play here. Is there any chance you can try building both USD and usd-qt against Boost 1.61? This combination is working well for us internally (in and out of Maya).

DanEnglesson commented 5 years ago

Thanks bfloch and nrusch, I will test building with Boost 1.61 for USD and usd-qt today and see if it works. I'll report back once it's been built and tested.

DanEnglesson commented 5 years ago

Hi, unfortunately I'm still seeing the same error with 1.61 for USD and usd-qt. crashLog.txt

Maybe I'm starting the outliner in a weird way, but I doubt it since it loads fine with dialog.exec_(), however, I noticed that it is missing the header names:

def GetStage():
    from AL import usdmaya
    stageCache = usdmaya.StageCache.Get()
    stages = stageCache.GetAllStages()
    if stages:
        return stages[0]
    else:
        raise RuntimeError('No stage loaded in AL_USDMaya!')

def OpenOutliner():
    from pxr.UsdQtEditors.outliner import UsdOutliner
    stage = GetStage()
    dialog = UsdOutliner(stage)
    dialog.show() <----------------------------------------------------- segfault
    return dialog

dlg = OpenOutliner()
csaez commented 5 years ago

The intended usage requires more than just passing the stage in memory: https://github.com/LumaPictures/usd-qt/blob/master/pxr/usdQtEditors/outliner.py#L911

You can try passing the filepath set in the AL_USDMaya proxy shape to FromUsdFile (AL_USDMaya populate UsdStageCache, so Usd will reuse the stage in memory instead of loading a brand new from disk).

DanEnglesson commented 5 years ago

Hi csaez, thanks for your suggestion. I've tried it out and it still fails. Just loading it directly with FromUsdFile fails as well, which might be easier to debug as well:

def OpenOutliner():
    from pxr.UsdQtEditors.outliner import UsdOutliner
    dialog = UsdOutliner.FromUsdFile('/mnt/home/dan.englesson/USD/kitchen_scene/Kitchen_set.usd')
    dialog.show()
    dialog.raise_()
    dialog.activateWindow()
    return dialog

dlg = OpenOutliner()

Thanks, Dan

nrusch commented 5 years ago

Hi @DanEnglesson @bfloch,

Sorry for the confusion here. Your mention of QItemSelectionModel::isSelected reminded me that @nxkb recently fixed a crash related to the outliner's item selection model, and the changes are currently on the dev branch (which is the basis of what we use internally).

Can you give this one more try from the tip of dev? Assuming it works, it's probably worth merging dev into master shortly, since this is a bit of a showstopper.

Thanks.

DanEnglesson commented 5 years ago

Hi @nrusch good idea! I'll test it out right away and report back!

Thanks, Dan

DanEnglesson commented 5 years ago

Yay the dev-branch worked! I was able to do dialog.show() without the crash.

image

def GetStage():
    from AL import usdmaya
    stageCache = usdmaya.StageCache.Get()
    stages = stageCache.GetAllStages()
    if stages:
        return stages[0]
    else:
        raise RuntimeError('No stage loaded in AL_USDMaya!')

def OpenOutliner():
    from pxr.UsdQtEditors.outliner import UsdOutlinerDialog
    stage = GetStage()
    dialog = UsdOutlinerDialog(stage)
    dialog.show()
    return dialog

dlg = OpenOutliner()

So to conclude, this bug seems to have been resolved in your dev branch.

However, there still seem to be some viewer update issues with changing variants and activating/deactivating objects. If I deactivate the table, it wont update in the viewer unless I move around a bit. Same with switching variant on the table chairs. Have you guys experienced that? Maybe I opened it in a weird way, see code above, but it seems like the header is incorrect as well. Just want to make sure I'm doing this correctly.

Many thanks for the help resolving this! Dan

nrusch commented 5 years ago

Great, thanks for testing, and glad to hear that worked. I've gone ahead and merged dev into master.

@nxkb may be able to provide some more insight into the behavior (or lack thereof) that you're seeing with AL_usdmaya, but I'm going to go ahead and close this issue.

DanEnglesson commented 5 years ago

Sounds good, thanks for all the help on this. cheers, Dan

nxkb commented 5 years ago

Hi @DanEnglesson , The stock version of the outliner is missing some pieces needed for syncing selection to the maya scene.

There are a couple of callbacks that need to be hooked up to get that behavior. For the demo you saw we had hooked up the view's primSelectionChanged to the "AL_usdmaya_ProxyShapeSelect" command, and then in the other direction we have maya's SelectionChanged event hooked up to something that will expand and select the items in the view.

The thought is to add that customized outliner to the AL_usdmaya repo so it can be kept in sync with that tool.

DanEnglesson commented 5 years ago

Thanks for the info @nxkb that's good to know!

Thanks, Dan