question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NavigationView causes hard crash in Reunion-0.5pre desktop

See original GitHub issue

Update It works properly in Reunion 0.5 (Debug/Release, w/wo debugger), but it still causes exception caught by VS during start.

Workaround In your app.xaml, add these lines below <!-- Other app resources here -->:

            <SolidColorBrush x:Key="NavigationViewDefaultPaneBackground" Color="#F9F9F9" />
            <SolidColorBrush x:Key="NavigationViewTopPaneBackground" Color="#F9F9F9" />

The color of these brushes can be whatever. I’m copying the default fallback from https://github.com/microsoft/microsoft-ui-xaml/blob/20d6fd87439a1c1e2fd0ef77d47d82e595daea67/dev/Materials/Acrylic/AcrylicBrush_19h1_themeresources.xaml#L86

Describe the bug Initialization of NavigationView calls a UWP api and will hard crash in desktop.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Using the WinUI in Desktop, packaged template, version Reunion 0.5 Preview
  2. Simply add a NavigationView in main window
  3. Hard crash: WinRT originate error - 0x80070490 : 'Windows.Graphics.Display: GetForCurrentView must be called on a thread that is associated with a CoreWindow.'

Stack trace:

 	KernelBase.dll!00007ffd1de8d759	未知
 	vcruntime140.dll!00007ffc99756220	未知
 	Microsoft.UI.Xaml.Controls.dll!winrt::throw_hresult	未知
 	Microsoft.UI.Xaml.Controls.dll!winrt::impl::consume_Microsoft_UI_Xaml_Media_IAcrylicBrushStatics<winrt::Microsoft::UI::Xaml::Media::IAcrylicBrushStatics>::BackgroundSourceProperty	未知
 	Microsoft.UI.Xaml.Controls.dll!<lambda_0a1437f4f9e4e85de4e92d9eedff3a11>::<lambda_invoker_cdecl>	未知
 	Microsoft.UI.Xaml.Controls.dll!winrt::impl::factory_cache_entry<winrt::Windows::Graphics::Display::DisplayInformation,winrt::Windows::Graphics::Display::IDisplayInformationStatics>::call<winrt::Windows::Graphics::Display::DisplayInformation (__cdecl*)(winrt::Windows::Graphics::Display::IDisplayInformationStatics const &)>	未知
 	Microsoft.UI.Xaml.Controls.dll!MaterialHelper::GetNoiseBrushImpl	未知
 	Microsoft.UI.Xaml.Controls.dll!MaterialHelper::GetNoiseBrush	未知
 	Microsoft.UI.Xaml.Controls.dll!AcrylicBrush::EnsureNoiseBrush	未知
 	Microsoft.UI.Xaml.Controls.dll!AcrylicBrush::CreateAcrylicBrush	未知
 	Microsoft.UI.Xaml.Controls.dll!AcrylicBrush::UpdateAcrylicBrush	未知
 	Microsoft.UI.Xaml.Controls.dll!std::_Func_impl_no_alloc<<lambda_5b13b3b6091b667131bdae3712af62d3>,void,winrt::com_ptr<MaterialHelperBase> const &,bool>::_Do_call	未知
 	Microsoft.UI.Xaml.Controls.dll!std::_Func_class<void,winrt::com_ptr<MaterialHelperBase> const &,bool>::operator()	未知
 	Microsoft.UI.Xaml.Controls.dll!event_base<event<std::function<void > >,std::function<void >,std::function<void > >::operator()<winrt::com_ptr<MaterialHelper>,bool>	未知
 	Microsoft.UI.Xaml.Controls.dll!<lambda>(void)	未知
 	Microsoft.UI.Xaml.Controls.dll!MaterialHelper::UpdatePolicyStatus	未知
 	Microsoft.UI.Xaml.Controls.dll!std::_Func_impl_no_alloc<<lambda_f38bc1e85e37f8d661e19832411993ab>,void>::_Do_call	未知
 	Microsoft.UI.Xaml.Controls.dll!winrt::impl::delegate<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>,<lambda_f1ce5351e36cddf637b056ff8b430e0c>>::Invoke	未知
 	Microsoft.ui.xaml.dll!DirectUI::CEventSourceBase<DirectUI::IUntypedEventSource,ABI::Windows::Foundation::IEventHandler<IInspectable *>,IInspectable,IInspectable>::Raise	未知
 	Microsoft.ui.xaml.dll!DirectUI::DXamlCore::OnRenderingEvent	未知
 	Microsoft.ui.xaml.dll!DirectUI::DXamlCore::RaiseEvent	未知
 	Microsoft.ui.xaml.dll!CCoreServices::CallPerFrameCallback	未知
 	Microsoft.ui.xaml.dll!CCoreServices::NWDrawTree	未知
 	Microsoft.ui.xaml.dll!CCoreServices::NWDrawMainTree	未知
 	Microsoft.ui.xaml.dll!CWindowRenderTarget::Draw	未知
 	Microsoft.ui.xaml.dll!CXcpBrowserHost::OnTick	未知
 	Microsoft.ui.xaml.dll!CXcpDispatcher::Tick	未知
 	Microsoft.ui.xaml.dll!CXcpDispatcher::OnReentrancyProtectedWindowMessage	未知
 	Microsoft.ui.xaml.dll!CXcpDispatcher::ProcessMessage	未知
 	Microsoft.ui.xaml.dll!CXcpDispatcher::WindowProc	未知
 	Microsoft.ui.xaml.dll!CDeferredInvoke::DispatchQueuedMessage	未知
 	Microsoft.ui.xaml.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl ABI::Windows::Foundation::ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Microsoft::System::DispatcherQueueTimer *,ABI::Microsoft::System::IDispatcherQueueTimer *>,IInspectable *>::*)(ABI::Microsoft::System::IDispatcherQueueTimer *,IInspectable *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,ABI::Windows::Foundation::ITypedEventHandler<ABI::Microsoft::System::DispatcherQueueTimer *,IInspectable *>,Microsoft::WRL::FtmBase>,<lambda_fbe4f38be23425399af0724cc79ee2d3> &,1,ABI::Microsoft::System::IDispatcherQueueTimer *,IInspectable *>::Invoke	未知
 	CoreMessagingXP.dll!00007ffc7f104338	未知
 	CoreMessagingXP.dll!00007ffc7f10450a	未知
 	CoreMessagingXP.dll!00007ffc7f10410b	未知
 	CoreMessagingXP.dll!00007ffc7f0db5d8	未知
 	CoreMessagingXP.dll!00007ffc7f0db4ab	未知
 	CoreMessagingXP.dll!00007ffc7f0b67c2	未知
 	CoreMessagingXP.dll!00007ffc7f08319e	未知
 	CoreMessagingXP.dll!00007ffc7f07bcdb	未知
 	CoreMessagingXP.dll!00007ffc7f083ca3	未知
 	CoreMessagingXP.dll!00007ffc7f0d2d0b	未知
 	CoreMessagingXP.dll!00007ffc7f0d2d81	未知
 	CoreMessaging.dll!00007ffd1a505e1f	未知
 	CoreMessaging.dll!00007ffd1a537a77	未知
 	CoreMessaging.dll!00007ffd1a50996b	未知
 	CoreMessaging.dll!00007ffd1a508e26	未知
 	CoreMessaging.dll!00007ffd1a507061	未知
 	CoreMessaging.dll!00007ffd1a506e83	未知
 	user32.dll!00007ffd1ef2e858	未知
 	user32.dll!00007ffd1ef2e3dc	未知
 	user32.dll!00007ffd1ef40bc3	未知
 	ntdll.dll!00007ffd202d0a44	未知
 	win32u.dll!00007ffd1daf1104	未知
 	user32.dll!00007ffd1ef41b3e	未知
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RunDesktopWindowMessageLoop	未知
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartDesktop	未知
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::Start	未知
 	[托管到本机的转换]	
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStatics.Microsoft.UI.Xaml.IApplicationStatics.Start	未知
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start	未知

Expected behavior NavigationView works

Screenshots

Version Info

NuGet package version: [WinUI 3 - Project Reunion 0.5 Preview: 0.5.0-prerelease]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
huoyaoyuancommented, Mar 31, 2021

If you hit F5 after the exception caught by VS, it will actually work.

0reactions
StephenLPeterscommented, Mar 31, 2021

Yes, it is a known issue that Acrylic brush does not work in winui3 currently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS 16 crash on dismiss sheet with navigationView
Hi, I've recently experienced a weird crash that only happening on iOS 16 device. When dismiss a sheet which contains NavigationView it sometime...
Read more >
SwiftUI: Trying to figure out NavigationView “Preview ...
1 Answer. Your preview is crashing because of an extra NavigationView in your preview, you don't need it. Your ContentView already has  ......
Read more >
SwiftUI FocusedBinding inside NavigationView causes ...
I am finding that using @FocusedBinding s in the way prescribed within Commands causes a consistent crash when focused is received by input ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found