Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

unity 5 beta 14 webgl error

Discussion in 'Unity 5 Pre-order Beta' started by badescuga9, Nov 30, 2014.

  1. badescuga9

    badescuga9

    Joined:
    Dec 11, 2012
    Posts:
    37
    hello! i'm trying to build our project to webgl. although it works ok with unity 4.6-webplayer, when i try to compile with unity-5.0-beta14-webgl it doesn't work.

    with the non-optimised option it compiles but it crashes the chrome/firefox browser and with the optimised option i get this error:

    before this issue i also recieve these warnings:


    Does anyone know something about this issue?
     
    Last edited: Nov 30, 2014
  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    972
    I am getting exactly the same.
    Even on new project with one empty scene with just a camera on the build scene.
     
  3. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    I am getting similar error on b17.
    But it doesn't build at all. It just crashes with this error message.
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Try beta 16. 14 and 15 did that for me. I haven't tried 17 yet but 16 worked.
     
  5. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    It looks like the relevant part of the error messages is:

    "FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory"

    It seems to run out of memory during linking. How much memory do you have? And, how much available free disk space for swap?

    (That said, yes, definitely try b17!)
     
  6. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    Hey, Jonas!

    I have 16 GB of memory. On disk there is 250+ GB free space. I am running on OS X, Unity5b17.
     
  7. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    Is it possible to increase memory allocated to emc?
     
  8. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    bump

    I'm getting the same error and I also have 16 GB memory with 200+ GB free disk space, running OSX Mavericks on a 1st generation Macbook Pro Retina and Unity 5 beta 17.

    I watched the Unity process tree as it was building, and it never seems to go above 5 GB of memory used. I would assume it could grab more memory if it needed it.

    OSX makes it difficult to really figure out how much true "free" memory you have left though. I'm happy to run another build running some kind of memory debug commands as the build process is running, if you can provide the command you like to get the amount of free memory.

    I poked around on the emscripten site for ideas on how to decrease the memory usage, or increase the amount of memory available to emcc, and I did find 1 thing that might help: EMCC_CORES (http://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html). Apparently, if you have a lot of cores and not so much memory, you can set that to a lower number than your real cores and it should consume less memory. Is there a way to add that to the emcc command it runs?
     
  9. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    @d12frosted , @tayl0r : It seems odd that you would be running out of memory on a 16GB mac. I have the same setup and I never saw that happening. Are you sure that you are seeing the same error as the thread starter? The first lines of the error are not relevant, the relevant part is "FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory". If you are seeing that on a 16 MB mac, then either your project is somehow stretching the limits of emscripten very far, or points to a bug in emscripten. In either case, a bug report with a repro project would probably be helpful.
     
  10. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    Yeah, it's the same error:

    FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory Traceback (most recent call last): File "/Applications/Unity5/Unity.app/Contents/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emcc", line 1452, in <module> flush_js_optimizer_queue() File​

    I submitted a bug report (# 657693) with our huge project attached. I'm pretty confident you'll be able to reproduce it with our project. Thanks!
     
  11. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    So, I looked at a bug report on this now, and discussed the behavior with Alon from mozilla (developer of emscripten). It turns out that the code had a single, very long function (several thousand lines of code), which caused the JavaScript optimizer to run out of memory when building with the "Fastest" build option (-O3 in emscripten). "Fast" (-O2 in emscripten) would work fine. Alon is working on a new version of the emscripten optimizer (which is written in C++ and not in JavaScript), which uses less memory and should fix this issue. But that is not stable yet, so until then, you can either use "Fast" to get around this, or check your project for excessively long functions and try splitting those up.
     
  12. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    Thanks @jonas echterhoff , I will check our project for excessively long functions.