tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
897 stars 73 forks source link

Load url after Load static HTML file doesn't work #220

Open r-pankevicius opened 4 days ago

r-pankevicius commented 4 days ago

OS: Win11.

I updated Photino.NET package to latest today (3.1.18) and noticed that app starts freezing in "loading page".

Our app initially (from Main, STAThread) loads loading screen from the file, then after Kestrel server boots up we redirect window there.

Shortened code:

var hostApplicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
hostApplicationLifetime.ApplicationStarted.Register(() =>
{
    var server = host.Services.GetRequiredService<IServer>();
    var addressFeature = server.Features.Get<IServerAddressesFeature>();
    string hostAddress = addressFeature.Addresses.FirstOrDefault();
    if (hostAddress is not null)
    {
        MainPhotinoWindow.Load(hostAddress);
    }
}, useSynchronizationContext: true);

MainPhotinoWindow.Load(path: "LoadingPage.html");

It worked fine earlier, so I started to downgrade Photino.NET to earlier versions and found that it still works with 3.1.15.

So this error starts from Photino.NET version 3.1.16.

MikeYeager commented 2 days ago

@r-pankevicius Our first thought is, have you tried putting a breakpoint in your ApplicationStarted.Register() code? Does it fire? Does it throw an exception? We're happy to take a look if you have a repo you can share with us that contains the complete code so we can try it out ourselves.

r-pankevicius commented 1 day ago

@MikeYeager I've created a simplest example here: https://github.com/r-pankevicius/MyPhotinoApps

SimplePhotinoApp has a ref to Photino.NET v 3.1.16 to show the intended behaviour.

Changing it to 3.1.18 makes app often (not always) to not redirect to web page from "loading" page.

r-pankevicius commented 1 day ago

BTW ApplicationStarted.Register(callback) is invoked, debugger hit breakpoint, MainPhotinoWindow.Load(hostAddress) was called.