Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question WebGL Build crashes when unfocusing (click away, alt-tab)

Discussion in 'WebGL' started by LinusGustafsson_, Jun 11, 2021.

  1. LinusGustafsson_

    LinusGustafsson_

    Joined:
    Jun 11, 2021
    Posts:
    2
    Hello!
    I've just upgraded a rather big project from 2018.2.21 to 2020.3.11 and it went rather well, considering.
    But now that it's uploaded on the server and I'm testing it I notice that the application "quits" (crashes?) when you unfocus the window. Like if you alt tab or you click away somewhere else.

    The only functionality currently that happens in the OnApplicationFocus fund is that the FPS gets limited to 1 and then gets unlimited (-1) when you re-focus. The only log I can see that seems to be connected is "Quitting..." & "done!". There's no earlier error that appears as this happens.

    I understand how vague the question is but if anyone as ever experienced something similar I would be ever grateful for any help that can be given!
    I'll grant any helper a cookie.

    Regards,
    Linus, a developer
     
  2. dlorddd

    dlorddd

    Joined:
    Aug 13, 2016
    Posts:
    7
    We have a similar issue where when unloading and reloading a WebGL app in our React frontend on unfocusing the browser the game gets stuck and CPU goes to constant 100% utilization.
     
  3. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
    The log messages you see are happeneing when you call Application.Quit() which I assume you are not. Does this also repro on an empty project for you? On any browser?
     
  4. LinusGustafsson_

    LinusGustafsson_

    Joined:
    Jun 11, 2021
    Posts:
    2
    Thanks for the answers!
    The CPU getting up to 100% is interesting, we'll have a look if ours act similar in the background!

    And you're correct, we never call Application.Quit, which is why we got a bit confused as to why we're seeing it. But it seems that any crash can cause that log to appear?

    And I have not yet had time to try creating a new project and uploading it, will try this during this week.
    And we have tried on Safari, Chrome & Firefox.
     
  5. Hypertectonic

    Hypertectonic

    Joined:
    Dec 16, 2016
    Posts:
    75
    This happens on an app of mine as well. Several browsers. I think it might be because of the way browsers handle tabs and memory, but I don't really know....
     
  6. phils_lab

    phils_lab

    Joined:
    Sep 28, 2019
    Posts:
    1
    This happens to our projects as well. .Quit() is called, but it seems like the GPU memory isn't purged at all (macOS latest, Firefox latest). This happens after some time, or almost instantly when switching tabs or unfocusing the browser window. Only the process of that tab crashes, the others remain intact. I also heard a lot about this being an issue with modern browser's garbage collection, but it really should be possible for us to unload a build and load another one.