cfoust / sour

Sauerbraten for the web in a single Docker image.
https://sourga.me/
MIT License
159 stars 30 forks source link

Allow for backgrounding the tab by responding to pings #39

Open cfoust opened 1 year ago

cfoust commented 1 year ago

Right now, when the tab is backgrounded the game is completely suspended, which makes sense because it uses requestAnimationFrame. Unfortunately this means the game completely stops responding to pings from the server, meaning that other players see the user go into the LAG state on the scoreboard and after a few seconds, the server disconnects them (at least on community servers).

Theoretically this could be solved by running the game in a Web Worker and or man-in-the-middling communication with the server in the backend and responding to pings on behalf of the user. The former would be ideal, but is extremely complicated from what I can gather. The latter is not ideal because when the user returns to the tab, there will be a significant buildup of server messages that may cause bugs or a temporary slowdown.