maui
maui copied to clipboard
MAUI Blazor for Windows: PushModalAsync-Issue
Description
In a MAUI blazor app, it is not always possible to open a content page as modal dialog in Windows.
-
Start MAUI Blazor App:

-
Click on Button "Open modal page" (which calls a ContentPage) - Code:

-
Unhandled Win32 Exception appears:

Steps to Reproduce
-
Create .NET MAUI Blazor-App
-
Add new .NET MAUI ContentPage (XAML)

-
Add new button which opens the newly created modal dialog page:

4a) Case ERROR SHOWN:
After clicking on the button, the modal ContentPage sometimes does not appear... Win32 Exception is shown instead:

4b) Case NO ERROR SHOWN:
After clicking on the button, the modal ContentPage appears correctly:
Click on "Close me" - Executed code: await Navigation.PopModalAsync();
Click on the button again (1) and click anywhere in the white background (2), before the modal page appears - Win32-Exception appears:

MauiAppBlazorModalBug_20220809.zip
dotnet version: 6.0.400-preview.22330.6 Visual Studio Version: Enterprise - 17.3.0 Preview 6
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 10 (my OS: Version 10.0.19044 Build 19044)
Did you find any workaround?
no
Relevant log output
No response
Hi @reinhardlackner , can you show the full stack trace of the exception when this happens? That would help us route this issue to the appropriate team.
Hi @reinhardlackner , can you show the full stack trace of the exception when this happens? That would help us route this issue to the appropriate team.
@Eilon Unfortunately I was not able to add a debugger after the crash.

Visual Studio 2022 (Version 17.3.0) shows following error after case 4b:
The program '[30464] MauiAppBlazorModalBug.exe: Program Trace' has exited with code 0 (0x0).
The program '[30464] MauiAppBlazorModalBug.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'

In Windows Logs (Section Application) following error is shown: Faulting application name: MauiAppBlazorModalBug.exe, version: 1.0.0.0, time stamp: 0x62cf0990 Faulting module name: Microsoft.ui.xaml.dll, version: 3.0.0.2207, time stamp: 0x9fca4060 Exception code: 0xc0000005 Fault offset: 0x00000000000e61cd Faulting process id: 0x7700 Faulting application start time: 0x01d8ac8c5eae5095 Faulting application path: C:\Users\reinhardl\source\repos\MauiAppBlazorModalBug\MauiAppBlazorModalBug\bin\Debug\net6.0-windows10.0.19041.0\win10-x64\AppX\MauiAppBlazorModalBug.exe Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1003.565.600.0_x64__8wekyb3d8bbwe\Microsoft.ui.xaml.dll Report Id: a999fb3c-2e2c-46e3-aa18-dc0056c5e20c Faulting package full name: 2CBBE3FF-0072-4FD1-88C5-2553BA52786E_1.0.0.1_x64__9zz4h110yvjzm Faulting package-relative application ID: App

Alright thank you for the info, we will try to reproduce this and investigate.
Hi @reinhardlackner , I was able to reproduce an exception in this app when I specifically attach native debugging and catch all exceptions. I then get this error, but I'm not sure if it's the same error as you're seeing:
Exception thrown at 0x00007FFC60C7474C (KernelBase.dll) in TestMBPushModalAsync.exe: 0x40080202: WinRT transform error (parameters: 0x000000008000000B, 0x0000000080070490, 0x0000000000000014, 0x000000F0F5979D50).
> KernelBase.dll!RaiseException() Unknown
combase.dll!RoTransformErrorImpl(HRESULT oldError=0x8000000b, HRESULT newError=0x80070490, unsigned int cchMax=0, const wchar_t * message=0x000000f0f59791a0) Line 656 C++
twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplication::GetCurrentView(struct Windows::ApplicationModel::Core::ICoreApplicationView * *) Unknown
twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationFactory::GetCurrentView() Unknown
Microsoft.UI.Xaml.Controls.dll!SharedHelpers::TryGetCurrentCoreApplicationView() Unknown
Microsoft.UI.Xaml.Controls.dll!NavigationView::OnApplyTemplate() Unknown
Microsoft.UI.Xaml.Controls.dll!winrt::impl::produce<NavigationView,winrt::Microsoft::UI::Xaml::IFrameworkElementOverrides>::OnApplyTemplate() Unknown
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.OnApplyTemplate(WinRT.IObjectReference _obj = {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.OnApplyTemplate() Unknown
Microsoft.Maui.dll!Microsoft.Maui.Platform.MauiNavigationView.OnApplyTemplate() Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.OnApplyTemplate() Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_OnApplyTemplate_2(System.IntPtr thisPtr) Unknown
[Native to Managed Transition]
Microsoft.ui.xaml.dll!DirectUI::FrameworkElementGenerated::OnApplyTemplateProtected() Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkElement::OnApplyTemplateFromCore() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::InvokeApplyTemplate() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CContentPresenter::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CGrid::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!DirectUI::UIElementGenerated::Measure() Unknown
Microsoft.ui.xaml.dll!DirectUI::Page::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkElement::MeasureOverrideFromCore() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CControl::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkElementGenerated::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!DirectUI::ContentControl::MeasureOverride() Unknown
Microsoft.ui.xaml.dll!00007ffb45f49420() Unknown
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(WinRT.IObjectReference _obj = {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}, Windows.Foundation.Size availableSize = {Windows.Foundation.Size}) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Windows.Foundation.Size availableSize = {Windows.Foundation.Size}) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Windows.Foundation.Size availableSize = {Windows.Foundation.Size}) Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(System.IntPtr thisPtr, Windows.Foundation.Size availableSize, Windows.Foundation.Size* result) Unknown
[Native to Managed Transition]
Microsoft.ui.xaml.dll!DirectUI::FrameworkElement::MeasureOverrideFromCore() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!DirectUI::UIElementGenerated::Measure() Unknown
[Managed to Native Transition]
Microsoft.Maui.dll!Microsoft.Maui.Platform.WindowRootViewContainer.MeasureOverride(Windows.Foundation.Size availableSize) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Windows.Foundation.Size availableSize = {Windows.Foundation.Size}) Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(System.IntPtr thisPtr, Windows.Foundation.Size availableSize, Windows.Foundation.Size* result) Unknown
[Native to Managed Transition]
Microsoft.ui.xaml.dll!DirectUI::FrameworkElement::MeasureOverrideFromCore() Unknown
Microsoft.ui.xaml.dll!CFrameworkElement::MeasureCore() Unknown
Microsoft.ui.xaml.dll!CUIElement::MeasureInternal() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CUIElement::Measure() Unknown
Microsoft.ui.xaml.dll!CLayoutManager::UpdateLayout() Unknown
Microsoft.ui.xaml.dll!CCoreServices::NWDrawTree() Unknown
Microsoft.ui.xaml.dll!CCoreServices::NWDrawMainTree() Unknown
Microsoft.ui.xaml.dll!CWindowRenderTarget::Draw() Unknown
Microsoft.ui.xaml.dll!CXcpBrowserHost::OnTick() Unknown
Microsoft.ui.xaml.dll!CXcpDispatcher::Tick() Unknown
Microsoft.ui.xaml.dll!CXcpDispatcher::OnReentrancyProtectedWindowMessage() Unknown
Microsoft.ui.xaml.dll!CXcpDispatcher::WindowProc() Unknown
Microsoft.ui.xaml.dll!CDeferredInvoke::DispatchQueuedMessage() Unknown
Microsoft.ui.xaml.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl ABI::Windows::Foundation::ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Microsoft::UI::Dispatching::DispatcherQueueTimer *,ABI::Microsoft::UI::Dispatching::IDispatcherQueueTimer *>,IInspectable *>::*)(ABI::Microsoft::UI::Dispatching::IDispatcherQueueTimer *,IInspectable *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,ABI::Windows::Foundation::ITypedEventHandler<ABI::Microsoft::UI::Dispatching::DispatcherQueueTimer *,IInspectable *>,Microsoft::WRL::FtmBase>,<lambda_e857fdb067b9ae81889f07225ce1ccec> &,1,ABI::Microsoft::UI::Dispatching::IDispatcherQueueTimer *,IInspectable *>::Invoke() Unknown
CoreMessagingXP.dll!Microsoft::WRL::Details::DelegateArgTraits<long ( Windows::Foundation::ITypedEventHandler_impl<struct Windows::Foundation::Internal::AggregateType<class Microsoft::UI::Dispatching::DispatcherQueueTimer *,struct Microsoft::UI::Dispatching::IDispatcherQueueTimer *>,struct IInspectable *>::*)(struct Microsoft::UI::Dispatching::IDispatcherQueueTimer *,struct IInspectable *)>::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_82cf8073f4f042d1a68771c460cb9f49>,-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_1e854da9c9ccd42f6138c3b007a32877>,struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Dispatching::DispatcherQueueTimer *,struct IInspectable *> >(class <lambda_1e854da9c9ccd42f6138c3b007a32877>,class Microsoft::WRL::Details::EventTargetArray *,class Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Dispatching::DispatcherQueueTimer *,struct IInspectable *>,struct Microsoft::WRL::InvokeModeOptions<-2> > *) Unknown
CoreMessagingXP.dll!Microsoft::UI::Dispatching::DispatcherQueueTimer::TimerCallback(void *) Unknown
CoreMessagingXP.dll!CFlat::SehSafe::Execute<<lambda_654db17c35df07198786f0867aa10de6>>() Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::TimeoutHandler::ImportAdapter$(class CFlat::Box$1<struct CFlat::FunctionPointerAndUserData$1<long (*)(void *)> > *) 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,bool,struct CFlat::Ref<struct System::IntPtr>) Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch(bool,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,struct CFlat::Ref<struct System::IntPtr>) Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatchRaw(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool,struct CFlat::Ref<struct System::IntPtr>) Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DoWork(struct HWND__ *,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool) 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
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RunDesktopWindowMessageLoop() Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartDesktop() Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::Start() Unknown
The same exception that I saw also happens without any Blazor. Lots of various Win32 (or C++?) exceptions, but they are all first-chance, so without a debugger you can't see them.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Not repro on Windows platform with sample project.
MauiAppBlazorModalBug_20220809.zip
Hi @reinhardlackner. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.