-
Notifications
You must be signed in to change notification settings - Fork 742
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
WinUI: WebView2 does not display in UnoSdk project #18552
Comments
@baskren thank you for the extensive investigation, it really helped! I have a workaround now which is to add additional processor architectures in Configuration Manager: When building directly against x64, etc. |
@MartinZikmund : Thank you for giving this some attention. I'm trying to see if I can get the suggested work-around to work. When I go to the configuration manager, I see that I already have additional processor architectures: When I select just one (ex: Arm64 or X64), the WebView2 still does not appear. Given that you've a better understanding of the mechanics here, do you have a suggestion for me? To answer my own question on how to fix this if there are other platforms existing in the Configuration Manager:
|
CORRECTION: The above comment was for the 5.4.0-dev.261 version. Your suggested work-around works great for 5.4.10! |
@jeromelaban I was investigating this previously, but so far unable to figure out the difference relevant to WebView2 between binlogs for plain WinAppSDK app and Uno.Sdk app. For AnyCPU we are overriding the relevant runtime identifier in the SDK so technically it should not be a problem to have AnyCPU selected, but somehow it still matters in case of WebView2 and the required dependencies are not deployed along with the app. Can you check this if you have a chance? |
My guess is that it is related to the decoupling of WebView 2:
My guess would be that adding: <PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2950-prerelease" /> should fix the problem, but so far, adding the webview2 package crashes the app. |
@jeromelaban Based on the fact this workaround helps it seems that the AnyCPU is the problem, just not sure why the overrides Uno.Sdk does don't help:
|
A tentative fix is present in #18872, but in the meantime, adding this block in the csproj will help: <PropertyGroup>
<!-- Workaround for https://github.com/unoplatform/uno/issues/18552 -->
<PlatformTarget Condition=" '$(PlatformTarget)' == '' AND $(Platform) == 'AnyCPU' AND '$(NETCoreSdkRuntimeIdentifier)' == 'win-x86'">x86</PlatformTarget>
<PlatformTarget Condition=" '$(PlatformTarget)' == '' AND $(Platform) == 'AnyCPU' AND '$(NETCoreSdkRuntimeIdentifier)' == 'win-x64'">x64</PlatformTarget>
<PlatformTarget Condition=" '$(PlatformTarget)' == '' AND $(Platform) == 'AnyCPU' AND '$(NETCoreSdkRuntimeIdentifier)' == 'win-arm64'">arm64</PlatformTarget>
</PropertyGroup> |
The issue is fixed in latest dev (the workaround is included). |
I want to verify this once more, I was using latest dev from yesterday, so it should have been there already 🤔 |
@jeromelaban I tested now with the latest Applying the workaround directly in Repro:
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center">
<WebView2 x:Name="Test" />
</StackPanel>
public MainPage()
{
this.InitializeComponent();
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
await Test.EnsureCoreWebView2Async();
Test.CoreWebView2.Navigate("https://platform.uno");
} |
This feels like a different issue, but yes, maybe it needs to be applied earlier then. |
Current behavior
Two WinUI3 apps:
The plain WinUI3 app will render a WebView2 but the UnoSdk app will not.
Expected behavior
WebView2 works with in Uno.Sdk projects when targeting WinUI
How to reproduce it (as minimally and precisely as possible)
Expected Behavior: https://github.com/baskren/WinUi3WebView2.git
Current Behavior: https://github.com/baskren/UnoSdkWinuiWebView2.git
Workaround
None known at this time
Works on UWP/WinUI
Yes
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
Expected Behavior:
Current Behavior:
"Uno.Sdk": "5.4.10"
Affected platforms
Windows (WinAppSDK)
IDE
No response
IDE version
Microsoft Visual Studio Community 2022 (ARM 64-bit) - Current Version 17.11.5
Relevant plugins
VisualStudio Installed Products:
Microsoft Visual Studio Community 2022
Version 17.11.5
VisualStudio.17.Release/17.11.5+35327.3
Microsoft .NET Framework
Version 4.8.09032
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA155
Microsoft Visual C++ 2022
ASP.NET and Web Tools 17.11.231.19466
ASP.NET and Web Tools
AvaloniaPackage Extension 1.0
AvaloniaPackage Visual Studio Extension Detailed Info
Azure App Service Tools v3.0.0 17.11.231.19466
Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 17.11.231.19466
Azure Functions and Web Jobs Tools
C# Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
CleanBinAndObjCommand Extension 1.2.58
CleanBinAndObjCommand Visual Studio Extension Detailed Info
Extensibility Message Bus 1.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
GitHub Copilot 0.2.1657.32929
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.
ILSpy.AddIn 1.0
Integration of the ILSpy Decompiler into Visual Studio.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Node.js Tools 1.5.60329.1 Commit Hash:15fce86a17f9f33e5bd7ca7ccb9b216aff149252
Adds support for developing and debugging Node.js apps in Visual Studio
NuGet Package Manager 6.11.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Project System Tools 1.0
Tools for working with C#, VisualBasic, and F# projects.
Razor (ASP.NET Core) 17.11.3.2442001+68650a7d94261bc56a1f4bc522c2ee35314b1abb
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.11.47.0
Microsoft SQL Server Data Tools
TypeScript Tools 17.0.30715.2002
TypeScript Tools for Microsoft Visual Studio
Uno Platform Extension 1.0
Uno Platform Extension to create cross-platform apps using iOS, Android, mac Catalyst, Skia and WebAssembly.
Visual Basic Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
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.11.0-beta.24421.7+af2f522de602281d4ef5a7b71507c428e814c5c1
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info
Xamarin 17.11.0.98 (d17-11@86652fe)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.11.3.11 (remotes/origin/d17-11@cdbb0a4fdd)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: d9a6e87
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d
Xamarin.iOS and Xamarin.Mac SDK 16.4.0.23 (9defd91b3)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: