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. The 2022.2 beta is now available for testing. To find out what's new, have a look at our 2022.2 feature highlights.
    Dismiss Notice
Dismiss Notice
Submit bug reports tagged with #Beta2022Win_Unity when you encounter unknown issues while testing the 2022.2 betas for a chance to win a year of Unity Pro. For more information, have a look at our Beta Sweepstakes Announcement.

How to properly host WebGL content

Discussion in 'Unity 5 Pre-order Beta' started by TDMIsh, Nov 26, 2014.

  1. TDMIsh


    May 29, 2013
    I have been messing with the WebGL export and can play on my local machine, but once I upload it to a webserver I get error messages about memory allocation.

    An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was:
    uncaught exception: could not load memory initializer Data/WebGL.html.mem

    I have tried lowering the Memory Size in the Publish Settings down to 128, and I get the same message. I have tried an empty scene with a cube that rotates and I get the same behavior. I have tried on B9 & B14 for both OSX and Win. But again even my more complex scene works fine when I Build & Run.
    I have tried two hosting providers, InMotionHosting (which I don't believe allows server side JS), and then my Microsoft Azure account.

    Is there a proper way and known place to upload these builds online?

  2. Ostwind


    Mar 22, 2011
    Your server must allow downloads of the required file types. Some restrict them to known files only and some server all types.

    You need at least .mem and .data to be known mime type
  3. sluice


    Jan 31, 2014
    You need to allow the MIME Type for the .mem and the .data.

    As @Ostwind, said in one of my thread, you can use:
    application/octet-stream as both are binary files
    GrayDwarf likes this.
  4. TDMIsh


    May 29, 2013
    Thanks a ton guys! This worked. Took me a while to figure out that I had to upload the web.config with the mime types you said. For others that are interested in this, I made a file called web.config and uploaded it to my webserver (at least for Azure, haven't tried my InMotionHosting acct yet) and placed it in the wwwroot folder.

    Code (csharp):
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <configuration>
    4.     <system.webServer>
    5.         <staticContent>
    6.             <remove fileExtension=".mem" />
    7.             <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
    8.             <remove fileExtension=".data" />
    9.             <mimeMap fileExtension=".data" mimeType="application/octet-stream" />        
    10.         </staticContent>
    11.     </system.webServer>
    12. </configuration>
    The above was for Azure/IIS installations. On a linux based server like my InMotionHosting acctount which uses cPanel, you add the MIME types by going to Advanced -> MIME Types, and add the type as "application/octet-stream" and the extension as "mem data". On my InMotionHosting account it still doesn't appear to be working, but that could be them. As long as I have one place to use it I'm happy for now.

    Thanks again, this is now useful. I knew I had to have been doing something wrong or missing a step.

    Last edited: Nov 27, 2014
    nomadic, WendelinReich and Xaurrien like this.