Uncaught RangeError : Maximum Call Stack Size Exceeded after game loaded (hosted in azure)

So, i decided to update my game and upload it to azure server
it usually works smoothly but now this error appears which i’ve never been encountered before…

i would like to give another clue for this problem if i could, but since i’ve never encountered this problem before and google doesn’t help much i don’t know what to do now

I have encountered the same problem. Fortunately, I can solve it by clear Google Chrome caches.
Then I can’t reproduce this issue again.

Have you seen this topic on forum?
http://forum.unity3d.com/threads/rangeerror-maximum-call-stack-size-exceeded-after-unity-has-loaded-in-webgl.332956/

Possibly it’s a bug in Unity’s WebGL implementation.

Did you ever get to solve this problem? I am encountering the same where my build works locally on both chrome and firefox and when I upload it to the server it only works on firefox but chrome gives me that error.

This error is almost always means you have a problem with recursion in JavaScript code, as there isn’t any other way in JavaScript to consume lots of stack. Sometimes calling a recursive function over and over again, causes the browser to send you Maximum call stack size exceeded error message as the memory that can be allocated for your use is not unlimited. It’s possible to cause infinite recursion in a fully promisified code, too. That can happen if the promises in a chain don’t actually perform any asynchronous execution , in which case control never really returns to the event loop, even though the code otherwise appears to be asynchronous. That’s when it’s useful to wrap your recursive function call into a -

  • setTimeout
  • setImmediate or
  • process.nextTick

Also, you can localize the issue by setting a breakpoint on RangeError type of exception , and then adjust the code appropriately. Moreover, you can managed to find the point that was causing the error by check the error details in the Chrome dev toolbar console , this will give you the functions in the call stack, and guide you towards the recursion that’s causing the error.

For anyone that’s seeing a similar issue recently in Unity 2021.3.x or, 2021.2.x, I spent a few days battling this exact problem and found it was specific to Safari and IIS.

My workaround was to switch to Brotli compression in Player Settings->Publishing Settings instead of gzip. Details in this forum thread:
https://forum.unity.com/threads/unhandled-promise-rejection-rangeerror-maximum-call-stack-size-exceeded-on-macos-safari.1257510/

Hopefully that spares somebody out there the pain I went through. :slight_smile: