Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godot Web Build reloads infinitely on github.io #97580

Closed
Swarkin opened this issue Sep 28, 2024 · 18 comments · Fixed by #97645
Closed

Godot Web Build reloads infinitely on github.io #97580

Swarkin opened this issue Sep 28, 2024 · 18 comments · Fixed by #97645

Comments

@Swarkin
Copy link
Contributor

Swarkin commented Sep 28, 2024

Tested versions

4.4.dev2
master branch as of 28.09.2024

System information

Any

Issue description

Recording.2024-09-28.115226.mp4

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

@yankscally
Copy link

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

@RedMser
Copy link
Contributor

RedMser commented Sep 28, 2024

It is caused by following code (note the window.location.reload() at the end):

if (missing.length !== 0) {
if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) {
// There's a chance that installing the service worker would fix the issue
Promise.race([
navigator.serviceWorker.getRegistration().then((registration) => {
if (registration != null) {
return Promise.reject(new Error('Service worker already exists.'));
}
return registration;
}).then(() => engine.installServiceWorker()),
// For some reason, `getRegistration()` can stall
new Promise((resolve) => {
setTimeout(() => resolve(), 2000);
}),
]).catch((err) => {
console.error('Error while registering service worker:', err);
}).then(() => {
window.location.reload();
});

CC @adamscott

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

@Swarkin
Copy link
Contributor Author

Swarkin commented Sep 28, 2024

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

@AThousandShips AThousandShips added this to the 4.4 milestone Sep 28, 2024
@AThousandShips AThousandShips moved this from Unassessed to Bad in 4.x Release Blockers Sep 28, 2024
@AThousandShips
Copy link
Member

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

This comment was marked as outdated.

@RedMser
Copy link
Contributor

RedMser commented Sep 28, 2024

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).

@AThousandShips
Copy link
Member

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

@adamscott
Copy link
Member

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

@adamscott adamscott changed the title Godot Web Build reloads infinitely, ddosing my website Godot Web Build reloads infinitely on github.io Sep 30, 2024
@c6nabors
Copy link

c6nabors commented Oct 1, 2024

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

@adamscott
Copy link
Member

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.

@Swarkin
Copy link
Contributor Author

Swarkin commented Oct 4, 2024

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

@mhilbrunner mhilbrunner reopened this Oct 4, 2024
@mhilbrunner
Copy link
Member

cc @adamscott ^

@adamscott
Copy link
Member

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

@Swarkin
Copy link
Contributor Author

Swarkin commented Oct 4, 2024

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

@adamscott
Copy link
Member

@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.

@Swarkin
Copy link
Contributor Author

Swarkin commented Oct 4, 2024

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?

@adamscott
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

7 participants