tryphotino / photino.Blazor

https://tryphotino.io
Apache License 2.0
332 stars 62 forks source link

HelloWorld Blazor Sample not loading on Linux #43

Closed mdemler closed 2 years ago

mdemler commented 2 years ago

Attempting to run the sample from here. Runs fine when published and run on Windows, but under Linux, the window displays with the content "There is no content at ". The Photino.NET sample here works just fine.

Any ideas? Running Ubuntu 21.10.

Thanks!

Mike

Denny09310 commented 2 years ago

Attempting to run the sample from here. Runs fine when published and run on Windows, but under Linux, the window displays with the content "There is no content at ". The Photino.NET sample here works just fine.

Any ideas? Running Ubuntu 21.10.

Thanks!

Mike

Same error on Manjaro KDE. I noticed just now that if in the NavigateCore method you replace Load with LoadRawString it loads the html correctly.

image

Maybe not a Photino.NET error but a Blazor error?

mdemler commented 2 years ago

I unfortunately don't have a Linux machine, but have been going back and forth with someone else on my team that does and is seeing this issue, so getting it fully understood has been slow. I do not see this issue running Ubuntu under WSL (Windows Subsystem for Linux) on my machine.

So far, we have traced it to the TryGetResponseContent() call in PhotinoWebViewManager.HandleWebRequest(). In looking at the source code for it, there appears to be an issue with it failing to access files in wwwroot, which we are still working to pinpoint.

Denny09310 commented 2 years ago

Okay, I made some progress. After debugging the source code of .NET Core I found out that it wasn't a Blazor related problem neither a Photino.Blazor, but a typo (or some mistake). If you see the "Index.html" file in wwwroot, it has the "I" with a capital letter, but the path shows that he's searching for "index.html" with a non-captal letter and unfortunately linux is case sensitive while windows is not, so the program is generating the FileNotFoundException.

image

After renaming the index.html file the webview loaded the blazor application, but there's another problem coming up. In the console it shows the following error "Cannot receive IPC messages when no page is attached"

image

If you find out how to resolve this second problem please tell me ASAP, because I need Photino.Blazor to work for a project

EDIT: Ok I just tryed to reload the page and i'ts working, so the second problem is just a one-time error at the startup. I tracked down the error and it seems to be in the window.__receiveMessageCallbacks function

image

mdemler commented 2 years ago

Fantastic work! Oddly, WSL does not exhibit file name case sensitivity, and I'm too much of a Linux newbie to have caught that. It looks like there has been an effort to fix this here, but it hasn't yet found its way back to master.

The IPC message error that you're seeing is exactly what I was hitting on WSL. Good to know that it's not just there. The issue is in PhotinoWebViewManager.SendMessage(). Under Windows, this call returns and processing continues at lower levels, but under Linux, it blocks and a message is received right away via PhotinoWindow.WebMessageReceived. To avoid this, that call needs to be made async. I changed the body of this method to the below, which looks to have done the job:

Task.Run(() => Dispatcher.InvokeAsync(() => _window.SendWebMessage(message)));

Denny09310 commented 2 years ago

Fantastic work! Oddly, WSL does not exhibit file name case sensitivity, and I'm too much of a Linux newbie to have caught that. It looks like there has been an effort to fix this here, but it hasn't yet found its way back to master.

The IPC message error that you're seeing is exactly what I was hitting on WSL. Good to know that it's not just there. The issue is in PhotinoWebViewManager.SendMessage(). Under Windows, this call returns and processing continues at lower levels, but under Linux, it blocks and a message is received right away via PhotinoWindow.WebMessageReceived. To avoid this, that call needs to be made async. I changed the body of this method to the below, which looks to have done the job:

Task.Run(() => Dispatcher.InvokeAsync(() => _window.SendWebMessage(message)));

That works great! Thanks for the help. Can we make a pull request with the fixes? I'd like to improve this project as it's a good starting point

EDIT: I just saw that the pull request that you linked is in Photino.Blazor and not Photino.NET, regarding this second fix i didn't find any pull request for now

mdemler commented 2 years ago

Resolving Denny09310's find on the casing issue of index.html did indeed address the issue that I was seeing, combined with the next encountered issue of needing to dispatch the SendWebMessage call.

ottodobretsberger commented 2 years ago

@mdemler could you provide a pull request for this? We will test it and then we can merge it in if all tests pass.

mdemler commented 2 years ago

Both of the issues reported here have been addressed by other commits.