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 (11)

  1. 9c08f6bf6350e1708cb81bf68d4cb2df?d=mm

    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?

  2. 8d25e920bd2cd69b85b5d0d59f82d188?d=mm

    EmperorTim

    Oct 09, 2018 02:42

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

  3. 9c3e13c735074d0cf5cb245eb44baed1?d=mm

    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.

  4. 9c3e13c735074d0cf5cb245eb44baed1?d=mm

    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.

  5. D60d821a828b23c2899c591ba3336982?d=mm

    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.

  6. 8d25e920bd2cd69b85b5d0d59f82d188?d=mm

    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

  7. 3bc834947524395cd0f240fed11f1de7?d=mm

    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.

  8. 14b9b9f5bb644aa944ed5cb798fbc08c?d=mm

    Walkure

    Jul 31, 2018 14:17

    I found some steps :
    1) open Web-GL game
    2) open console (f12) only for fast un-focus
    3) goto other page ( sometimes i reload different pages )
    4) return and click on game canvas -> freeze 80% chance.
    But our game still write logs to console and handle click by screen =)
    But render is disabled.

    Fix : canvas resizing helps but it very bad idea =)

  9. 14b9b9f5bb644aa944ed5cb798fbc08c?d=mm

    Walkure

    Jul 31, 2018 13:33

    We have the same problem with a Unity WebGL build with Unity 2018.2.0f2

  10. Dffe2ed443f39191d7b537e9d1e7b36d?d=mm

    FernandoChen

    Jun 12, 2018 05:17

    Same problem here after we upgrade from 5.6.4p1 to 5.6.6f2.
    Seems to happen only on Chrome 67, can't reproduce on Chrome 66.

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.