maui icon indicating copy to clipboard operation
maui copied to clipboard

[regression/8.0.3] BlazorWebView does not initialize properly on Android platform

Open foximoxi opened this issue 1 year ago • 6 comments
trafficstars

Description

The Android build does not run Blazor properly resulting message:"There is not content at". On Windows Machine platform the app works without errors. Also works on MAUI 7.0.49/.NET 7.0.14 installed on the same machine.

Comparing trace values I noticed missing line: "Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Starting WebView2..."

My installation:

Visual Studio 17.8.1

Installed Workload Id Manifest Version Installation Source

macos 14.0.8478/8.0.100 SDK 8.0.100, VS 17.8.34316.72 maui-windows 8.0.3/8.0.100 VS 17.8.34316.72 maccatalyst 17.0.8478/8.0.100 VS 17.8.34316.72 ios 17.0.8478/8.0.100 VS 17.8.34316.72 android 34.0.43/8.0.100 VS 17.8.34316.72

Steps to Reproduce

  1. Create .NET MAUI Blazor Hybrid App

  2. Add (or not) initialization code in MauiProgram.cs builder.Services.AddLogging(logging => { logging.AddFilter("Microsoft.AspNetCore.Components.WebView", LogLevel.Trace); });

  3. Build and run in Debug on Android device

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.49

Affected platforms

Android

Affected platform versions

Tested on Android 13

Did you find any workaround?

no

Relevant log output

[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Creating Android.Webkit.WebView...
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Created Android.Webkit.WebView.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Creating file provider at content root 'wwwroot', using host page relative path 'index-android.html'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Starting initial navigation to '/'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Navigating to https://0.0.0.0/.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Handling web request to URI 'https://0.0.0.0/'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Response content being sent for web request to URI 'https://0.0.0.0/' with HTTP status code 404.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Running Blazor startup scripts.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Handling web request to URI 'https://0.0.0.0/favicon.ico'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Response content being sent for web request to URI 'https://0.0.0.0/favicon.ico' with HTTP status code 404.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Blazor startup scripts finished.

foximoxi avatar Nov 24 '23 15:11 foximoxi

@mkArtakMSFT fyi

samhouts avatar Dec 07 '23 17:12 samhouts

@foximoxi can you post a repro app for this posted as a public GitHub repo so that we can investigate?

Eilon avatar Dec 12 '23 21:12 Eilon

Hi @foximoxi. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

ghost avatar Dec 12 '23 21:12 ghost

I created repository: https://github.com/foximoxi/hybridappbugrepro

I also made some further investigations and I think that the bug is related to MAUI build pipeline:

  1. After update of VS to 17.8.3 I was not able to compile the project on PC dotnet new maui-blazor/New Project in VS (compilation errors below).
  2. I created a project and ran it correctly on my second machine (notebook) with the same VS 17.8.3+Android phone. I see Blazor template running on the phone.
  3. When I copy the project to my PC (including obj/bin):
    • The project builds only once. I do not see Blazor template but only "There is not content at"
    • After running the application I have compilation errors (the same when I create new project)
Build started at 8:00 AM...
1>------ Build started: Project: HybridApp, Configuration: Debug Any CPU ------
1>Components\Layout\MainLayout.razor : error BLAZOR101: More than one scoped css files were found for the razor component 'Components\Layout\MainLayout.razor'. Each razor component must have at most a single associated scoped css file.
1>Components\Layout\MainLayout.razor : error BLAZOR101: Components\Layout\MainLayout.razor.css
1>Components\Layout\MainLayout.razor : error BLAZOR101: Components\Layout\MainLayout.razor.css
1>Components\Layout\NavMenu.razor : error BLAZOR101: More than one scoped css files were found for the razor component 'Components\Layout\NavMenu.razor'. Each razor component must have at most a single associated scoped css file.
1>Components\Layout\NavMenu.razor : error BLAZOR101: Components\Layout\NavMenu.razor.css
1>Components\Layout\NavMenu.razor : error BLAZOR101: Components\Layout\NavMenu.razor.css
1>Done building project "HybridApp.csproj" -- FAILED.
1>Components\Layout\MainLayout.razor : error BLAZOR101: More than one scoped css files were found for the razor component 'Components\Layout\MainLayout.razor'. Each razor component must have at most a single associated scoped css file.
1>Components\Layout\MainLayout.razor : error BLAZOR101: Components\Layout\MainLayout.razor.css
1>Components\Layout\MainLayout.razor : error BLAZOR101: Components\Layout\MainLayout.razor.css
1>Components\Layout\NavMenu.razor : error BLAZOR101: More than one scoped css files were found for the razor component 'Components\Layout\NavMenu.razor'. Each razor component must have at most a single associated scoped css file.
1>Components\Layout\NavMenu.razor : error BLAZOR101: Components\Layout\NavMenu.razor.css
1>Components\Layout\NavMenu.razor : error BLAZOR101: Components\Layout\NavMenu.razor.css
1>Done building project "HybridApp.csproj" -- FAILED.
1>HybridApp -> C:\todelete\HybridApp\HybridApp\bin\Debug\net8.0-android\HybridApp.dll
1>HybridApp -> C:\todelete\HybridApp\HybridApp\bin\Debug\net8.0-windows10.0.19041.0\win10-x64\HybridApp.dll
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 8:00 AM and took 01.184 seconds ========== 

On both machines I have the same workloads. Everything is up to date.

Installed Workload Id      Manifest Version       Installation Source
--------------------------------------------------------------------------------
macos                      14.0.8490/8.0.100      SDK 8.0.100, VS 17.8.34330.188
maui                       8.0.3/8.0.100          SDK 8.0.100
maui-windows               8.0.3/8.0.100          VS 17.8.34330.188
maccatalyst                17.0.8490/8.0.100      VS 17.8.34330.188
ios                        17.0.8490/8.0.100      VS 17.8.34330.188
android                    34.0.52/8.0.100        VS 17.8.34330.188

foximoxi avatar Dec 13 '23 08:12 foximoxi

I did a full reinstall of Visual Studio (I removed all SDKS, workloads and IDE). I'm not able to compile MAUI Hybrid (same errors as previous)

Also: dotnet new maui-blazor dotnet build returns the same error list (above)

foximoxi avatar Dec 15 '23 18:12 foximoxi

I've fixed the problem:

  1. VS installer -> I've added Xamarin (because on my laptop it was installed)
  2. I've cleared nuget cache (Tools -> Options -> NuGet Package Manager -> Clear All Nuget Storage + system restart

Now I can build and run 8.0 app on android but I don't understand relation between build pipeline and nuget cache...something is wrong for sure.

foximoxi avatar Dec 31 '23 07:12 foximoxi

Looks like maybe a one-time hiccup. Let us know if it happens again with more info you might have uncovered by then. Thanks!

jfversluis avatar Mar 08 '24 10:03 jfversluis