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

Using WinUI 2.6.1 in a .net core 3.1 app (XAML island) crashes at startup on older Windows version #5435

Closed
lhak opened this issue Jul 10, 2021 · 15 comments · Fixed by #5781
Closed
Labels
area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) team-Controls Issue for the Controls team
Milestone

Comments

@lhak
Copy link

lhak commented Jul 10, 2021

Describe the bug

The application based on .net core 3.1 crashes during launch on Windows version 1903 when using WinUI 2.6.1 while version 2.6.0 works fine (just replacing the winui dll in the output directory is sufficient to make it work). The bug does not occur on the latest Windows version (21H1). Attached is the stack trace from windbg:

Access violation - code c0000005

[0x0]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::Windows::Foundation::IUnknown::unconditional_release_ref + 0x10   
[0x1]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::Windows::Foundation::IUnknown::release_ref + 0xf   
[0x2]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::Windows::Foundation::IUnknown::{dtor} + 0xf   
[0x3]   Microsoft_UI_Xaml_7ffbfc0d0000!XamlControlsResources::UpdateAcrylicBrushesDarkTheme + 0xea   
[0x4]   Microsoft_UI_Xaml_7ffbfc0d0000!XamlControlsResources::UpdateSource + 0x1ba   
[0x5]   Microsoft_UI_Xaml_7ffbfc0d0000!XamlControlsResources::{ctor} + 0x38   
[0x6]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::impl::heap_implements<XamlControlsResources>::heap_implements<XamlControlsResources> + 0x45   
[0x7]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::make + 0x26   
[0x8]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::Microsoft::UI::Xaml::Controls::factory_implementation::XamlControlsResourcesT<winrt::Microsoft::UI::Xaml::Controls::XamlControlsResourcesFactory,XamlControlsResources>::ActivateInstance + 0x26   
[0x9]   Microsoft_UI_Xaml_7ffbfc0d0000!winrt::impl::produce<winrt::Microsoft::UI::Xaml::Controls::XamlControlsResourcesFactory,winrt::Windows::Foundation::IActivationFactory>::ActivateInstance + 0x42   
[0xa]   0x7ffba5aaa14c   
[0xb]   0x7ffba5aa915e   
[0xc]   0x7ffba37d95e7   
[0xd]   System_Windows_Forms!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry)$##60012A5 + 0xf0   
[0xe]   System_Windows_Forms!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)$##60012A4 + 0x3c   
[0xf]   System_Private_CoreLib!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)$##6001E8E + 0x76   
[0x10]   System_Private_CoreLib!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)$##6001E8D + 0x10   
[0x11]   System_Windows_Forms!System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)$##60012A3 + 0x80   
[0x12]   System_Windows_Forms!System.Windows.Forms.Control.InvokeMarshaledCallbacks()$##60012A6 + 0xf7   
[0x13]   System_Windows_Forms!System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)$##60013CC + 0xa03   
[0x14]   System_Windows_Forms!System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)$##6005621 + 0x1f   
[0x15]   System_Windows_Forms!System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)$##6005624 + 0x102   
[0x16]   System_Windows_Forms!System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)$##6002E1C + 0xa1   
[0x17]   0x7ffba34252e0   
[0x18]   coreclr!coreclr_shutdown_2 + 0xbc5b   
[0x19]   USER32!UserCallWinProcCheckWow + 0x2bd   
[0x1a]   USER32!DispatchMessageWorker + 0x1e2   
[0x1b]   0x7ffba37d5337   
[0x1c]   System_Windows_Forms!System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)$##600537C + 0x391   
[0x1d]   System_Windows_Forms!System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)$##60053AA + 0x416   
[0x1e]   System_Windows_Forms!System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)$##60053A9 + 0x46   
[0x1f]   System_Windows_Forms!System.Windows.Forms.Application.Run(System.Windows.Forms.Form)$##6000AEC + 0x3b   
[0x20]   0x7ffba341630e   
[0x21]   coreclr!coreclr_shutdown_2 + 0xbb43   
[0x22]   coreclr!coreclr_initialize + 0xda772   
[0x23]   coreclr!coreclr_initialize + 0xe1739   
[0x24]   coreclr!coreclr_initialize + 0xe1bc7   
[0x25]   coreclr!coreclr_initialize + 0xe2371   
[0x26]   coreclr!coreclr_execute_assembly + 0x101   
[0x27]   hostpolicy!coreclr_t::execute_assembly + 0x2d   
[0x28]   hostpolicy!run_app_for_context + 0x387   
[0x29]   hostpolicy!run_app + 0x46   
[0x2a]   hostpolicy!corehost_main + 0x132   
[0x2b]   hostfxr!execute_app + 0x2e3   
[0x2c]   hostfxr!`anonymous namespace'::read_config_and_execute + 0xa8   
[0x2d]   hostfxr!fx_muxer_t::handle_exec_host_command + 0x15d   
[0x2e]   hostfxr!fx_muxer_t::execute + 0x1fc   
[0x2f]   hostfxr!hostfxr_main_startupinfo + 0x9c   
[0x30]   apphost!exe_start + 0x651   
[0x31]   apphost!wmain + 0x88   
[0x32]   apphost!invoke_main + 0x22   
[0x33]   apphost!__scrt_common_main_seh + 0x10c   
[0x34]   KERNEL32!BaseThreadInitThunk + 0x14   
[0x35]   ntdll!RtlUserThreadStart + 0x21   

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'

Expected behavior

The application should launch properly

Screenshots

Version Info

NuGet package version:

[Microsoft.UI.Xaml 2.6.1]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
21H1 (19043) No
October 2020 Update (19042)
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362) Yes
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jul 10, 2021
@asklar
Copy link
Member

asklar commented Jul 11, 2021

CC @llongley @ranjeshj @jevansaks

@jevansaks
Copy link
Member

@lhak Would you be able to share a repro project?

@lhak
Copy link
Author

lhak commented Jul 12, 2021

I found a way to reproduce this issue quite easily. Unfortunately, there is no prerelease package of winui that corresponds to the latest release so the winui dll has to be manually copied from the appx package. These are the steps:

The app should now start properly on the latest Windows release but will crash on Windows 1903 with the stacktrace shown above.

@ranjeshj ranjeshj added this to the WinUI 2.7 milestone Jul 12, 2021
@ranjeshj ranjeshj added the needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) label Jul 12, 2021
@ranjeshj
Copy link
Contributor

@StephenLPeters StephenLPeters added area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) team-Controls Issue for the Controls team needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Jul 13, 2021
@lhak
Copy link
Author

lhak commented Jul 13, 2021

@ranjeshj Adding this package to the XAML islands sample results in the crash with the stacktrace shown above.

Seems this issue was introduced by #5297?

@ghost ghost added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Jul 13, 2021
@StephenLPeters
Copy link
Contributor

@jevansaks agree that #5297 added this?

@StephenLPeters StephenLPeters removed the needs-triage Issue needs to be triaged by the area owners label Jul 13, 2021
@jevansaks
Copy link
Member

Technically, but the switch to OS AcrylicBrush was the precipitating change. :)

In any case we should change that logic to only run on 1903 or later because it's trying to set the "new" TintLuminosityOpacity property.

I'm on vacation until 7/21 but it's a trivial fix so hopefully someone else can pick it up.

@lhak
Copy link
Author

lhak commented Jul 16, 2021

Well, the code crashes on 1903 even though TintLuminosityOpacity is available on that version. I looked at how this setting was previously handled for the winui AcrylicBrush and I found out that by changing the direct calls to something like this:

brush.SetValue(winrt::Windows::UI::Xaml::Media::AcrylicBrush::TintLuminosityOpacityProperty(), winrt::box_value(0.85));

the code does not crash anymore and seems to still set the value correctly. However, I am not sure why this works.

@asklar
Copy link
Member

asklar commented Aug 22, 2021

Is this still an issue with 2.6.2 ?

@lhak
Copy link
Author

lhak commented Aug 23, 2021

@asklar Yes, still the same issue

@jaimecbernardo
Copy link

@asklar , I had opened the duplicate issue #5546 .

I've tested 2.6.2-prerelease.210818003. The issue is still present.
I've tested 2.7.0-prerelease.210816001. The issue is still present.

@asklar
Copy link
Member

asklar commented Aug 23, 2021

thanks for confirming. @jevansaks could you take a look? I'm not sure why setting the property via the DP would work but setting it through the accessor would crash.

@miniksa
Copy link
Member

miniksa commented Aug 24, 2021

From the Terminal team, I've identified the root cause of this issue inside Windows and sent mail to the appropriate folks for triage and prioritization.

DHowett added a commit to microsoft/terminal that referenced this issue Aug 24, 2021
…11031)

The upgrade to 2.6 revealed #11003 and microsoft/microsoft-ui-xaml#5435, and is impeding
progress on PGO.

This reverts commit cfdf03c.
Reverts #10996
@jaimecbernardo
Copy link

I can confirm the latest release "2.7.0-prerelease.210913003" fixes this issue for me.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Sep 15, 2021
@StephenLPeters StephenLPeters removed the needs-triage Issue needs to be triaged by the area owners label Sep 17, 2021
@StephenLPeters StephenLPeters removed the needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) label Oct 26, 2021
@ghost
Copy link

ghost commented Dec 3, 2021

🎉This issue was addressed in #5781, which has now been successfully released as Microsoft.UI.Xaml v2.6.3.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) team-Controls Issue for the Controls team
Projects
None yet
7 participants