godot icon indicating copy to clipboard operation
godot copied to clipboard

Godot Web Build reloads infinitely on github.io

Open Swarkin opened this issue 1 year ago • 17 comments

Tested versions

4.4.dev2 master branch as of 28.09.2024

System information

Any

Issue description

https://github.com/user-attachments/assets/80af8339-850d-414c-b9a1-12313b0eda42

Steps to reproduce

  1. Go to https://swarkin.github.io/wsclicker

Minimal reproduction project (MRP)

Not a MRP but the project in question: https://github.com/Swarkin/wsclicker

Swarkin avatar Sep 28 '24 09:09 Swarkin

hey - I've been following this project.

tested this and got the same result on ChromeOS

Screen recording 2024-09-28 10.46.57 AM.webm

yankscally avatar Sep 28 '24 10:09 yankscally

It is caused by following code (note the window.location.reload() at the end): https://github.com/godotengine/godot/blob/76a135926aef1f02f27e4e09093787f2c670956d/misc/dist/html/full-size.html#L153-L171

CC @adamscott

As workaround, you can try disabling the "ensure cross origin isolation headers", or PWAs as a whole, in export options @Swarkin

RedMser avatar Sep 28 '24 12:09 RedMser

I cannot do this as I need CORS headers for threads to work...

Swarkin avatar Sep 28 '24 12:09 Swarkin

For me the following error occurs in the console for the running page:

Uncaught (in promise) TypeError: Failed to execute 'addAll' on 'Cache': Request failed

AThousandShips avatar Sep 28 '24 12:09 AThousandShips

Have you actually built the template with threads? ~The template file doesn't have threads in the name which is normally added, you need to build it with threads explicitly enabled~ (my bad the template has nothreads when disabled)

AThousandShips avatar Sep 28 '24 12:09 AThousandShips

I cannot do this as I need CORS headers for threads to work...

I haven't done any threaded web apps before, so my assessment might be wrong. But as far as I can read online (search for "github pages cross origin isolation"), you need to do some additional work to enable cross origin isolation headers on github pages. Here is one example I found: https://docs.wasmer.io/sdk/wasmer-js/how-to/coop-coep-headers

But the infinite reload is still something that should be fixed (show an error message on the web page instead).

RedMser avatar Sep 28 '24 12:09 RedMser

But the infinite reload is still something that should be fixed (show an error message on the web page instead).

This might be something that happens before the engine can load properly (it seems at least one error happens immediately in the service worker) so might be something we don't have any power over, but not sure exactly where things are breaking exactly

AThousandShips avatar Sep 28 '24 12:09 AThousandShips

I don't have access to a computer this weekend, but I'll see what I can do Monday.

adamscott avatar Sep 28 '24 17:09 adamscott

I cannot do this as I need CORS headers for threads to work...

https://github.com/gzuidhof/coi-serviceworker gets around the use of headers on hosters where you cannot change them

c6nabors avatar Oct 01 '24 19:10 c6nabors

I cannot do this as I need CORS headers for threads to work...

https://github.com/gzuidhof/coi-serviceworker gets around the use of headers on hosters where you cannot change them

We do handle this directly in the Web export template since #86089.

adamscott avatar Oct 02 '24 14:10 adamscott

I am still experiencing this issue, website reloading infinitely. I updated my web build from master an hour ago. Both firefox and chromium, I have reloaded without cache using ctrl+shift+r as well as ticking the disable cache box in the network debugger. image

Swarkin avatar Oct 04 '24 16:10 Swarkin

cc @adamscott ^

mhilbrunner avatar Oct 04 '24 16:10 mhilbrunner

@Swarkin Did you rename wsclicker_client_web_wasm32.html to index.html?

adamscott avatar Oct 04 '24 17:10 adamscott

I did, do I need to rename everything containing wsclicker_client_web_wasm32 to index?

Swarkin avatar Oct 04 '24 17:10 Swarkin

@Swarkin Try exporting the project using index.html as name directly (without any renaming afterwards). We should advise people to never rename files in the docs.

The service worker fails to load wsclicker_client_web_wasm32.html and then everything fails.

adamscott avatar Oct 04 '24 17:10 adamscott

Seems like that was the actual issue, even though Im pretty sure that it worked this way in the past? Anyways thank you! Should we convert this into a documentation issue and leave it open?

Swarkin avatar Oct 04 '24 17:10 Swarkin

Seems like that was the actual issue, even though Im pretty sure that it worked this way in the past? Anyways thank you! Should we convert this into a documentation issue and leave it open?

There's definitely something wrong when a file can't be loaded. I'll try to fix the infinite loading.

adamscott avatar Oct 04 '24 18:10 adamscott

Weird. I tried to rename in a small test project test.html to index.html, and it still works...

I'll create a PR for the documentation and close this issue. Then, if the problem returns, I'll be there to fix it.

adamscott avatar Oct 25 '24 17:10 adamscott