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

HybridWebView crashes Maui App built with .Net 9.0.1 GA / Windows on ARM / 23H2 #26116

Open
atanubanerjee opened this issue Nov 26, 2024 · 6 comments
Labels
area-controls-hybridwebview HybridWebView control platform/windows 🪟 t/bug Something isn't working
Milestone

Comments

@atanubanerjee
Copy link

Description

Build any .Net MAUI App that has a page with a HybridWebView control on a Windows ARM laptop running .Net 9.0.1 and Windows 11 23H2. Navigating to that page causes an Unhandled Exception in App.g.i.cs. This is true even if you just run the .Net Maui sample app for HybridWebView, or the code on the online documentation for HybridWebView.

This was working fine in .Net 9 RC1 and RC2 on the same laptop - and so this appears to be a regression in .Net 9 GA. Uninstalling / reinstalling Visual Studio and .Net SDK doesn't change this behavior.

The same Maui Sample App for HybridWebView doesn't crash on a Windows 11 x86 laptop running 24H2 - so this might happen only for Windows on ARM, or 23H2 version of Windows 11.

Steps to Reproduce

  1. Setup Visual Studio 2022 on a Windows on ARM PC running Windows 11 23H2 and .Net 9.0.1
  2. Build and run the HybridWebView sample app from here:
    https://github.com/dotnet/maui-samples/tree/main/9.0/UserInterface/Views/HybridWebViewDemo
  3. Observe that the app crashes in App.g.i.cs

Link to public reproduction project repository

https://github.com/dotnet/maui-samples/tree/main/9.0/UserInterface/Views/HybridWebViewDemo

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.0-rc.2.24503.2

Affected platforms

Windows

Affected platform versions

Windows 11 23H2 ARM64 , Target Windows SDK Framework 10.0.19041.0, Min Target 10.0.17763.0

Did you find any workaround?

Build and run the same app on a different laptop running Windows 11 24H2 x86. So switching from Windows ARM to Windows x86, and from 23H2 to 24H2, prevents the crash.

Relevant log output

@atanubanerjee atanubanerjee added the t/bug Something isn't working label Nov 26, 2024
@jfversluis jfversluis added the area-controls-hybridwebview HybridWebView control label Nov 26, 2024
@jfversluis jfversluis added this to the Backlog milestone Nov 26, 2024
@jfversluis
Copy link
Member

@Eilon

@Bowman74
Copy link

Bowman74 commented Nov 26, 2024

I have encountered this as well in Parallels in a M2 Mac. I was going to add a bug for it, but I see this one was just added. This is likely a pretty major issue as likely the majority of people who are doing MAUI development are doing so on Macs due to iOS restrictions. That means Parallels on an Silicon chip which is based on ARM if they want to cross platform to a Windows app. This also leads me to believe such apps will not run on an ARM based machine, regardless of where they were developed and compiled. I.e. this bug will prevent it from running on many of Microsoft's own new devices.

System Information
Apple M2 Pro
Sequoia 15.1

Parallels Desktop for Mac Version 20.1.1 (55740)

Windows 11 Pro 23H2

Relevant log output
{Microsoft.UI.Xaml.UnhandledExceptionEventArgs}
Exception: {"%1 is not a valid Win32 application.\r\n\r\n%1 is not a valid Win32 application.\r\n"}
Handled: false
Message: "%1 is not a valid Win32 application.\r\n\r\n%1 is not a valid Win32 application.\r\n"
ThisPtr: 0x000002554abee540
WinRT.IWinRTObject.AdditionalTypeData: Count = 0
WinRT.IWinRTObject.HasUnwrappableNativeObject: true
WinRT.IWinRTObject.NativeObject: {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}
WinRT.IWinRTObject.QueryInterfaceCache: Count = 0
_additionalTypeData: Count = 0
_inner: {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}
_objRef_global__Microsoft_UI_Xaml_IUnhandledExceptionEventArgs: {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}
_queryInterfaceCache: Count = 0

Exception:
{"%1 is not a valid Win32 application.\r\n\r\n%1 is not a valid Win32 application.\r\n"}
Data: Count = 6
ErrorCode: -2147024703
HResult: -2147024703
HasBeenThrown: true
HelpLink: null
InnerException: null
Message: "%1 is not a valid Win32 application.\r\n\r\n%1 is not a valid Win32 application.\r\n"
SerializationStackTraceString: " at Microsoft.Maui.Handlers.HybridWebViewHandler.HybridWebView2Proxy.TryInitializeWebView2(WebView2 webView)\r\n at Microsoft.Maui.Handlers.HybridWebViewHandler.b__37_0()\r\n at System.Threading.Tasks.Task.<>c.b__128_0(Object state)\r\n at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.b__0()"
SerializationWatsonBuckets: null
Source: "Microsoft.Maui"
StackTrace: " at Microsoft.Maui.Handlers.HybridWebViewHandler.HybridWebView2Proxy.d__7.MoveNext()\r\n at Microsoft.Maui.Handlers.HybridWebViewHandler.<b__37_0>d.MoveNext()\r\n at System.Threading.Tasks.Task.<>c.b__128_0(Object state)\r\n at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.b__0()"
TargetSite: {Void MoveNext()}
_HResult: -2147024703
_data: Count = 6
_exceptionMethod: null
_helpURL: null
_innerException: null
_ipForWatsonBuckets: 0x00007ffd93f69d67
_message: "%1 is not a valid Win32 application.\r\n\r\n%1 is not a valid Win32 application.\r\n"
_remoteStackTraceString: null
_source: null
_stackTrace: {sbyte[528]}
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: 0x0000000000000000

@Bowman74
Copy link

Bowman74 commented Nov 26, 2024

This also brings up another thought. The team added a lot of automated regression testing for MAUI as part of .Net 9. That is great and I love seeing it. My further question is, are the automated tests for Windows sections of the framework running on Intel and ARM based machines? If not, that may represent a gap in the automated testing.

@atanubanerjee
Copy link
Author

When I created this bug report, I wasn't sure if this happens to all Windows on ARM laptops, or just a subset of them. But if the former then I agree with @Bowman74 that this is pretty bad. Anybody using any of the new Copilot+ Windows PCs (e.g., Surface Pro 7, Surface Laptop 7, ...), or an M* series Mac MBP / Air / Studio / Mini, for Maui development is going to be blocked from using the new HybridWebView control.

@Bowman74
Copy link

Also, to be clear on a Mac I can run in Android and iOS MAUI apps just fine (I haven't tried MacOS apps yet). It is only when I deploy to Windows and try to run it as a Windows app in Windows that I get this error.

I assume MS wants the apps to work in Windows on ARM machines. :)

Also it compiles without a hitch. The error is a runtime error.

@Bowman74
Copy link

I did verify it works correctly in MacCatalyst as well. It is only an issue when running in Windows in some flavor of ARM processor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-hybridwebview HybridWebView control platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants