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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Some browsers does not load unity WebGL project files from server.

Discussion in 'WebGL' started by support, Oct 2, 2015.

  1. support

    support

    Joined:
    Oct 24, 2013
    Posts:
    19
    Recently, we launched our WebGL game on Kongregate. A lot of users reported that game is not loaded (about 60% of new players). We started to gather browser console logs during the game startup moment. Now we have a huge set of them to analyze.

    We use Unity ver 5.2.1f1 . The latest release on this moment.

    According to the logs, the most common problem: unity loader does not load anything from server after index.html and other js files are loaded. I am speaking about files from Release folder (or Compressed if gzip supported).

    We print the message received by SetMessage message of UnityProgress.js into console.

    In good cases: the console, at the very top, contains a lot of:
    Preparing... (0/2)
    Preparing... (0/1)
    Downloading data... (8541/12901281)

    In failed cases, the the first and only received message: (Downloading (0.0/1) that is printed from index.html.
    Then nothing. Sometimes, nothing during 2 to 5 minutes.

    There are some browsers that alway filed. Some browsers are good in 50%, but problem above still happens.

    From "always failed":
    Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
    Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

    50/50 fail rate:
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
    Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

    One success experiment: we replaced "dancing" with Math.fround,ASM,Blob,XHR from generated index.html with just <script src="Release/AmebaWar.js"> . This saved 10% users. (Still 50% are failed)

    The question is what to try next to make user happy.
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    It is hard to tell from the server side logs what is going on. But what I see is that you are mostly seeing failures (your "always failed" part) on Chrome 32-bit. Chrome has issues where it may run out of memory and crash when trying to parse the JavaScript code we generate (which is much more severe in 32-bit versions), which would explain that it would not download anything after the .js files. Google has made changes to Chrome which improve the situation a lot here. These changes are currently in Chrome Canary builds. (Also see this thread: http://forum.unity3d.com/threads/memory-issues-in-chrome-try-canary.358002/). If you see this problem please try (or have your users try) if using Chrome Canary fixes the issue (and let us know!).
     
  3. support

    support

    Joined:
    Oct 24, 2013
    Posts:
    19
    Jonas, when we are launching our game in production world-wide, it is not a point to find a particular experimental browser where the game is working. We just have to reduce the failed rate on the browsers and OS real users play on.

    That what we were working on during the whole week. So far, we have a good progress, but not ideal. The first attached picture shows the statistic for the 5,000 latest loads. It includes the 10 most popular browser users use on Kongregate.
    In the table: green - success, red - failed, yellow - unity is launched, but did not connected to Photon network for some reason.

    What we did:
    1. We figured out that if user downloads the game once, she has less chance to fail next time. Currently, unity launch process mix downloading and running javascript.
    We separated this process. First, we load all largest files (from Release or Compressed folder) into browser cache. Then, the standard unity loader is added to the dom including UnityConfig.js and fileloader.js
    2. Reduced the size of the textures. We used to have truecolor option for most graphic because the reduced quality more recognizable in 2d games. It seems like unity keeps truecolor graphic uncompressed in memory. So, it needs larger value for TOTAL_MEMORY settings.
    3. Selected the right amount for TOTAL_MEMORY. This is a well documented issue, of course, but pretty challengeable job on practice.

    As you can see in the tables, the most unstable browser is a latest Chrome on 32-bit computer with Windows 7. Unfortunately, it is from 5 top.

    We gather and send the browser console log to the server. So, we can see what is going on the client side. Of course, is some cases (like browser crash) we might miss the latest portion.

    According to the log, the most critical moment is between loading the main js (in our case, AmebaWar.js) into the memory and staring to execute it (the 'read' node appears in the Module object).
    In some cases, it is just a long delay (up to 30 secs with periodical locking the main browser's thread). Sometimes, the browser's log shows "Uncaught RangeError: Invalid array buffer length" or other Memory related error. Sometimes, no more logs from the browser (It might be browser crash or user stops to wait).
    If main js begins to execute, it is unlikely to face the problems.

    P.S. We checked the beta of Unity 5.3 today. Nice improvements for the loading process there. However, scanning and replacing the content of the main js might be very challengeable for the browsers on 32-bits computes.
    P.P.S. Just in case, the game URL is http://www.kongregate.com/games/2bsocial/ameba-war
     

    Attached Files:

    Last edited: Oct 8, 2015
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Today, it won't help you (and you are doing the right steps towards what you can do today).

    But it is super important that we have people running into these issues like you check upcoming fixes (like what is in Canary right now), to see if this helps or not. Because we can give this feedback to Google, and it might help them make decisions on whether they would need a better fix, and on whether to accelerate the fix in their build process so it might land in Chrome 46 instead of 47 for instance. So this will help you in the future.