Search Unity

"RangeError: Maximum call stack size exceeded" after Unity has loaded in WebGL.

Discussion in 'Web' started by ViLLE-Team, Jun 12, 2015.

  1. ViLLE-Team

    ViLLE-Team

    Joined:
    Jun 12, 2015
    Posts:
    4
    Hi,

    I'm currently trying to solve above problem in our educational game project and I have come to a dead end with searching solutions all around internet.

    Our team is trying to integrate Unity game in to our own system built and coded with Vaadin, Java and Javascript. The thing is that our game needs to take parameters as "setups" from our system and use them in the game and when game is done, send something back with callback function. This all works perfectly in the game and via the index file created during conversion to WebGL platform game, I can send parameters to the game and it works with those "setups".However I have managed to encounter the above error when trying to integrate the game int to our system.

    First I tried to do it with <iframe> by putting the tags in to our systems running init.js file which executes function creating the iframe in the html. In the iframe, i just open the Unity generated index file and it shows the game inside the iframe without problems. (in this point, I have not change anything in the files given from Unity) So this solution works well. (code and picture link below)
    Code (JavaScript):
    1. $(this.getElement()).append('<iframe src="VAADIN/themes/vexer-catch_the_numbers/index.html" height="768" width="1024" frameborder="0"></iframe>');
    http://puu.sh/ilYzy/ac680429e2.jpg

    Now the first part of the problem I encountered was that sending parameters through iframe is the worst scenario you could ever imagine. That is 'cos the only way to do it is via the url, so we tried to find a way around this "last solution". We found out that it's possible (and even advisable) to do so by just getting all the code from the index file to the init.js file where I first had the iframe. As we did so, the code looked like this.
    Code (JavaScript):
    1.  
    2. var $thisElement = $(this.getElement());
    3. (function(){
    4.         $thisElement.append('<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="768px" width="1024px"></canvas>');
    5.         function OnUnityReady(){
    6.             var difficultyMode = "false";
    7.             var allowNumCollect = "true";
    8.             var sTime = 60;
    9.             var scoreTime = 3;
    10.             var scoreAmount = 5;
    11.             var dropRange = 6.0;
    12.  
    13.             var timeLeft = "TIME LEFT:";
    14.             var score = "SCORE:";
    15.             var gameOver = "GAME OVER";
    16.             var collection = "COLLECTED NUMBERS:";
    17.             var answersToCollect = "ANSWERS TO COLLECT:";
    18.             var translations = timeLeft + "/" + score + "/" + gameOver + "/" + collection + "/" + answersToCollect;
    19.  
    20.             var startGravity = 0.2;
    21.             var firstNumber = 1;
    22.             var secondNumber = 10;
    23.             var expOperator = "+";
    24.             var numToCollect = 2;
    25.             var difficultyTime = 60.0;
    26.             var stoppedForTime = 5.0;
    27.  
    28.             SendMessage("Setup", "SetDifficulty", difficultyMode);
    29.             SendMessage("Setup", "SetAllowNumCollect", allowNumCollect);
    30.             SendMessage("Setup", "SetStartTime", sTime);
    31.             SendMessage("Setup", "SetScoreTime", scoreTime);
    32.             SendMessage("Setup", "SetScoreAmount", scoreAmount);
    33.             SendMessage("Setup", "SetDropRange", dropRange);
    34.             SendMessage("Setup", "SetLanguage", translations);
    35.             SendMessage("Setup", "SetStartGravity", startGravity);
    36.             SendMessage("Setup", "SetFirstNumber", firstNumber);
    37.             SendMessage("Setup", "SetSecondNumber", secondNumber);
    38.             SendMessage("Setup", "SetExpOperator", expOperator);
    39.             SendMessage("Setup", "SetNumToCollect", numToCollect);
    40.             SendMessage("Setup", "SetDifficultyTime", difficultyTime);
    41.             SendMessage("Setup", "SetStoppedForTime", stoppedForTime);
    42.         }
    43.         function EndGame(){
    44.             gameClosed = true;
    45.             console.log("Is game closing: " + gameClosed);
    46.             //window.document.close();
    47.         }
    48.  
    49.         function Callback(score){
    50.             console.log("Game won with score: ", score);
    51.         }
    52.         // connect to canvas
    53.         var Module = {
    54.                 TOTAL_MEMORY: 268435456,
    55.                 filePackagePrefixURL: "/xxx/xxx/xxx/Release/",
    56.                 memoryInitializerPrefixURL: "/xxx/xxx/xxx/Release/",
    57.                 preRun: [],
    58.                 postRun: [],
    59.                 print: (function() {
    60.                     return function(text) {
    61.                         console.log (text);
    62.                     };
    63.                 })(),
    64.                 printErr: function(text) {
    65.                     console.error (text);
    66.                 },
    67.                 canvas: document.getElementById('canvas'),
    68.                 progress: null,
    69.                 setStatus: function(text) {
    70.                     if (this.progress == null)
    71.                     {
    72.                         if (typeof UnityProgress != 'function'){
    73.                             return;
    74.                         }
    75.                         this.progress = new UnityProgress (canvas);
    76.                         console.log("11");
    77.                     }
    78.                     if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
    79.                     if (text === Module.setStatus.text) return;
    80.                     this.progress.SetMessage (text);
    81.                     var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
    82.                     if (m){
    83.                         this.progress.SetProgress (parseInt(m[2])/parseInt(m[4]));
    84.                     }
    85.                     if (text === ""){
    86.                         this.progress.Clear()
    87.                     }
    88.                 },
    89.                 totalDependencies: 0,
    90.                 monitorRunDependencies: function(left) {
    91.                     this.totalDependencies = Math.max(this.totalDependencies, left);
    92.                     Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
    93.                 }
    94.         };
    95.         Module.setStatus('Downloading (0.0/1)');
    96.         var script = document.createElement('script');
    97.         script.type = 'text/javascript';
    98.         script.src = 'xxx/xxx/xxx/UnityConfig.js';
    99.         $thisElement.append(script);
    100.         console.log("20" + script);
    101.         script = document.createElement('script');
    102.         script.type = 'text/javascript';
    103.         script.src = 'xxx/xxx/xxx/fileloader.js';
    104.         $thisElement.append(script);
    105.         if (!(!Math.fround)) {
    106.             var script = document.createElement('script');
    107.             script.src = "/xxx/xxx/xxx/CatchTheNumber.js";
    108.             document.body.appendChild(script);
    109.         } else {
    110.             var codeXHR = new XMLHttpRequest();
    111.             codeXHR.open('GET', '/xxx/xxx/xxx/CatchTheNumber.js', true);
    112.             codeXHR.onload = function() {
    113.                 var code = codeXHR.responseText;
    114.                 if (!Math.fround) {
    115.                     try {
    116.                         console.log('optimizing out Math.fround calls');
    117.                         var m = /var ([^=]+)=global\.Math\.fround;/.exec(code);
    118.                         var minified = m[1];
    119.                         if (!minified) throw 'fail';
    120.                         var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS');
    121.                         var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS');
    122.                         var asm = code.substring(startAsm, endAsm);
    123.                         do {
    124.                             var moar = false; // we need to re-do, as x(x( will not be fixed
    125.                             asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' });
    126.                         } while (moar);
    127.                         code = code.substring(0, startAsm) + asm + code.substring(endAsm);
    128.                         code = code.replace("'use asm'", "'almost asm'");
    129.                     } catch(e) { console.log('failed to optimize out Math.fround calls ' + e) }
    130.                 }
    131.                 var blob = new Blob([code], { type: 'text/javascript' });
    132.                 codeXHR = null;
    133.                 var src = URL.createObjectURL(blob);
    134.                 var script = document.createElement('script');
    135.                 script.src = URL.createObjectURL(blob);
    136.                 script.onload = function() {
    137.                     URL.revokeObjectURL(script.src);
    138.                 };
    139.                 document.body.appendChild(script);
    140.             };
    141.             codeXHR.send(null);
    142.         }
    143.     })();
    After doing this the real problem (the part 2) started. So if I'm correct, when this init.js file is executed by our system, it creates the canvas (that index already had) and then executes the other scripts as the index did too and in the same order. I tried to debug the code through with console.log() and it went through the whole code normally. The problem itself occurred after the so called "initialization of the game". So my final question is where did I go wrong, when the game (tested both, chrome and Firefox) throws me ""RangeError: Maximum call stack size exceeded" (though Firefox gives only ”Too much recursion” error) PLEASE help me with this, I peg you (on my knees, of course). I also attached some files to be clearer with all this.
     

    Attached Files:

    Last edited: Jun 12, 2015
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    This can currently happen in WebGL when it tries to find a function which is getting stripped (and then some code endlessly recurses trying to find that function). We are fixing this to do better error reporting, until then, try putting in some Debug prints in the code around where the issue happens, to find out what code it is calling, so you might see which function is getting stripped.
     
  3. ViLLE-Team

    ViLLE-Team

    Joined:
    Jun 12, 2015
    Posts:
    4
    Okey, I tried to debug through the code from the init.js file and put some console.debugs through out the initialization function. It goes through it without problems but the RangeError comes after the game has gone through the initialization. That's why I was so confused that where the error could come from. But should I still try to put some debugs in the game itself? I also took some pictures from the PlayerSettings of the game. The point is to get as small game package as possible so if you know some tricks to that too, let me know.
     
    Last edited: Jun 15, 2015
  4. notprathap

    notprathap

    Joined:
    Jan 18, 2013
    Posts:
    9
    I ran into the same issue as well. Jonas, what do you mean by "stripped"?
     
  5. ViLLE-Team

    ViLLE-Team

    Joined:
    Jun 12, 2015
    Posts:
    4
    One step closer to the error once again. I tried the console trick and took it further on. I put console.logs all over the UnityConfig.js and fileloader.js files and was able to locate one kind of source where it comes from. Here is the fileloader.js
    Code (JavaScript):
    1. function runWithFS() {
    2.                 console.log("Fileloader 24");
    3.                 function assert(check, msg) {
    4.                     console.log("Fileloader 25");
    5.                     if (!check) throw msg + new Error().stack;
    6.                 }
    7.                 Module['FS_createPath']('/', 'Resources', true, true);
    8.                 console.log("Fileloader 26");
    9.                 function DataRequest(start, end, crunched, audio) {
    10.                     this.start = start;
    11.                     this.end = end;
    12.                     this.crunched = crunched;
    13.                     this.audio = audio;
    14.                     console.log("Fileloader 27");
    15.                 }
    16.                 DataRequest.prototype = {
    17.                         requests: {},
    18.                         open: function(mode, name) {
    19.                             console.log("Fileloader 28");
    20.                             this.name = name;
    21.                             this.requests[name] = this;
    22.                             Module['addRunDependency']('fp ' + this.name);
    23.                         },
    24.                         send: function() {},
    25.                         onload: function() {
    26.                             console.log("Fileloader 29");
    27.                             var byteArray = this.byteArray.subarray(this.start, this.end);
    28.  
    29.                             this.finish(byteArray);
    30.  
    31.                         },
    32.                         finish: function(byteArray) {
    33.                             console.log("Fileloader 30");
    34.                             var that = this;
    35.                             Module['FS_createPreloadedFile'](this.name, null, byteArray, true, true, function() {
    36.                                 Module['removeRunDependency']('fp ' + that.name);
    37.                             }, function() {
    38.                                 if (that.audio) {
    39.                                     console.log("Fileloader 31");
    40.                                     Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang)
    41.                                 } else {
    42.                                     console.log("Fileloader 32");
    43.                                     Module.printErr('Preloading file ' + that.name + ' failed');
    44.                                 }
    45.                             }, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
    46.                             this.requests[this.name] = null;
    47.                         },
    48.                 };
    49.                 console.log("Fileloader 33");
    50.                 new DataRequest(0, 31356, 0, 0).open('GET', '/mainData');
    51.                 new DataRequest(31356, 31588, 0, 0).open('GET', '/methods_pointedto_by_uievents.xml');
    52.                 new DataRequest(31588, 4403916, 0, 0).open('GET', '/sharedassets0.assets');
    53.                 new DataRequest(4403916, 4410113, 0, 0).open('GET', '/sharedassets0.resource');
    54.                 new DataRequest(4410113, 5985149, 0, 0).open('GET', '/Resources/unity_default_resources');
    55.                 new DataRequest(5985149, 6485625, 0, 0).open('GET', '/Resources/unity_builtin_extra');
    56.                 console.log("Fileloader 34");
    57.                 function processPackageData(arrayBuffer) {
    58.                     console.log("Fileloader 35");
    59.                     Module.finishedDataFileDownloads++;
    60.                     assert(arrayBuffer, 'Loading data file failed.');
    61.                     var byteArray = new Uint8Array(arrayBuffer);
    62.                     var curr;
    63.                     console.log("Fileloader 36");
    64.                     // Reuse the bytearray from the XHR as the source for file reads.
    65.                     DataRequest.prototype.byteArray = byteArray;
    66.                     DataRequest.prototype.requests["/mainData"].onload();
    67.                     DataRequest.prototype.requests["/methods_pointedto_by_uievents.xml"].onload();
    68.                     DataRequest.prototype.requests["/sharedassets0.assets"].onload();
    69.                     DataRequest.prototype.requests["/sharedassets0.resource"].onload();
    70.                     DataRequest.prototype.requests["/Resources/unity_default_resources"].onload();
    71.                     DataRequest.prototype.requests["/Resources/unity_builtin_extra"].onload();
    72.                     Module['removeRunDependency']('datafile_CatchTheNumber.data');
    73.                     console.log("Fileloader 37");
    74.                 };
    75.                 Module['addRunDependency']('datafile_CatchTheNumber.data');
    76.                 console.log("Fileloader 38");
    77.                 if (!Module.preloadResults) Module.preloadResults = {};
    78.                 console.log("Fileloader 39");
    79.                 Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
    80.                 if (fetched) {
    81.                     console.log("Fileloader 40");
    82.                     processPackageData(fetched);
    83.                     fetched = null;
    84.                 } else {
    85.                     console.log("Fileloader 41");
    86.                     fetchedCallback = processPackageData;
    87.                 }
    88.                 console.log("Fileloader 42");
    89.             }
    90.             if (Module['calledRun']) {
    91.                 console.log("Fileloader 43");
    92.                 runWithFS();
    93.             } else {
    94.                 console.log("Fileloader 44");
    95.                 if (!Module['preRun']) Module['preRun'] = [];
    96.                 Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
    97.             }
    Now I get the error somewhere around here:
    (This is from my browsers console prints)
    Fileloader 24
    Fileloader 26
    Fileloader 33
    Fileloader 27
    Fileloader 28
    Fileloader 27
    Fileloader 28
    Fileloader 27
    Fileloader 28
    Fileloader 27
    Fileloader 28
    Fileloader 27
    Fileloader 28
    Fileloader 27
    Fileloader 28
    Fileloader 34
    Fileloader 38
    Fileloader 39
    Fileloader 40
    Fileloader 35
    Fileloader 25
    Fileloader 36
    Fileloader 29
    Fileloader 30
    Fileloader 29
    Fileloader 30
    Fileloader 29
    Fileloader 30
    Fileloader 29
    Fileloader 30
    Fileloader 29
    Fileloader 30
    Fileloader 29
    Fileloader 30
    Fileloader 37
    Fileloader 42
    Invoking error handler due to
    Uncaught RangeError: Maximum call stack size exceeded

    Attached the console logs to different files, so it's clearer to see the differents
     

    Attached Files:

    Last edited: Jun 16, 2015
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    We strip code which is not used during the build. However, sometimes, we cannot determine that a method or type is being used - typically when something is trying to call them by reflection by name, and may end up incorrectly stripping that code. You can use a link.xml file as described here to work around that: http://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html
     
  7. ViLLE-Team

    ViLLE-Team

    Joined:
    Jun 12, 2015
    Posts:
    4
    So how about the reading order of the files. According to those files I posted earlier, the iframe has different reading order than when I'm trying to execute all from one js file. Any suggestions to that?
     
  8. notprathap

    notprathap

    Joined:
    Jan 18, 2013
    Posts:
    9
    Oh right, thanks for the explanation. Just so everyone knows, in my case, the rangeerror was actually caused by a method that was throwing a null reference exception - once I fixed that, this error stopped appearing.
     
  9. maudlinmonkey

    maudlinmonkey

    Joined:
    Jun 14, 2014
    Posts:
    3
    Also happens when trying to use Unity Analytics on WebGL...

    And by use, I mean just having 'using UnityEngine.Analytics'
     
    Last edited: Jul 22, 2015
  10. dreg_master

    dreg_master

    Joined:
    Jan 4, 2016
    Posts:
    44
    Hi There,

    I know this is old thread, this is happening to me now, has happened in past but resolved itself, so I'm not sure to wait it out or try troubleshoot. I need some help. I've scoured the web for a few days now on google and stack overflow etc. My game stopped working on WebGL after the Unity update 2018.1.0f2 Personal. Now WebGL fails, but runs in editor and PC builds fine. I have played around allot with the player settings to no avail. bosssoftaware.net/GLTrump.html. There are no errors in my code(from what i can tell), worked before the update.

    Google Chrome gives error - Uncaught RangeError: Maximum call stack size exceeded.
    Firefox gives error - too much recursion

    My next step it to try debug chrome and firefox, but I am unsure and not sure if it is worth it, so if anyone know anything please inform me.
     
  11. dreg_master

    dreg_master

    Joined:
    Jan 4, 2016
    Posts:
    44
    SOLVED. For me it was to set in the WebGL Player settings API Compatibility level to .Net Standard 2.0
     
    tytbone likes this.
  12. IAmPatSilva

    IAmPatSilva

    Joined:
    Dec 30, 2015
    Posts:
    7
    Instead of Creating a new Thread, I felt that this one was very relevant to what I was going through in Unity 2018.1.0f.

    My Problem: I received the Range Error with a project that was a part of a series of simulations, they all are their own builds and runs similarly simulating different devices. So far everyone of them was working except for one particular project. I kept running into this error on Google Chrome. now I did not test it on any other browsers.

    I tried to change the API Compatibility Level to .NET 2.0, not the subset. However I still ran into this error

    Solution: After more research I found this thread https://answers.unity.com/questions/1181369/uncaught-rangeerror-maximum-call-stack-size-exceed.html

    The first response declared that Clearing Chrome's Data fixed the problem. This worked for me, however I do not want my users to have to clear chrome's data if they run into this error.

    My Question: Is there a way where I can avoid this error all together?
     
    TheVirtualMunk likes this.
  13. jvalenciag

    jvalenciag

    Joined:
    Dec 2, 2018
    Posts:
    2
    For me neither cleaning Chrome's data nor changing the API compatibility level, didn't worked for me, anyone knows if there is a bug report created?
     
  14. Raybosama

    Raybosama

    Joined:
    Nov 7, 2018
    Posts:
    1
    I had similar problems with the Chrome browser, even with API Compatibility Level set to .NET 2.0. To fix it I went to the Resolution and Presentation settings of Player Settings and selected Minimal WebGL Template. Then rebuilt and redeployed.

    Minimal.png
     
    Last edited: Mar 15, 2019
  15. tytbone

    tytbone

    Joined:
    Jul 16, 2013
    Posts:
    18
    Sorry for the bump but I think (fingers crossed) this solved the same "rangeerror maximum call stack" error I had (changing Scripting Runtime Version to 4.0 first, then Net Standard 2 became available as an Api Compatibility Level option), so I really appreciate you posting this as I don't know if I would have figured that out myself. (I combined it with Raybosama's suggestion of "Minimal WebGL Template" too just to be safe since I'm not close to being a pro at developing and debugging. :p) I'm still on 2018.2.11f1 so maybe that caused some issue(s).
     
  16. The_Devil

    The_Devil

    Joined:
    Jun 6, 2015
    Posts:
    36
    I have a simple scene with two 3D models (https://assetstore.unity.com/packages/3d/environments/fantasy/baker-s-house-26443) and two dynamic lights. This scene loads fine on both desktop , android and iphones (total file size was under 5 MB). I added a single Text Mesh Pro label to the scene was updating it through code (sort of like a debug log but visible on screen) and this worked correctly on android and desktop. But when I try to run on safari or chrome on an iPhone 7 running ios version 13.1.1 it does not load. It shows the warning message (which it showed earlier too) and on pressing ok it proceeds to load the scene. It stops at about 90% with the following stack trace :


    Code (CSharp):
    1. Warning: Unsupported graphics API WebGL 2.0
    2. [UnityCache] 'http://192.168.0.179/webgl/Build/Web.wasm.code.unityweb' successfully revalidated and served from the indexedDB cache
    3. [UnityCache] 'http://192.168.0.179/webgl/Build/Web.wasm.framework.unityweb' successfully revalidated and served from the indexedDB cache
    4. [UnityCache] 'http://192.168.0.179/webgl/Build/Web.data.unityweb' successfully revalidated and served from the indexedDB cache
    5. failed to asynchronously prepare wasm: Error: Out of executable memory in function at index 29257
    6. Error: Out of executable memory in function at index 29257
    7. Error: Out of executable memory in function at index 29257
    8. still waiting on run dependencies:
    9. dependency: wasm-instantiate
    10. (end of list)
    11. still waiting on run dependencies:
    12. dependency: wasm-instantiate
    13. (end of list)
    14. still waiting on run dependencies:
    15. dependency: wasm-instantiate
    16. (end of list)
    17. still waiting on run dependencies:
    18. dependency: wasm-instantiate
    19. (end of list)
    20. still waiting on run dependencies:
    21. dependency: wasm-instantiate
    22. (end of list)
    23. still waiting on run dependencies:
    24. dependency: wasm-instantiate
    25. (end of list)
    26. still waiting on run dependencies:
    27. dependency: wasm-instantiate
    28. (end of list)
    29. still waiting on run dependencies:
    30. dependency: wasm-instantiate
    31. (end of list)
    32. still waiting on run dependencies:
    33. dependency: wasm-instantiate
    34. (end of list)
    35. still waiting on run dependencies:
    36. dependency: wasm-instantiate
    37. (end of list)
    38. still waiting on run dependencies:
    39. dependency: wasm-instantiate
    40. (end of list)
    41.  
    It then shows a popup with the message "RangeError: Maximum call stack size exceeded".

    I have tried restarting the phone, clearing the cache, the scripting run-time version is set to .Net 4,x Equivalent, set the display to minimal as mentioned above, increased memory to 512 from 256 under Publishing settings. I have no idea what else to try. I have new to web development and hence have to idea on how to proceed ahead. Any help would be appreciated.
     
  17. iLyxa3D

    iLyxa3D

    Joined:
    Sep 25, 2013
    Posts:
    31
    Try to clear browser cache (Ctrl+F5). Sometimes it helps with this bugs.
     
  18. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    This is a painful issue we are very well aware of with older versions of Safari. These are reported as

    https://bugs.webkit.org/show_bug.cgi?id=181723
    https://bugs.webkit.org/show_bug.cgi?id=200686
    https://bugs.webkit.org/show_bug.cgi?id=200807
    https://bugs.webkit.org/show_bug.cgi?id=206284

    The problem should be fixes in newer versions of Safari. If the issue still reproduces in latest Safari browsers, please let us know.
     
  19. jimmack

    jimmack

    Joined:
    May 2, 2016
    Posts:
    20
    Thank you. This was all it took for me. Now. If only the Unity team can get gzip compression working properly with the Linux version of 2020.2 :)
     
  20. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    I was not aware of an issue on this front (granted, I don't have a Linux development system available atm - another engineer is looking at Linux WebGL support for Unity 2021.2 release). Is there a specific error you get? I could route that by him if so.
     
  21. maximiliananzinger

    maximiliananzinger

    Joined:
    Mar 4, 2020
    Posts:
    26
    Same error here: "RangeError: Maximum call stack size exceeded"

    I tried a new Unity scene without any modificiation.
    Unity Version is 2020.03.0f1 and I set the compatibility to .Net Standard 2.0, as well as chose the minimal template.
    This did not solve the issue for me.
    Clearing Browser Cache also didn't help.

    Chrome error is the one already mentioned above: "RangeError: Maximum call stack size exceeded"
    Firefox error is: " RangeError: too many arguments provided for a function call" -> loader.js with statement:
    "apply(null, e.subarry(r,r+1));r+=i ..."
     
    _TheFuture_ likes this.
  22. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    595
    Same problem with Unity 2021.1.7f1 (64-bit)

    gzip ==> fail to load with "RangeError: Maximum call stack size exceeded"
    Brotli ==> working
     
    _TheFuture_ likes this.
  23. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    These are errors that we have not seen reported before. When you get this issue, was the project built with the "Compression Fallback" option enabled or disabled?

    My suspect is that the error message would be coming from the software-based compression fallback code, that would be good to confirm.

    Do you have a failing build somewhere you could zip up?
     
  24. ralf_b

    ralf_b

    Joined:
    Jul 9, 2013
    Posts:
    48
    Sorry to necro this thread ongoing since 2015 but I also do have jsStackTrace and wasm-function errors starting today.

    I have tried Unity 2021.1.15f1:
    + Api Compatibility Level ".Net Standard 2.0"
    + Managed Stripping level "Low"
    + Compression Fallback "enabled" / "disabled"
    + Strip Engine Code "enabled" / "disabled"
    + Optimize Mesh Data "enabled" / "disabled"

    WTF?! Moment of the day Unity 2021.1.15f1:
    I have reverted all the above mentioned settings to the ones from yesterday and now everything works again (in Edge, Chrome and Firefox on PC)

    + Api Compatibility Level ".Net Standard 2.0"
    + Managed Stripping level "Low"
    + Compression Fallback "enabled"
    + Strip Engine Code "enabled"
    + Optimize Mesh Data "enabled"

    Unfortunately this might not be as much help for others running into these problems but maybe the Unity team might get a better overall picture of this long standing issue. To me it seems like that when building a WebGL the outcome might vary regardless if changes have been made or not, which makes reliable development a hit or miss thing.

    Speaking of which maybe I am missing something fundamental though I just hope this can be resolved one day without us / me getting mails from clients (also on PC using either Edge or Chrome and a small team of Mac users also using Chrome) reporting this issue.
     
    saltytunaicecream likes this.
  25. G33RT

    G33RT

    Joined:
    Dec 27, 2013
    Posts:
    52
    I seem to be having the seem issue after an upgrade from 2021.2.0b15 to 2021.2.0b16
     
    manuelgoellnitz likes this.
  26. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    I can confirm this!
    Error occurs on b16 and build works without errors on b15.
    Maybe it has something todo with URP?
    Unity complained when I downgraded and there was an update from b15 to b16
     
  27. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Had the error, try "Clean Build" to remove IL2CPP code cache. It fixed it for me.
     
  28. markovicho

    markovicho

    Joined:
    Nov 2, 2016
    Posts:
    5
    same here. thanks for sharing the solution !
     
  29. _TheFuture_

    _TheFuture_

    Joined:
    Mar 11, 2016
    Posts:
    4
    We were experiencing the same issue @roka mentioned at first, where the non-compressed build worked but using Gzip expression resulted in this error. However, this seems to be misleading, after cleaning the GI Cache (Edit -> Preferences... -> GI Cache), as @KamilDA suggested, the Gzip compressed built worked just as fine for us. So it looks like a caching related issue indeed.

    Also worth to mentioned we crashed at the same place
    Code (JavaScript):
    1. ...apply(null, e.subarry...
    mentioned by @maximiliananzinger and only in Chrome (Edge and Firefox worked) on some machines. Pretty weird.
     
  30. Mehrdad995

    Mehrdad995

    Joined:
    Jul 17, 2013
    Posts:
    46
    In my case there were two problems, I had added a .jslib plugin to my assets letting me know if a device the WebGL build is running on is a mobile or a desktop. The addition of the plugin somehow corrupted the build then I noticed that if I don't use the "Build And Run" option unity wouldn't update the "___.wasm.unityweb" file alongside "___.loader.js" but by choosing the "Build And Run" it would recreate the "___.wasm.unityweb" file again, however, very mysteriously my problem wasn't solved which was due to chrome's caching the old script. As on mobile, we don't have the Ctrl+F5 option so the workaround is to close the tab and reopen it using the URL, not history.
     
  31. KnewK

    KnewK

    Joined:
    Sep 2, 2012
    Posts:
    19
    Hi, I had an older loading script stuck in UnityCache IndexedDB causing this error in Chome browser. Fixed with this procedure.
    Chromium browser web cache clearing UnityCache via developer tool
    • Press F12 on your keyboard while the game is in the foreground tab.
    • Then click on the Application tab at the top of the screen
    • Click in this tab on the left side on "Indexed DB" and expand it
    • Then click on the entry "UnityCache - www.yourwebsite.com".
    • On the right side then click on "Delete Database"
     
    Dance_M likes this.
  32. Destrucity

    Destrucity

    Joined:
    Sep 28, 2014
    Posts:
    17
    Just want to report that this solution worked for me. Thanks!
     
    tkoknordic likes this.
  33. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    64
  34. epratt

    epratt

    Joined:
    Oct 15, 2019
    Posts:
    17
    In my situation, we were using CI/CD to automatically build and deploy our app on Kubernetes deployed on AWS. Everything done via script. What drove me crazy is if I manually built from my machine and deployed it in a docker container or deployed it on our own network via CI/CD it would work just fine.

    What's more is it would work if I opened it in incognito mode or after clearing browser cache as many have suggested (Which I don't find is an acceptable solution for users)

    What finally fixed it for me is updating player settings in the build script. The container that it gets deployed on is configured to use Gzip to serve the files, so the following player settings were configured:

    Code (CSharp):
    1. PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Gzip;
    2. PlayerSettings.WebGL.decompressionFallback = false;
    3. PlayerSettings.WebGL.dataCaching = false;
    I disabled decompression fallback after @jukka_j mentioned that could be the cause. I also disabled data caching just in case and it appears to have resolved my issues.

    Using Unity 2020.3.28f
     
    Last edited: Nov 3, 2022
  35. AkshayGhosh

    AkshayGhosh

    Joined:
    Jan 8, 2017
    Posts:
    4
    hi @IAmPatSilva did you get a solution?
     
  36. theVirtunaut

    theVirtunaut

    Joined:
    Sep 28, 2013
    Posts:
    10
    It's 2023 and this bug still comes up. Any new info?
     
  37. King9999

    King9999

    Joined:
    Sep 21, 2017
    Posts:
    3
    I ran into this error the other day. The problem for me was that the engine code that was required for Toggles (checkboxes) to work properly was stripped. Instead of changing the stripping level, my solution was to use a Button instead of Toggle.

    If anyone else is using Toggles in their games, you might want to consider using Buttons instead. Otherwise, you might not want to strip any engine code, or keep it to the default level. But this will increase the size of your build, which probably isn't ideal for WebGL games.
     
    Last edited: Mar 31, 2023
  38. halfdan87

    halfdan87

    Joined:
    Jul 8, 2019
    Posts:
    2
    I had the same with github and GameCI. I deployed to Hetzner and served with nginx.
    It turns out my configuration didn't handle gzip in nginx config.
    I added these in my config for my domain in server block:


    Code (CSharp):
    1.     location ~ \.wasm\.gz$ {
    2.         add_header Content-Encoding gzip;
    3.         default_type application/wasm;
    4.         gzip off;
    5.     }
    6.     location ~ \.data\.gz$ {
    7.         add_header Content-Encoding gzip;
    8.         default_type application/octet-stream;
    9.         gzip off;
    10.     }
    11.     location ~ \.js\.gz$ {
    12.         add_header Content-Encoding gzip;
    13.         default_type text/javascript;
    14.         gzip off;
    15.     }
    It helped. Probably for apache or other server apps you have to figure out something else.
    But it will be probably nothing that ChatGPT wouldn't have an answer to ;)
     
  39. Artificialized

    Artificialized

    Joined:
    Oct 5, 2014
    Posts:
    69
    Im getting this error when building a WebGL Build in unity editor 2020.3.47f1 rangerror: maximum file call stack exceeded
     
  40. Oleksandr_Kryvonos

    Oleksandr_Kryvonos

    Joined:
    Dec 11, 2014
    Posts:
    1
    I overcame the issue with some of these settings in "Player Settings":
    1) "Publishing Settings" -> "Compression Format: Disabled"
    2) "Other Settings" -> "C++ Compiler Configuration: Debug"
    3) "Other Settings" -> "Stack Trace: Full (for every option)"
     
  41. Reeti_Maurya

    Reeti_Maurya

    Joined:
    Jul 19, 2021
    Posts:
    2
    If anyone is wondering, this code is available in Unity manual for webgl server configuration sample. And yes, there are also sample codes available for Apache and IIS. Here, https://docs.unity3d.com/2022.3/Documentation/Manual/webgl-server-configuration-code-samples.html
     
    unityruba likes this.
  42. ExNinja

    ExNinja

    Joined:
    Dec 4, 2013
    Posts:
    30
    Just ran into this issue in Unity 2020.3.47.

    Turning off Decompression Fallback in Publishing Settings fixed it for me.
     
  43. feefbro

    feefbro

    Joined:
    Oct 14, 2023
    Posts:
    1
    I had this issue, but fixed it by clearing all browser caches, and then refreshing the site.
     
    Dance_M likes this.
  44. Dance_M

    Dance_M

    Joined:
    Aug 17, 2014
    Posts:
    15
    Clearing browser cache helped. Unity 2022.3.13f1. All projects settings by default, br compression settings added to the server.
     
  45. RobAtApex

    RobAtApex

    Joined:
    Jun 19, 2017
    Posts:
    21
    Still an issue in Unity 2022.3.19. Fixed by doing a hard reload of the page, but that requires work from the user, and we don't want to force a hard reload every time. Happens to some users on some platformsm but not all.

    I suspect all the changes to compression settings etc really just work because they effectively force a hard reload.

    And if they're on Android, it's non-trivial for the user to do a hard reload, and is different for every browser. It's a real pain that this keeps happening.
     
    makaka-org likes this.