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

Enable in-app Toolbar in XAML Hot Reload crashes in App SDK 1.4 #8806

Closed
NicholasChrzan opened this issue Aug 31, 2023 · 23 comments
Closed

Enable in-app Toolbar in XAML Hot Reload crashes in App SDK 1.4 #8806

NicholasChrzan opened this issue Aug 31, 2023 · 23 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners team-Markup Issue for the Markup team
Milestone

Comments

@NicholasChrzan
Copy link

NicholasChrzan commented Aug 31, 2023

Describe the bug

When debugging windows app sdk (1.4.230822000) with visual studio 202217.7.3 I get an access violation when opening
our application after about 10 seconds, Turning off the "Enable in-app Toolbar" under the XAML hot reload allows the app to start and not crash.

From the crash log:
ExceptionAddress: 00007ffd6057de84 (Microsoft_UI_Windowing_Core!Api::ReunionApi32::GetWindowFeatureImpl+0x0000000000000020)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000001
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 0000000000000030
Attempt to read from address 0000000000000030

Steps to reproduce the bug

Start app in x64 debug in VS 2022 17.7.3
Open second window
Crash

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.0: 1.4.230822000

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

@NicholasChrzan NicholasChrzan added the bug Something isn't working label Aug 31, 2023
@lhak
Copy link

lhak commented Aug 31, 2023

I see the same issue. Here is a stack trace:

Microsoft.UI.Windowing.Core.dll!Api::ReunionApi32::GetWindowFeatureImpl(enum Core::WindowHandle,unsigned int)
 Microsoft.UI.Windowing.Core.dll!GetWindowFeature()
 Microsoft.UI.Input.dll!InputNonClientPointerSourceWinRTStatics::GetForWindowIdHelper(struct Microsoft::UI::WindowId,struct Microsoft::UI::Input::IInputNonClientPointerSource * *,bool)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!winrt::impl::factory_cache_entry<struct winrt::Microsoft::UI::Input::InputNonClientPointerSource,struct winrt::Microsoft::UI::Input::IInputNonClientPointerSourceStatics>::call<class `winrt::Microsoft::UI::Input::InputNonClientPointerSource::GetForWindowId(struct winrt::Microsoft::UI::WindowId const &)'::`2'::<lambda_1> &>(class `winrt::Microsoft::UI::Input::InputNonClientPointerSource::GetForWindowId(struct winrt::Microsoft::UI::WindowId const &)'::`2'::<lambda_1> &)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!winrt::Microsoft::UI::Input::InputNonClientPointerSource::GetForWindowId(struct winrt::Microsoft::UI::WindowId const &)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::InAppMenu::InAppMenu(class Microsoft::VisualStudio::DesignTools::UwpTap::ActivationFactoryProviderBase &,class std::shared_ptr<class Microsoft::VisualStudio::DesignTools::UwpTap::OM::ObjectIdentityService>,struct Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::InAppMenuModel &,struct winrt::Microsoft::UI::Xaml::Controls::Panel,struct winrt::Microsoft::UI::Xaml::XamlRoot,struct HWND__ *)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::UILayerManager::OnInAppMenuStateChanged(void)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::WinrtRunOnUIThread<class std::function<void > >(class Microsoft::VisualStudio::DesignTools::UwpTap::DispatcherHelper const &,enum Microsoft::VisualStudio::DesignTools::UwpTap::DispatcherPriority,class std::function<void >)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!std::_Func_impl_no_alloc<class `Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::DispatcherBindingBase<bool>::Initialize(class std::function<void >,bool)'::`5'::<lambda_1>,void>::_Do_call(void)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::SimpleBinding<bool>::Initialize(class std::function<void >,bool)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::DispatcherBindingBase<bool>::Initialize(class std::function<void >,bool)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::UILayerManager::SetBinding(class Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::NotifyingValue<bool> &,void )
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::UILayerManager::Initialize(void)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::UILayerManager::RunOnUIThread(class std::function<void > const &)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::InAppUI::UILayerManager::Initialize(struct winrt::Microsoft::UI::Xaml::Controls::Panel,struct HWND__ *)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!std::_Func_impl_no_alloc<`Microsoft::VisualStudio::DesignTools::UwpTap::WindowsXamlDiagnosticsTap::AddRoot'::`2'::<lambda_1>,void>::_Do_call()
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!Microsoft::VisualStudio::DesignTools::UwpTap::PackagedTask<void>::operator()(void)
 Microsoft.VisualStudio.DesignTools.WinUITap.dll!winrt::impl::delegate<winrt::Microsoft::UI::Dispatching::DispatcherQueueHandler,`Microsoft::VisualStudio::DesignTools::UwpTap::WinrtRunOnUIThreadAsync<`Microsoft::VisualStudio::DesignTools::UwpTap::WindowsXamlDiagnosticsTap::AddRoot'::`2'::<lambda_1>>'::`2'::<lambda_1>>::Invoke()
 CoreMessagingXP.dll!Microsoft::UI::Dispatching::DispatcherQueue::DeferInvokeCallback(void *)
 CoreMessagingXP.dll!CFlat::SehSafe::Execute<<lambda_a81ff790741c2a62f2197c2561f5fe49>>()
 CoreMessagingXP.dll!Microsoft::CoreUI::ActionCallback::ImportAdapter$(class CFlat::Box$1<struct CFlat::FunctionPointerAndUserData$1<long > > *)
 CoreMessagingXP.dll!Microsoft::CoreUI::Messaging::MessageSession::Callback_InvokeDeferInvoke(class Microsoft::CoreUI::ActionCallback *,struct System::UIntPtr)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::DeferredCall::Callback_Dispatch(void)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::DeferredCallDispatcher::Callback_OnDispatch(void)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchNextItem(class Microsoft::CoreUI::Dispatch::DispatchItem *)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchLoop(enum Microsoft::CoreUI::Dispatch::RunnablePriorityMask)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop(enum Microsoft::CoreUI::Dispatch::RunMode)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,void * *)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch(bool,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,void * *)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatchRaw(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool,void * *)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DoWork(struct HWND__ *,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::HandleDispatchNotifyMessage(struct HWND__ *,unsigned __int64,__int64)
 CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)

@bpulliam bpulliam changed the title Bug title Opening Second Window Crashes Hot Reload Aug 31, 2023
@NicholasChrzan
Copy link
Author

NicholasChrzan commented Aug 31, 2023

Turning off the "Enable in-app Toolbar" fixes this issue for me, so you can still use XAML Hot Reload

@NicholasChrzan NicholasChrzan changed the title Opening Second Window Crashes Hot Reload Enable in-app Toolbar in XAML Hot Reload crashes in App SDK 1.4 Aug 31, 2023
@Zulu-Inuoe
Copy link

Seeing the same behaviour - Disabling the 'Enable in-app Toolbar' avoids the crash

@castorix
Copy link

castorix commented Sep 6, 2023

Turning off the "Enable in-app Toolbar" fixes this issue for me, so you can still use XAML Hot Reload

Thanks, it also fixes the issue for XAML Islands in WPF which crashed with "access violation", while the same code worked in WinForms

@bpulliam bpulliam added the team-Markup Issue for the Markup team label Sep 7, 2023
@Zulu-Inuoe
Copy link

@JoeTomkinson this is not closed - the duplicate #8848 was

@JoeTomkinson
Copy link

@JoeTomkinson this is not closed - the duplicate #8848 was

Apologies, was viewing this on mobile to check the status and clearly misread.

@JochemPalmsens
Copy link

Same issue here... and now my front-end developers aren't happy with us upgrading to 1.4. So it's pretty blocking for us!

@Scottj1s
Copy link
Member

Scottj1s commented Dec 7, 2023

internal MS issue: https://task.ms/47919577

@llongley llongley closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
@llongley llongley added the closed-Duplicate Described behavior is already captured by another issue. label Feb 2, 2024
@Zulu-Inuoe
Copy link

@JoeTomkinson so I guess this is actually closed now.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 2, 2024
@JochemPalmsens
Copy link

@llongley what's the dupe? We're still waiting on this and it's blocking us moving to 1.4

@Scottj1s
Copy link
Member

Scottj1s commented Feb 2, 2024

This issue was addressed in Visual Studio version 17.8

@Scottj1s Scottj1s closed this as completed Feb 2, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the needs-triage Issue needs to be triaged by the area owners label Feb 2, 2024
@JochemPalmsens
Copy link

@Scottj1s thank you for your answer, but could you clarify that? Because I just tried it and still get the issue.

I'm running visual studio 17.8.6.

  • When I run the (multi window) app using WinApp SDK 1.3.230724000 the (XAML hot-reload) in-app toolbar runs fine
  • When I run WinApp SDK 1.4.231219000 with in-app toolbar enabled, the app (still) crashes.
  • When I disable the in-app toolbar, the app starts without exceptions again.

that's the same behavior as before, so I don't see how it's "completed"?

Like said: our front-end developers are using that toolbar, so they don't want us to switch to 1.4 this way. It's still blocking us.

Screenshot:
afbeelding

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 3, 2024
@irperez
Copy link

irperez commented Feb 13, 2024

@Scottj1s thank you for your answer, but could you clarify that? Because I just tried it and still get the issue.

I'm running visual studio 17.8.6.

  • When I run the (multi window) app using WinApp SDK 1.3.230724000 the (XAML hot-reload) in-app toolbar runs fine
  • When I run WinApp SDK 1.4.231219000 with in-app toolbar enabled, the app (still) crashes.
  • When I disable the in-app toolbar, the app starts without exceptions again.

that's the same behavior as before, so I don't see how it's "completed"?

Like said: our front-end developers are using that toolbar, so they don't want us to switch to 1.4 this way. It's still blocking us.

Screenshot: afbeelding

I just wanted to confirm that at my company we are seeing the same issue.

We're running visual studio 17.8.5.
Windows v10.0.19045 Build 19045

We have over 50 developers with the same issue here.

@NicholasChrzan
Copy link
Author

@irperez @JochemPalmsens While the in app toolbar does still have this issue. We've been able to work around this using the "Live Visual Tree" window in visual studio. The toolbar there has many of the same functions (if not all) as the in app toolbar and still works without issue.

@Scottj1s @llongley This issue still exists in VS 2022 17.8.6 and has not been addressed. One of these issues should be re-opened.

@JochemPalmsens
Copy link

JochemPalmsens commented Feb 15, 2024

I just tried it with the new Visual Studio 2022 releases today:

  • 17.8.7: still crashes
  • 17.9.0: a bit better, but still issues: see next post
  • (17.10.0 preview 1.0 not checked, as we don't want to use that for our production work)

So apparently it was addressed in 17.9, not 17.8... but it's not fixed

Details: It's more that it sometimes seems to work in 17.9, but sometimes also doesn't.
I had to do a very thorough clean (delete obj/bin directories manually) and multiple rebuilds before I could run the app without crashing using 1.4 or even 1.5. But after a new checkout it crashes again. The only thing always starting is WinAppSDK 1.3

Update 19-2-2024: we made all colleagues update to Visual Studio 17.9 and rolled out a test update to WinAppSDK 1.4. Even after thorough cleaning of build directories, almost everybody had problems with the in-app toolbar, so we need to stay at WinApp SDK 1.3 until this is really fixed.

@Scottj1s So it seems there still are issues.

@Scottj1s
Copy link
Member

@irperez , @JochemPalmsens , @NicholasChrzan - thanks all for your feedback. We're engaging with the Visual Studio team to root cause. I was unable to repro this myself, after updating to VS 17.8+. But evidently, you all are still seeing the crash on latest VS.

@Scottj1s
Copy link
Member

This crash was manifesting from two location:

  • Visual Studio ships with a WinUITap.dll that is injected into the target process, enabling communication between the VS debugger and the app. There were conditions under which WinUITap.dll was attempting to resolve a zero WindowID to an HWND, causing a crash. This was fixed in VS 17.8 Preview 2.
  • WinUI had an issue where upon receiving that zero WindowID, it would crash rather than returning a null HWND. That has been fixed in Windows App SDK 1.5, currently in Preview 1.

I don't understand why the crash still repros with VS 17.8+. The Visual Studio team has requested a VS feedback item, ideally with a repro project, and at minimum a crash dump.

In addition, the hardening in Windows App SDK 1.5 should also resolve this crash, so upgrading is another option.

@Scottj1s Scottj1s reopened this Feb 21, 2024
@irperez
Copy link

irperez commented Feb 22, 2024

Just to confirm what we're seeing, below are the versions we're using. I didn't provide enough detail.

Related Versions

Visual Studio Professional 17.8.5.
Windows v10.0.19045 Build 19045
Microsoft.WindowsAppSDK 1.4.231008000
Microsoft.Windows.SDK.BuildTools 10.0.22621.756

From the About Dialog:

Microsoft Visual Studio Professional 2022
Version 17.8.5
VisualStudio.17.Release/17.8.5+34511.84
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

Visual C++ 2022 00476-80000-00000-AA140
Microsoft Visual C++ 2022

ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 17.8.358.6298
ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.8.358.6298
Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.8.358.6298
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 4.8.0-7.23572.1+7b75981cf3bd520b86ec4ed00ec156c8bc48e4eb
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Copy Nice 1.0.7
Strips leading indentation when copying to the clipboard. This fixes the issue of tangled code when pasting code into an email, IM, or elsewhere.

CreateUnitTestBoilerplateCommand Extension 1.0
CreateUnitTestBoilerplateCommand Visual Studio Extension Detailed Info

File Differ 3.0.49
The easiest way to diff two files directly in Solution Explorer

File Icons 2.7
Adds icons for files that are not recognized by Solution Explorer

Fine Code Coverage FineCodeCoverage2022.ad53fb28-7a11-4465-a27a-3550499ea4a1
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)

GitHub Copilot 1.137.0.0 (v1.137.0.0@2f127d06d)
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

GitHub Copilot Agent 1.137.0

ILSpy.AddIn 1.0
Integration of the ILSpy Decompiler into Visual Studio.

Insert Guid 1.3.6
Makes it super easy to insert a new GUID into any editor and input field

Microsoft Azure Hive Query Language Service 2.6.5000.0
Language service for Hive query

Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

NuGet Package Manager 6.8.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Office Developer Tools for Visual Studio 17.6.34024.01
Microsoft Office Developer Tools for Visual Studio

Rainbow Braces 1.0.155
Colorizes matching brace pairs to make it easy to identify them and their scope. Works for curly brackets, parentheses, and square brackets.

Razor (ASP.NET Core) 17.8.3.2405201+d135dd8d2ec1c2fbdee220e8656b308694e17a4b
Provides languages services for ASP.NET Core Razor.

Snippet Designer 1.8.1
Snippet Designer is a Visual Studio plug in which allows you to create and search for snippets inside the IDE

SQL Server Data Tools 17.8.120.1
Microsoft SQL Server Data Tools

Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 17.0.20920.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.8.0-7.23572.1+7b75981cf3bd520b86ec4ed00ec156c8bc48e4eb
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.8.0-beta.23475.2+10f956e631a1efc0f7f5e49c626c494cd32b1f50
Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

@Prochy
Copy link

Prochy commented Feb 22, 2024

@Scottj1s
I'm able to reproduce it if I checkout H.NotifyIcon git repo and run it. With "Enable in-app toolbar" ON it crashes, if it's OFF it works fine. I hope it will help somehow. :) I uploaded simplified NotifyIcon project where I removed unnecessary projects. Not sure why, but H.NotifyIcon.Apps.WinUI is not working with the "Enable in-app toolbar" and H.NotifyIcon.Apps.WinUI.Windowless is working fine. Didn't investigate deeper.

VS 17.9.0
WinAppSdk 1.5 Preview 1
reproducibleExample.zip

@Scottj1s
Copy link
Member

Sorry for the confusion, and thanks for the repro @Prochy - very helpful. I've confirmed that the fix is in the WinAppSDK 1.5 release candidate (and not in Preview 1).
image

@bpulliam bpulliam added fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. and removed needs-triage Issue needs to be triaged by the area owners closed-Duplicate Described behavior is already captured by another issue. labels Feb 23, 2024
@bpulliam bpulliam added this to the WinAppSDK 1.5 milestone Feb 23, 2024
@llongley llongley closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2024
@llongley llongley added the closed-Duplicate Described behavior is already captured by another issue. label Feb 24, 2024
@llongley llongley reopened this Feb 24, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-triage Issue needs to be triaged by the area owners labels Feb 24, 2024
@llongley llongley removed the closed-Duplicate Described behavior is already captured by another issue. label Feb 24, 2024
@JochemPalmsens
Copy link

JochemPalmsens commented Feb 25, 2024

Well that's good news... although we have no way to test if it works for our projects yet. I guess we'll have to wait. When is the RC released?

In the meantime I made a minimal test solution (to compare 1.3, 1.4 and 1.5): https://github.com/JochemPalmsens/WinAppSDKbug8806

Just adding a second window on launched triggers the bug.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 25, 2024
@bpulliam bpulliam removed needs-triage Issue needs to be triaged by the area owners fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. labels Feb 29, 2024
@JochemPalmsens
Copy link

I can confirm that (at least it seems so) it's fixed in 1.5.240227000
image

@wbokkers
Copy link

wbokkers commented Sep 6, 2024

I see this crash happening all the time in App SDK 1.6 when closing (child)Windows. Hot Reload is broken for me.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests