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

How to properly host WebGL content

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

  1. TDMIsh

    TDMIsh

    Joined:
    May 29, 2013
    Posts:
    9
    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.
    Capture.PNG

    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?

    Thanks,
    Ish
     
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    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

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    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

    TDMIsh

    Joined:
    May 29, 2013
    Posts:
    9
    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):
    1.  
    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>
    13.  
    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.

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