ElectronNET / Electron.NET

:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).

Home Page:https://gitter.im/ElectronNET/community

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blank page when app started / no content

nazar322 opened this issue · comments

  • Version: 23.6.2
  • Target: win-x64, osx

In the built application sometimes the content is not loaded and therefore there is a blank space in the client area.
I have attached the screenshot.
Having googled the issue I see many have the same problem with just an electron and the typical solution would be changing the parameter in win.loadURL. F.i. https://stackoverflow.com/a/52497939/501082 or https://at15r.medium.com/electron-app-showing-white-screen-after-successful-build-but-work-in-development-mode-7e4f612a0871

I am able to reproduce this case on my Windows VM instance quite often, almost always, but rarely in osx or my host Windows computer.

I looked at main.js for the Host project and the only occurrence of loadURL is for the splash screen. The splash screen shows fine, however then the main window produces no content.

I'm really sweating bullets with this issue.
Does anyone have encountered it or perhaps has some ideas on the issue?

In OSX, I can press the red X button and then restore the app from the background, and the UI is loaded, but on Windows minimizing/restoring from the taskbar does not do anything.

VirtualBox_Windows 10 (64-bit) Home edition_17_04_2024_15_02_14

Here is the fix!

mainWindow.OnShow += OnMainWindowShown;
mainWindow.OnClosed += OnMainWindowClosed;

private static void OnMainWindowShown()
{
    if (!_windowShownFlag)
        ElectronHelper.MainWindow.Reload();

    _windowShownFlag = true;
}

private static void OnMainWindowClosed()
{
    _windowShownFlag = false;
}