tryphotino / photino.Blazor

https://tryphotino.io
Apache License 2.0
344 stars 63 forks source link

Shows white screen while loading WebView2 component #142

Open svetovid opened 2 weeks ago

svetovid commented 2 weeks ago

During application startup before index.html loaded, the window is just white. It would be nice to change its color, or even set a splashscreen.

On my Windows 10 computer, I have Dark theme enabled
Screenshot 2024-10-29 094550

But, while I'm waiting for the web content (presumably, waiting for WebView2 to be loaded), the window is white

Screenshot 2024-10-29 094750_2

When index.html downloaded, the Dark theme is applied

Screenshot 2024-10-29 094817_2

Please, advise how to make the window black or set a splashscreen, because I didn't find anything useful in the library API

evandrofadul commented 4 days ago

I have the same question. I am migrating my WPF Blazor Hybrid application to Photino, but in Blazor Hybrid running on Windows it is possible to make the screen transparent using the environment variable:

Environment.SetEnvironmentVariable("WEBVIEW2_DEFAULT_BACKGROUND_COLOR", "0");

However, this did not have the same effect in Photino, and I am looking for an alternative.

MikeYeager commented 1 day ago

You may want to try setting the BrowserControlInitParameters using --cast-app-background-color. This type of setting is browser control dependent, so it will be different on each OS. Here are some links https://peter.sh/experiments/chromium-command-line-switches/

https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2environmentoptions.additionalbrowserarguments?view=webview2-dotnet-1.0.1938.49&viewFallbackFrom=webview2-dotnet-1.0.1901.177view%3Dwebview2-1.0.1901.177

https://www.chromium.org/developers/how-tos/run-chromium-with-flags/

evandrofadul commented 1 day ago

I tried using the 2 commands below, but I was unsuccessful

app.MainWindow.SetBrowserControlInitParameters("--cast-app-background-color=00000000");
app.MainWindow.SetBrowserControlInitParameters("--default-background-color=00000000");

I also used other commands to test, but apparently none of them affected WebView. I'm not sure if I used the commands correctly.