Search Issue Tracker

Duplicate

Votes

13

Found in

2017.3.1f1

Issue ID

1034639

Regression

No

[WebGL][Chrome] game freezes after switching the browser tabs

WebGL

-

To reproduce:

1. Open the project, attached by the user (link in the edit)
2. Build and run for WebGL
3. In the build, switch the tabs back and forth a couple of times
4. Observe that the game freezes

Expected: the game doesn't freeze when switching between tabs

Reproduced in 2017.3.1f1, 2017.4.2f2
Could not reproduce in later and earlier versions due to shader and other errors in the console which prevents the building of the project completely

Comments (14)

  1. shubhamswaraj2021

    Aug 18, 2020 09:22

    good one <a href="https://www.lyricsauto.com">lyricsauto</a>

  2. ikarus1102

    Jan 07, 2019 06:42

    Hi, is there any fixes for this issue?

    I had the same problem with cocos2d js, when the tab is inactive (switching tab) my game will be freeze because the setTimeOut / setInterval or requestAnimationFrame only be call at 1 per second or less. Then I found a trick to workaround this issue: I used web worker or shared web worker to update my models (position, orientation etc...) then when tab become active I re-render things. This make my game become active even if tab is inactive (my game is an online game).
    But I don't know how to implement this in unity webgl (I'm new to unity). Does anyone have idea?

  3. EmperorTim

    Oct 09, 2018 02:42

    Yep fellow "Application.targetFrameRate" user too. Hopefully there's a fix in pipeline

  4. vrobel

    Oct 08, 2018 20:22

    Pardon me, AIFIRST. I didn't notice your comment now, I reviewed these comments before you posted. I came up with the same resolution as you. Cheers.

  5. vrobel

    Oct 08, 2018 20:19

    I've been researching this issue. I've just submitted a bug with attached project to Unity.

    Here's what I've found:
    WebGL app that is running in Chrome freezes when switching tabs, but only when custom target frame rate is set. It's not completely frozen but it's just not rendering. All sounds and mouse interactions are working, you just can't see anything on screen live.

    To get back into running you can just resize current window or change scale in Chrome (Ctrl + mouse scroll or Ctrl + '+').

    Also when setting FPS Chrome shows this error:
    > Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!

    Resetting FPS to -1 doesn't fix the issue.

  6. aifirst

    Sep 29, 2018 09:01

    I resolved by removing Application.targetFrameRate sentence.
    If Application.targetFrameRate is present, webgl make warning

    "Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!"

    and sometime freeze when minimize and recover.

    I think unity3d should requestAnimationFrame when Application.targetFrameRate is present.

  7. EmperorTim

    Sep 26, 2018 07:18

    Same issue as PSCHAUSSPLAYA on 2018.2.9f1. Resizing the browser sorts it out but not a great user experience

  8. PSchaussPlaya

    Sep 18, 2018 08:12

    Any update on this? This is a very serious problem as Chrome is the most popular browser. The probelm still occurs with Unity 2018.2.8f1.

    It can be easily reproduced by keeping the game tab inactive for a while. Either by opening another tab or by minimizing the brower window. Sometimes a minute is enough, sometimes it needs to be more time.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.