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

Instantiating child window from main window constructor crashes #4234

Closed
Slion opened this issue Feb 27, 2024 · 7 comments
Closed

Instantiating child window from main window constructor crashes #4234

Slion opened this issue Feb 27, 2024 · 7 comments

Comments

@Slion
Copy link

Slion commented Feb 27, 2024

Describe the bug

Crash after upgrading from 1.3 to 1.4
The app starts, when I'm lucky I can even get a nice complete render then it crashes in Api::ReunionApi32::GetWindowFeatureImpl.
See callstack below.

Steps to reproduce the bug

Upgrade from 1.3 to 1.4
Run your app making sure you instantiate a child window from the main window constructor.

Expected behavior

Should not crash

Screenshots

No response

NuGet package version

Windows App SDK 1.4.5: 1.4.240211001

Packaging type

msix

Windows version

Windows 11 22H2 22621.3007

IDE

Visual Studio 2022

Additional context

 	Microsoft.UI.Windowing.Core.dll!Api::ReunionApi32::GetWindowFeatureImpl(enum Core::WindowHandle,unsigned int)	Unknown
 	Microsoft.UI.Windowing.Core.dll!GetWindowFeature()	Unknown
 	Microsoft.UI.Input.dll!InputNonClientPointerSourceWinRTStatics::GetForWindowIdHelper(struct Microsoft::UI::WindowId,struct Microsoft::UI::Input::IInputNonClientPointerSource * *,bool)	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dbd46f()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dbd226()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dbfd7e()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56de6fe2()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dcf57c()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dd369e()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dc7d30()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56dc7ace()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56de5ff9()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56de4f78()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56de8687()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56de49b7()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56ea0fec()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56d59243()	Unknown
 	Microsoft.VisualStudio.DesignTools.WinUITap.dll!00007ffa56e9989d()	Unknown
 	CoreMessagingXP.dll!Microsoft::UI::Dispatching::DispatcherQueue::DeferInvokeCallback(void *)	Unknown
 	CoreMessagingXP.dll!CFlat::SehSafe::Execute<<lambda_a81ff790741c2a62f2197c2561f5fe49>>()	Unknown
>	CoreMessagingXP.dll!Microsoft::CoreUI::ActionCallback::ImportAdapter$(class CFlat::Box$1<struct CFlat::FunctionPointerAndUserData$1<long (*)(void *)> > *)	Unknown
 	CoreMessagingXP.dll!Microsoft::CoreUI::Messaging::MessageSession::Callback_InvokeDeferInvoke(class Microsoft::CoreUI::ActionCallback *,struct System::UIntPtr)	Unknown
 	CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::DeferredCall::Callback_Dispatch(void)	Unknown
 	CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::DeferredCallDispatcher::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 __int64,__int64)	Unknown
 	CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)	Unknown
 	user32.dll!UserCallWinProcCheckWow()	Unknown
 	user32.dll!DispatchClientMessage()	Unknown
 	user32.dll!__fnDWORD()	Unknown
 	ntdll.dll!KiUserCallbackDispatcherContinue()	Unknown
 	win32u.dll!NtUserGetMessage()	Unknown
 	user32.dll!GetMessageW()	Unknown
 	InProcessClient64.dll!00007ffbee899006()	Unknown
 	InProcessClient64.dll!00007ffbee898f45()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RunDesktopWindowMessageLoop() Line 1267	C++
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartDesktop() Line 238	C++
 	[External Code]	
 	Taskbar.App.dll!Taskbar.Program.StartApp() Line 108	C#
 	Taskbar.App.dll!Taskbar.Program.Main(string[] args) Line 31	C#
 	[External Code]	
 	[Inline Frame] hostpolicy.dll!coreclr_t::execute_assembly(int) Line 109	C++
 	hostpolicy.dll!run_app_for_context(const hostpolicy_context_t & context, int argc, const wchar_t * * argv) Line 255	C++
 	hostpolicy.dll!run_app(const int argc, const wchar_t * * argv) Line 284	C++
 	hostpolicy.dll!corehost_main(const int argc, const wchar_t * * argv) Line 430	C++
 	hostfxr.dll!execute_app(const std::wstring & impl_dll_dir, corehost_init_t * init, const int argc, const wchar_t * * argv) Line 145	C++
 	hostfxr.dll!`anonymous namespace'::read_config_and_execute(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int new_argc, const wchar_t * * new_argv, host_mode_t mode, const bool is_sdk_command, wchar_t * out_buffer, int buffer_size, int * required_buffer_size) Line 532	C++
 	hostfxr.dll!fx_muxer_t::handle_exec_host_command(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int argc, const wchar_t * * argv, int argoff, host_mode_t mode, const bool is_sdk_command, wchar_t * result_buffer, int buffer_size, int * required_buffer_size) Line 1007	C++
 	hostfxr.dll!fx_muxer_t::execute(const std::wstring host_command, const int argc, const wchar_t * * argv, const host_startup_info_t & host_info, wchar_t * result_buffer, int buffer_size, int * required_buffer_size) Line 578	C++
 	hostfxr.dll!hostfxr_main_startupinfo(const int argc, const wchar_t * * argv, const wchar_t * host_path, const wchar_t * dotnet_root, const wchar_t * app_path) Line 62	C++
 	Taskbar.App.exe!exe_start(const int argc, const wchar_t * * argv) Line 251	C++
 	Taskbar.App.exe!wmain(const int argc, const wchar_t * * argv) Line 322	C++
 	[External Code]	

@Slion
Copy link
Author

Slion commented Feb 27, 2024

That crash results from instantiating another window from your main window constructor.
In my case all I had to do was to comment out that line:
iWindowSettings = new WindowSettings(Handle);
Now I'm only intantiating that window just before showing it which works without crash apparently.

@Slion Slion changed the title Access violation crash upgrading from 1.3 to 1.4 Instantiating child window from main window constructor crashes Feb 27, 2024
@DarranRowe
Copy link

Do you have the in app toolbar enabled?

Screenshot 2024-01-25 222509

If you do, try disabling it.

Screenshot 2024-01-25 222528

There is a known issue where the in app toolbar will cause a crash if there are multiple Xaml windows on a thread.

Otherwise, it would be nice to know more about WindowSettings, importantly, are you trying to change the parent/owner of a Xaml window that derives from Microsoft.UI.Xaml.Window?

@Slion
Copy link
Author

Slion commented Feb 27, 2024

I'll try disable the debug toolbar to see if it helps.
I don't think I do anything too fancy with that settings window. It's just being created as a child from the main window.

@Slion
Copy link
Author

Slion commented Feb 28, 2024

I think it's definitly that bug with the debug toolbar. I tried it on another computer where the toolbar is disabled and that's not an issues there.

However I'm not sure how to turn back on the toolbar. Here are my settings:
image

Here is what the Live Visual Tree looks like:
image

@DarranRowe
Copy link

You should just be able to click the same button as you used to disable it.

@Slion
Copy link
Author

Slion commented Feb 28, 2024

You should just be able to click the same button as you used to disable it.

Can't recall how I did that last year now…

@Slion
Copy link
Author

Slion commented Feb 28, 2024

@Slion Slion closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants