microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Dismissing a tooltip throws 4 native exceptions

Open kmgallahan opened this issue 1 year ago • 10 comments

Describe the bug

Simply dismissing a toolip in WinUI 3 throws 4 native exceptions:

Exception thrown at 0x775FD902 (KernelBase.dll) in SliderTest.exe: WinRT originate error - 0x80000013 : 'The given object has already been closed / disposed and may no longer be used.'.
onecore\com\combase\winrt\error\restrictederror.cpp(1016)\combase.dll!76C3E6BA: (caller: 76B565D2) ReturnHr(1) tid(67e4) 8007007E The specified module could not be found.
Exception thrown at 0x775FD902 (KernelBase.dll) in SliderTest.exe: WinRT originate error - 0x80070005 : 'The caller is not allowed to perform this operation on this object.'.
onecore\com\combase\winrt\error\restrictederror.cpp(1016)\combase.dll!76C3E6BA: (caller: 76B565D2) ReturnHr(2) tid(67e4) 8007007E The specified module could not be found.

These aren't fatal, but they show up in the debug output and are very distracting.

I just spent 2 hours debugging my own code trying to figure out what the problem was. Then I made a min repo app and discovered that simply clicking a Slider throws multiple unexceptional exceptions...

All of my projects involve interop with native code, so I always have mixed-mode debugging turned on.

Steps to reproduce the bug

  1. Create a blank WinUI 3 app using VS template
  2. Update to the latest WASDK & build tools preview versions
  3. Enable mixed-mode debugging
  4. Add this to the main window: <Slider Width="300" />
  5. Debug the app and click anywhere on the Slider

Alternatively, dismiss a tooltip produced by any other control.

Expected behavior

Don't throw 4 unexceptional exceptions when a tooltip is dismissed.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4 Preview 1: 1.4.230628000-preview1

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

kmgallahan avatar Aug 02 '23 15:08 kmgallahan

This was caused by the new windowed popup support (ShouldConstrainToRootBounds="False", which tooltips always use). During cleanup of the popup, it tries to unregister event handlers from an already-closed object, which threw an exception. The first exception stack (there is another for the ContentIsland):

    Microsoft_UI_Input!PreTranslateKeyboardInputWinRT::ComApi::SetPreTranslateHandler+0x32
    Microsoft_ui_xaml!InputSiteAdapter::UnsubscribeToInputEvents+0x3a
    Microsoft_ui_xaml!InputSiteAdapter::~InputSiteAdapter+0x10 
    Microsoft_ui_xaml!std::default_delete<CustomWriterRuntimeData>::operator()+0x21
    Microsoft_ui_xaml!CPopup::~CPopup+0x142 (61979b3f)

codendone avatar Aug 28 '23 16:08 codendone

@codendone

I'm also getting 2 exceptions when a tooltip is displayed:

onecoreuap\windows\moderncore\inputv2\systeminputhosts\lifted\lib\inputrootconfigurationproxy.cpp(57)\Microsoft.InputStateManager.dll!00007FFA6BD626B5: (caller: 00007FFA6BD408DB) LogHr(1) tid(4308) 8000000E A method was called at an unexpected time.
onecoreuap\windows\moderncore\inputv2\systeminputhosts\lifted\lib\inputrootconfigurationproxy.cpp(69)\Microsoft.InputStateManager.dll!00007FFA6BD627E5: (caller: 00007FFA6BD409B8) LogHr(2) tid(4308) 8000000E A method was called at an unexpected time.

Unsure if this is new behavior with 1.4 release.

kmgallahan avatar Aug 31 '23 10:08 kmgallahan

We're up to three separate issues here:

  1. The fix for the two OriginateErrors on close of the tooltip is in progress.
  2. The two exceptions when displaying a tooltip is new in 1.4 (internal bug). I think those are just debug output spew which shouldn't cause a debugger to break in, right? I don't know if these will be fixed in 1.4 servicing.
  3. The two combase.dll!76C3E6BA: (caller: 76B565D2) ReturnHr(1) tid(67e4) 8007007E The specified module could not be found. errors on close of the tooltip don't repro for me. I suspect these may be coming from the graphics driver on your machine. If you set a breakpoint on that address (76C3E6BA for this particular output) and dump the callstack hopefully that will tell us where those are coming from.

codendone avatar Sep 06 '23 18:09 codendone

@codendone combase.pdb wasn't found on the public ms symbol server

combase.dll!7649e6ba()	Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for combase.dll]	
combase.dll!763b771b()	Unknown
combase.dll!763b76f8()	Unknown
combase.dll!763b76bf()	Unknown
combase.dll!763b7602()	Unknown
combase.dll!763b7573()	Unknown
combase.dll!763b64dd()	Unknown
combase.dll!76452d7e()	Unknown
Microsoft.UI.Input.dll!KeyboardInputWinRT::ComApi::SetPreTranslateHandler()	Unknown
Microsoft.ui.xaml.dll!5708f4f7()	Unknown
Microsoft.ui.xaml.dll!5708edea()	Unknown
Microsoft.ui.xaml.dll!56a4584a()	Unknown
Microsoft.ui.xaml.dll!56cf83f5()	Unknown
Microsoft.ui.xaml.dll!56cf854b()	Unknown
Microsoft.ui.xaml.dll!56954404()	Unknown
Microsoft.ui.xaml.dll!5695a88e()	Unknown
Microsoft.ui.xaml.dll!5695a0b1()	Unknown
Microsoft.ui.xaml.dll!56ac0ddf()	Unknown
Microsoft.ui.xaml.dll!56ac0c5c()	Unknown
CoreMessagingXP.dll!Microsoft::WRL::Details::DelegateArgTraits<long >::DelegateInvokeHelper<struct Microsoft::WRL::Implements<struct Microsoft::WRL::RuntimeClassFlags<2>,struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Dispatching::DispatcherQueueTimer *,struct IInspectable *>,class Microsoft::WRL::FtmBase>,class <lambda_1b1a5b0dce93060c2ffe10d1d311f882>,-1,struct Microsoft::UI::Dispatching::IDispatcherQueueTimer *,struct IInspectable *>::Invoke(struct Microsoft::UI::Dispatching::IDispatcherQueueTimer *,struct IInspectable *)	Unknown
CoreMessagingXP.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<class <lambda_2ad0659dc62ecd7334c0ef0269e3265b>,struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Dispatching::DispatcherQueue *,struct IInspectable *> >(class <lambda_2ad0659dc62ecd7334c0ef0269e3265b>,class Microsoft::WRL::Details::EventTargetArray *,class Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Dispatching::DispatcherQueue *,struct IInspectable *>,struct Microsoft::WRL::InvokeModeOptions<-2> > *)	Unknown
CoreMessagingXP.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Dispatching::DispatcherQueue *,struct IInspectable *>,struct Microsoft::WRL::InvokeModeOptions<-2> >::InvokeAll<class Microsoft::UI::Dispatching::DispatcherQueue *,std::nullptr_t>(class Microsoft::UI::Dispatching::DispatcherQueue *,std::nullptr_t)	Unknown
CoreMessagingXP.dll!Microsoft::UI::Dispatching::DispatcherQueueTimer::TimerCallback(void *)	Unknown
CoreMessagingXP.dll!CFlat::SehSafe::Execute<<lambda_e16aea3717fc5beac95aa2e513a8f395>>()	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::ActionCallback::ImportAdapter$(class CFlat::Box$1<struct CFlat::FunctionPointerAndUserData$1<long > > *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Support::ActivationContext::CallbackWithActivationContext(class Microsoft::CoreUI::Dispatch::Timeout *,struct System::UIntPtr)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::TimeoutManager::Callback_OnDispatch(void)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchNextItem(class Microsoft::CoreUI::Dispatch::DispatchItem *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchLoop(enum Microsoft::CoreUI::Dispatch::RunnablePriorityMask)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop(enum Microsoft::CoreUI::Dispatch::RunMode)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,void * *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch(bool,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,void * *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatchRaw(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool,void * *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DoWork(struct HWND__ *,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::HandleDispatchNotifyMessage(struct HWND__ *,unsigned int,long)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::WindowProc(struct HWND__ *,unsigned int,unsigned int,long)	Unknown
user32.dll!__InternalCallWinProc@20()	Unknown
user32.dll!UserCallWinProcCheckWow()	Unknown
user32.dll!DispatchClientMessage()	Unknown
user32.dll!___fnDWORD@4()	Unknown
ntdll.dll!774c4f3d()	Unknown
win32u.dll!_NtUserGetMessage@16()	Unknown
user32.dll!GetMessageW()	Unknown
Microsoft.ui.xaml.dll!56a740da()	Unknown
Microsoft.ui.xaml.dll!56a754c4()	Unknown
[Managed to Native Transition]	
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj = {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}, Microsoft.UI.Xaml.ApplicationInitializationCallback callback = {Method = {System.Reflection.RuntimeMethodInfo}})	Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback = {Method = {System.Reflection.RuntimeMethodInfo}})	Unknown
SliderTest.dll!SliderTest.Program.Main(string[] args = {string[0]}) Line 31	C#
[Native to Managed Transition]	
[Inline Frame] hostpolicy.dll!coreclr_t::execute_assembly(int argc, const char * *) Line 109	C++
hostpolicy.dll!run_app_for_context(const hostpolicy_context_t & context={...}, int argc, const wchar_t * * argv=0x00000000) Line 255	C++

kmgallahan avatar Sep 07 '23 12:09 kmgallahan

@kmgallahan Thanks! I don't know why you're seeing an extra exception output there and I'm not, but that KeyboardInputWinRT::ComApi::SetPreTranslateHandler error should go away with the fix for the OriginateError issues (now fixed internally).

codendone avatar Sep 08 '23 01:09 codendone

Fixed in 1.4.1, closing bug.

duncanmacmichael avatar Sep 19 '23 23:09 duncanmacmichael

Reopening, since unfortunately this is only half fixed in 1.4.1.

codendone avatar Sep 21 '23 01:09 codendone

This was caused by the new windowed popup support (ShouldConstrainToRootBounds="False", which tooltips always use). During cleanup of the popup, it tries to unregister event handlers from an already-closed object, which threw an exception. The first exception stack (there is another for the ContentIsland):

    Microsoft_UI_Input!PreTranslateKeyboardInputWinRT::ComApi::SetPreTranslateHandler+0x32
    Microsoft_ui_xaml!InputSiteAdapter::UnsubscribeToInputEvents+0x3a
    Microsoft_ui_xaml!InputSiteAdapter::~InputSiteAdapter+0x10 
    Microsoft_ui_xaml!std::default_delete<CustomWriterRuntimeData>::operator()+0x21
    Microsoft_ui_xaml!CPopup::~CPopup+0x142 (61979b3f)

I have another one which happening at the same place but a different stack:

 	KernelBase.dll!RaiseException() + 108 bytes
 	combase.dll!00007fff44d7b23a()
 	combase.dll!RoOriginateErrorW() + 77 bytes
 	Microsoft.UI.Input.dll!PreTranslateKeyboardInputWinRT::ComApi::SetPreTranslateHandler(struct Microsoft::UI::Input::IInputPreTranslateKeyboardSourceHandler *)
 	Microsoft.ui.xaml.dll!CXamlIslandRoot::UnsubscribeToInputEvents() Line 1461
 	Microsoft.ui.xaml.dll!CXamlIslandRoot::Dispose() Line 86
 	Microsoft.ui.xaml.dll!DirectUI::DesktopWindowXamlSource::Close() Line 486
 	Microsoft.ui.xaml.dll!DirectUI::DesktopWindowImpl::Shutdown() Line 1093
 	Microsoft.ui.xaml.dll!DirectUI::DesktopWindowImpl::CloseImpl() Line 468
 	[Inline Frame] Microsoft.ui.xaml.dll!DirectUI::DesktopWindowImpl::OnClosed() Line 962
 	Microsoft.ui.xaml.dll!DirectUI::DesktopWindowImpl::OnMessage(const unsigned int uMsg=16, const unsigned __int64 wParam=0, const __int64 lParam=0) Line 696
 	Microsoft.ui.xaml.dll!BaseWindow<DirectUI::DesktopWindowImpl>::WndProc(HWND__ * const window, const unsigned int message=16, const unsigned __int64 wparam=0, const __int64 lparam=0)

Exception thrown at 0x00007FFF43C9567C (KernelBase.dll) in xxx.Client.WinUI.exe: WinRT originate error - 0x80000013 : 'The given object has already been closed / disposed and may no longer be used.'.

softworkz avatar Jan 06 '24 23:01 softworkz

I also encountered the same problem

0x00007FFF63BF567C (KernelBase.dll)处(位于 App1.exe 中)引发的异常: WinRT originate error - 0x80000013 : 'The given object has already been closed / disposed and may no longer be used.'。

bizehao avatar Jan 23 '24 12:01 bizehao

Has this been addressed? I am also getting this exception with slider.

Exception thrown at 0x00007FFEEF16567C (KernelBase.dll) in app.exe: WinRT originate error - 0x80070005 : 'The caller is not allowed to perform this operation on this object.'.

edward-a avatar Feb 20 '24 06:02 edward-a

Just like @edward-a , I'm also encountering that issue when using the slider. It happens after I grab the silder's thumb, move it around and then release the thumb. As soon as I release it, the issue appears.

ackh avatar Jul 04 '24 08:07 ackh