简体   繁体   English

如何使用 WinUI 2.0 树视图控件诊断 UWP windows 商店应用程序中的崩溃

[英]How to diagnose crashes in a UWP windows store app with WinUI 2.0 tree view control

I have a UWP Windows store app with a WinUI 2.0 tree view control.我有一个带有 WinUI 2.0 树视图控件的 UWP Windows 商店应用程序。 I load the sub directory structure in the treeview based on user selection of a folder.我根据用户选择的文件夹加载 treeview 中的子目录结构。

The problem I am facing is that the application crashes when I select certain folders on my dev machine.我面临的问题是当我 select 我的开发机器上的某些文件夹时应用程序崩溃。 It works fine for other folders.它适用于其他文件夹。 I can see the same crash with some of my app users in the windows store diagnostic data.我可以在 windows 存储诊断数据中看到与我的一些应用程序用户相同的崩溃。

Here the call stack from my machine for the crash:这里是我机器的调用堆栈,用于崩溃:

Unhandled exception thrown: read access violation.
this->m_strongHost.ptr_ was nullptr.

Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::CacheManager::InitCollectionsCache() Line 787
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_cachemanager_partial.cpp(787)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::CacheManager::GetItem(int indexInItemCollection, IInspectable * * ppItem) Line 868
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_cachemanager_partial.cpp(868)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::GenerateContainerAtIndexImpl(int indexInItemCollection, Windows::UI::Xaml::IUIElement * * ppReturnValue) Line 189
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_iicg2_partial.cpp(189)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanelGenerated::GenerateContainerAtIndex(int index, Windows::UI::Xaml::IUIElement * * ppReturnValue) Line 567
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\winrtgeneratedclasses\moderncollectionbasepanel.g.cpp(567)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::Generate(DirectUI::ModernCollectionBasePanel::CollectionIterator iterator, Windows::UI::Xaml::Controls::LayoutReference referenceInformation, unsigned char goForward) Line 1374
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(1374)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::RunGenerate() Line 902
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(902)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::RunVirtualization() Line 628
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(628)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::MeasureOverride(Windows::Foundation::Size availableSize, Windows::Foundation::Size * pReturnValue) Line 521
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(521)
Windows.UI.Xaml.dll!DirectUI::FrameworkElementGenerated::MeasureOverrideProtected(Windows::Foundation::Size availableSize, Windows::Foundation::Size * pReturnValue) Line 1056
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\winrtgeneratedclasses\frameworkelement.g.cpp(1056)
Windows.UI.Xaml.dll!DirectUI::FrameworkElement::MeasureOverrideFromCore(CFrameworkElement * nativeTarget, float inWidth, float inHeight, float * outWidth, float * outHeight) Line 255
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\frameworkelement_partial.cpp(255)
[Inline Frame] Windows.UI.Xaml.dll!CFxCallbacks::FrameworkElement_MeasureOverride(CFrameworkElement *) Line 844
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\fxcallbacks.cpp(844)
Windows.UI.Xaml.dll!CFrameworkElement::MeasureCore(XSIZEF availableSize, XSIZEF & desiredSize) Line 1597
    at onecoreuap\windows\dxaml\xcp\core\core\elements\framework.cpp(1597)
Windows.UI.Xaml.dll!CUIElement::MeasureInternal(XSIZEF availableSize) Line 4121
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4121)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 3981
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(3981)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
    at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CLayoutManager::UpdateLayout(unsigned int controlWidth, unsigned int controlHeight) Line 279
    at onecoreuap\windows\dxaml\xcp\core\layout\layoutmanager.cpp(279)
Windows.UI.Xaml.dll!CCoreServices::NWDrawTree(HWWalk * pHWWalk, CWindowRenderTarget * pRenderTarget, VisualTree * pVisualTree, unsigned int forceRedraw, XRECT_WH * prcDirtyRect) Line 6354
    at onecoreuap\windows\dxaml\xcp\core\dll\xcpcore.cpp(6354)
Windows.UI.Xaml.dll!CCoreServices::NWDrawMainTree(CWindowRenderTarget * pIRenderTarget, bool fForceRedraw, XRECT_WH * prcDirtyRect) Line 6078
    at onecoreuap\windows\dxaml\xcp\core\dll\xcpcore.cpp(6078)
Windows.UI.Xaml.dll!CWindowRenderTarget::Draw(CCoreServices * fForceRedraw, unsigned int prcDirtyRect, XRECT_WH *) Line 136
    at onecoreuap\windows\dxaml\xcp\core\compositor\windowrendertarget.cpp(136)
Windows.UI.Xaml.dll!CXcpBrowserHost::OnTick() Line 545
    at onecoreuap\windows\dxaml\xcp\host\win\browserdesktop\winbrowserhost.cpp(545)
Windows.UI.Xaml.dll!CXcpDispatcher::Tick() Line 1449
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1449)
Windows.UI.Xaml.dll!CXcpDispatcher::OnReentrancyProtectedWindowMessage(HWND__ * msg, unsigned int lParam, unsigned __int64) Line 1041
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1041)
[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::ProcessMessage(HWND__ *) Line 890
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(890)
Windows.UI.Xaml.dll!CXcpDispatcher::WindowProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wParam, __int64 lParam) Line 839
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(839)
Windows.UI.Xaml.dll!CDeferredInvoke::DispatchQueuedMessage(bool * dispatchedWork, bool * hasMoreWork) Line 301
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(301)
[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::MessageTimerCallback() Line 1534
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1534)
Windows.UI.Xaml.dll!CXcpDispatcher::MessageTimerCallbackStatic(void * myUserData) Line 1526
    at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1526)
CoreMessaging.dll!Microsoft__CoreUI__Dispatch__TimeoutHandler$CallbackThunk(class System::Delegate *)
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::TimeoutManager::Callback_OnDispatch()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_DoWork()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_WindowProc()
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchMessageWorker()
Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessMessage(bool bDrainQueue, bool * pbWindowMessagesProcessed, bool * pbInvokeItemProcessed) Line 320
    at onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp(320)
Windows.UI.dll!Windows::UI::Core::CDispatcher::WaitAndProcessMessagesInternal(bool bRunAlwaysOnce, void * hEventWait) Line 1950
    at onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp(1950)
Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessEvents(Windows::UI::Core::CoreProcessEventsOption options) Line 596
    at onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp(596)
Windows.UI.Xaml.dll!CJupiterWindow::RunCoreWindowMessageLoop() Line 1234
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\jupiterwindow.cpp(1234)
[Inline Frame] Windows.UI.Xaml.dll!CJupiterControl::RunMessageLoop() Line 1065
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\jupitercontrol.cpp(1065)
Windows.UI.Xaml.dll!DirectUI::DXamlCore::RunMessageLoop() Line 2463
    at onecoreuap\windows\dxaml\xcp\dxaml\lib\dxamlcore.cpp(2463)
twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run()
twinapi.appcore.dll!<lambda>(void)()
SHCore.dll!_WrapperThreadProc()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()

As you can see the entire call stack only has windows system functions, any idea on how I can proceed?如您所见,整个调用堆栈只有 windows 系统函数,知道如何继续吗?

I was able to figure out what I was doing wrong - posting it here so that it can help others.我能够弄清楚我做错了什么 - 将其发布在这里以便它可以帮助其他人。

I was allowing users to filter out items in the tree view using other controls in the form, and I had implemented it such a way that on a node, I generate the list of children of a node when the bound property was accessed.我允许用户使用表单中的其他控件过滤树视图中的项目,并且我已经实现了这样一种方式,即在节点上,当访问绑定属性时,我生成节点的子节点列表。

This meant that I returned a new list of children each time the bound property was accessed, and the framework expects the list of children to be stable between immediate calls.这意味着每次访问绑定属性时我都会返回一个新的子列表,并且框架希望子列表在立即调用之间保持稳定。

The solution was to cache the list of children of a node so that I only generate a new list when something actually changed.解决方案是缓存节点的子节点列表,以便仅在实际发生更改时生成新列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM