Search Unity

WebGl Not Working

Discussion in 'Web' started by tokra30, Mar 6, 2015.

  1. tokra30

    tokra30

    Joined:
    Mar 6, 2015
    Posts:
    1
    Hi,

    I am in the middle of evluation Unity3d for use by our company for use to deliver our online content for educational software and have got an issue with Webgl

    When I compile the program for Web Player it works as expected or as a desktop app, but when I compile it for GL all I get is a Unity Web GL holding Page or blank page.

    Looking at the file size of the web GL project it almost 800MB but the windows and Web Player files are smaller and they work what going on.
     
  2. ShabihDesperado

    ShabihDesperado

    Joined:
    Oct 27, 2013
    Posts:
    41
    A. Try Firefox
    B. Uncheck development build
     
    deus0 likes this.
  3. mattbrody

    mattbrody

    Joined:
    Mar 16, 2015
    Posts:
    4
    I'm having the exact same problem. It works on my localhost but not when I push the build to my server. Here's a link to the webgl build that's not working, http://codifyacademy.com/testingunity/index.html. I also tried firefox and unchecked the development build.
     
  4. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Your web host is not returning the files correctly, possibly due to deep linking protection, general refusal to serve Javascript, or something like that.

    For example, compare what it returns for this URL with what you see in your build folder:

    http://codifyacademy.com/testingunity/Release/UnityConfig.js
     
  5. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    To expand on what gfoot said above... it looks like you have a routing or url rewrite issue. Not sure what you're using for a server or technology underneath. Most importantly, your javascript files are (almost) all returning HTML with their MIME type set to text/html. If you are using .NET MVC then you have a route misconfigured... or you have an HttpHandler that is handling those routes, or if you're using a *nix server (or possibly IIS) then you have a URL Rewrite that is returning content that is not correct. See this screenshot:

    Capture.PNG
     
    d12frosted likes this.
  6. Andrew-Horobin

    Andrew-Horobin

    Joined:
    Jun 18, 2014
    Posts:
    1
    Hey guys, I was having the exact issue as gfoot, the build worked fine locally, but just a grey box instead of my build once uploaded to my web host. All I did was delete the .htaccess file that gets generated with the build from the directory on my server and it works fine now. I use 1and1.com as my web host, so I don't know if they do something that caused a conflict.
     
    ei1 and mattbrody like this.
  7. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Your problem was,actually different then. The mime types weren't correctly mapped for the supporting files and when you deleted htaccess it fixed the issue. In some cases the .htaccess file needs to stay and be modified for the correct mine mappings.
     
  8. mattbrody

    mattbrody

    Joined:
    Mar 16, 2015
    Posts:
    4
    Deleting the htaccess filed worked!
     
  9. BrentMichie

    BrentMichie

    Joined:
    Sep 10, 2014
    Posts:
    32
    I am having similar issues. Can someone direct me to a tutorial of how to Build a Unity 5.0 WebGL and upload it to a webpage. I have been searching the internet and these forums and can't find a tutorial on how to do this. It does not appear as simple as the previous Unity Web Player upload was.
     
  10. softnax

    softnax

    Joined:
    Mar 20, 2015
    Posts:
    6
    for me removing the .htaccess file did the trick but then the page was unable to load the release/****.html.mem
    here i am after solving yet another issue .... ;)

    by the way it take ages to finish the loading of the page ...
     
  11. softnax

    softnax

    Joined:
    Mar 20, 2015
    Posts:
    6
    Finally WebGL is Working ..

    Now its working Ok but it takes really long time to load.
    i hope the screenshots below will help you about the required settings

    ohh also check your hosting provided for MIME types




     
    ei1 likes this.
  12. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    I think I am having a similar issue. I can create a MIME type on my host, but no idea what I am supposed to put there. I noticed in my JAVA console, it is giving me a similar error to what you guys are discussing. Any suggestions on what kind of MIME I need to add?
     
    Nicseloli likes this.
  13. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Depends. If you're using the uncompressed version, you'll need to make sure there are mime types for .mem, .data and .unity3d with their MIME types set to: "application/octet-stream"

    If you're using the gzipped version:
    .memgz -> application/octet-stream
    .datagz -> application/octet-stream
    .unity3dgz -> application/octet-stream
    .jsgz -> application/x-javascript or application/javascript

    If you're using the precompressed ones though you'll also need to make sure your server is adding the appropriate gzip response header so the browser knows it's compressed and uncompresses it. This varies depending on your host. It was kind of a bear to get setup in IIS, but I'm going to be publishing a guide sometime soon for configuring IIS and web.config to provide the correct content.
     
    Zelek, Zaelot and LaurieAnnis like this.
  14. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Thanks @Dustin Horne! For the most part that makes sense to me. I use Bluehost for our website. The irony is our demo runs on most machines, just my client can't access them. Gives a javascript error right away. I'm suspecting they may have some additional web security that I can't replicate yet. Hopefully we will know more if we win the business.
     
  15. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    @troy_halsey do you know what browser / version they are running? It's possible that they have some security setting that is preventing it from running or even some security software on the machine like some kind of overzealous ad blocker.
     
  16. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
  17. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Also, just added your MIME settings @Dustin Horne...but scared to ask the client to check again...as my sales instinct tells me I have a limited amount of tries with them before they tell me to bug off. Thanks for the clear instructions.
     
  18. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I'd await clarification on your other issue and see if it's a Unity bug before you ask them to try again.
     
  19. ulisesyo

    ulisesyo

    Joined:
    Aug 11, 2010
    Posts:
    24
    Hi there!

    The main problem removing the .htaccess is that you lose the opportunity to send the zipped data (having a big amount of data to send). In my case, having a 1and1 shared server what I needed to do was to add the "RewriteBase" directive so the Rewrite module works properly.

    I have the game in this folder: /root/TwistedRocket/

    then my .htaccess is:
    Code (Apache):
    1. Options +FollowSymLinks
    2.  
    3. RewriteEngine on
    4. RewriteBase /TwistedRocket/
    5. RewriteCond %{HTTP:Accept-encoding} (gzip.*)
    6. RewriteRule (.*)Release(.*)\.js $1Compressed$2\.jsgz [L]
    7. RewriteRule (.*)Release(.*)\.data $1Compressed$2\.datagz [l]
    8. RewriteRule (.*)Release(.*)\.mem $1Compressed$2\.memgz [L]
    9. RewriteRule (.*)Release(.*)\.unity3d $1Compressed$2\.unity3dgz [L]
    10.  
    11. AddEncoding gzip .jsgz
    12. AddEncoding gzip .datagz
    13. AddEncoding gzip .memgz
    14. AddEncoding gzip .unity3dgz
    I hope this helps
     
  20. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    @ulisesyo - Can you elaborate on what this does? Sounds like you are onto something, but it is just out of my understanding.
     
  21. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    It turns on URL Rewriting... sets the base to the application path, adds a condition for the gzip header, then rewrites the js, data, mem, and unity3d URLs to the gz equivalents and adds the appropriate headers.
     
  22. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    @Dustin Horne Interesting...I will give it a try! Thanks guys - love this community.
     
  23. ulisesyo

    ulisesyo

    Joined:
    Aug 11, 2010
    Posts:
    24
    Hi! I hope you got to make it work!
    I thought I was subscribed to the thread, but it turned out I wasn't!

    I think the main problem with the Unity template is that it is expected to be used when you have the game in a root web (for example: www.mygame.com/), but if you want to put it in a folder (example: www.mydomain.com/mygame/) you need to add the RewriteBase with your folder.

    In this case:
    RewriteBase /mygame/

    I hope this makes it more understandable :)
     
    theANMATOR2b and Dustin-Horne like this.
  24. marcelkop

    marcelkop

    Joined:
    Jun 24, 2015
    Posts:
    1
    Hi, I have the same problem! But rewrite doesn't function. The browser searches for the .js files not the.jsgz What I am doing wrong?
     
  25. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Are you on IIS or Apache?
     
  26. JeanSimonet

    JeanSimonet

    Joined:
    Nov 23, 2012
    Posts:
    31
    Hey, just here to say that indeed adding the RewriteBase as @ulisesyo suggests is what fixed it for me. The slight difference in syntax for the RewriteCond line didn't seem to make a difference.
    Also, for reference, I am on 1And1 as well, and this is my .htaccess
    Code (JavaScript):
    1. Options +FollowSymLinks
    2. RewriteEngine on
    3. RewriteBase /FireEffectShaderGL/
    4. RewriteCond %{HTTP:Accept-encoding} gzip
    5. RewriteRule (.*)Release(.*)\.js $1Compressed$2\.jsgz [L]
    6. RewriteRule (.*)Release(.*)\.data $1Compressed$2\.datagz [L]
    7. RewriteRule (.*)Release(.*)\.mem $1Compressed$2\.memgz [L]
    8. RewriteRule (.*)Release(.*)\.unity3d $1Compressed$2\.unity3dgz [L]
    9. AddEncoding gzip .jsgz
    10. AddEncoding gzip .datagz
    11. AddEncoding gzip .memgz
    12. AddEncoding gzip .unity3dgz
    And my gl build is accessible at http://yearseventeen.com/FireEffectShaderGL/index.html
    So hopefully this clears up the base VS url question.
     
    theANMATOR2b likes this.
  27. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
  28. jdinfusemed

    jdinfusemed

    Joined:
    Jun 30, 2015
    Posts:
    2
    I am still not getting my files to use the Compressed folder.

    I have used the .htaccess settings from above, and set the mime types.
    I have confirmed that mod_rewrite is enabled

    I am using on a SUSE LAMP stack

    I am at a loss for how to get this to work, any help would be much appreciated.
     
    Last edited: Jun 30, 2015
  29. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Can't help you there. I'm an IIS guy with very little knowledge of Apache setups.
     
  30. LaurieAnnis

    LaurieAnnis

    Joined:
    Jan 24, 2010
    Posts:
    63
    Thanks everybody! I got this to work but found the suggestions hard to interpret. This is what worked for me:

    I had my build in a folder on my website, like myurl.com/MyFolderHere/

    Open the .htaccess file in a text editor and between the lines that say

    RewriteEngine on

    and

    RewriteCond %{HTTP:Accept-encoding} (gzip.*)

    I wrote

    RewriteBase /MyFolderHere/

    and saved over the old one on my site.

    Then I had to go to my control panel on my host and hunt down the MIME tab, and found that adding new mime types was pretty straight forward there. Under the existing mime types I already had, I wrote

    .data application/octet-stream

    and

    .mem application/octet-stream

    Now I'm still having trouble with the load time, but it does eventually work so I thought I'd write up my dumbed down approach. I've tried adjusting the total memory in the generated .index file as per the Unity documentation for Player Settings, but it still loads really slow. http://docs.unity3d.com/Manual/webgl-building.html
     
    Cruncho and theANMATOR2b like this.
  31. jdinfusemed

    jdinfusemed

    Joined:
    Jun 30, 2015
    Posts:
    2
    Is there anyone that has gotten the compressed files to be sent to the browser to work on a LAMP server? Everything else works for me.

    EDIT: After more searching and research I found that in Apache you need to enable the mod_deflate module. This http://www.netlobo.com/mod_deflate_suse_linux.html was able to help with enabling, and making sure I had all the right types set up for compression.
     
    Last edited: Jul 1, 2015
  32. ersaurabh101

    ersaurabh101

    Joined:
    Oct 8, 2010
    Posts:
    412
  33. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
  34. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Less, actually :) Seems it couldn't allocate the heap at all.
     
  35. ersaurabh101

    ersaurabh101

    Joined:
    Oct 8, 2010
    Posts:
    412
    hey, its not my build..i mean to say if i try to play any demo, nothing works on my browsers...got it ???
     
  36. LaurieAnnis

    LaurieAnnis

    Joined:
    Jan 24, 2010
    Posts:
    63
    I just wanted to update my post since I had to make a few adjustments for my projects to work today due to the changes in 5.3:
    • WebGL: Release builds will now always use gzip compressed files, and decompress in JavaScript, if the server is not set up to handle gzip on the http protocol level -WebGL: Support soft shadows -WebGL: Higher quality Standard Shader -WebGL: Made it possible to relocate all build output files by changing only the main html output.
    For non technical people like me, it meant that I had to add the mime types for compression as Dustin Horne explained above:

    .memgz -> application/octet-stream
    .datagz -> application/octet-stream
    .unity3dgz -> application/octet-stream
    .jsgz -> application/x-javascript or application/javascript

    Hope that helps somebody!
     
    ilmario, Zelek, theANMATOR2b and 3 others like this.
  37. daqriken

    daqriken

    Joined:
    Jan 16, 2014
    Posts:
    7
    Hi,

    I've tried everything mentioned here to get a relatively simple scene built in Unity v5.3 running in WebGL to no avail. I'm also on 1and1 using a shared Apache server. It seems that there is no .htaccess file in the root directory of the project build (i.e. the same folder that contains the index.html file). Rather, there is one in the 'Resources' folder that already contains most of the code referenced in this thread (with more variable usage). I also tried adding the 4 mime types Lareieli points out here and tested with the latest Safari, Chrome and Firefox browsers. Still I get one of the 2 following errors:

    - incorrect header check
    - unknown compression method

    I've also uploaded the build to a subdir of the "root" (I believe) called 'publicAccess/HappyHolidaysAnimation' and tried adding the RewriteBase directive to indicate that.

    I'm trying to get this online ASAP so any more help would be much appreciated. Here's the URL for reference:

    http://shuri-ken.com/publicAccess/HappyHolidaysAnimation/index.html

    Thx!
     
  38. LaurieAnnis

    LaurieAnnis

    Joined:
    Jan 24, 2010
    Posts:
    63
    daqriken, header and compression errors were what led me to find these solutions, so it sounds like its possible that the fixes haven't been applied properly. Could you post a screen shot of where you added the mime types? That's a potential place for errors. I don't have an .htaccess file in my root directory anymore either, with the new build from 5.3 I just left the ones that were in the Resources folder untouched. No RewriteBase added. Hope that helps!
     
  39. JuanAntonio

    JuanAntonio

    Joined:
    Jan 4, 2013
    Posts:
    7
    Hello,

    I have had this error but i deleted .htaccess and worked until that I have begun to use Unity5.3, the error is that not can decompress the files and when Google Chrome o FireFox try to decompress it but not decompress it and not find MyProyect.js. I use 1&1, i edited .htaccess but i think that is not necessary and i have tried put web.config in the root of proyect, in root of server and release folder where it is .htaccess file.
    Is it necessary change any option of 1&1? Is it necessary use web.config and where i have to host it?

    Thanks.
     
  40. Deleted User

    Deleted User

    Guest

    Hi JuanAntonio,

    another hint - I also use a 1&1 server and it works now.

    I use the .htaccess file described by JeanSimonet (of course with RewriteBase to the directory in which index.html is located) and I removed the .htaccess from the Release directory. I cleared the browser cache and it is working now with gz data.
     
  41. JuanAntonio

    JuanAntonio

    Joined:
    Jan 4, 2013
    Posts:
    7
    You have removed .htaccess from the Release directory but where have you put the .htaccess file?
     
  42. JuanAntonio

    JuanAntonio

    Joined:
    Jan 4, 2013
    Posts:
    7
    I use the .htaccess file described by JeanSimonet (of course with RewriteBase to the directory in which index.html is located) and I removed the .htaccess from the Release directory. I cleared the browser cache and it is working now with gz data, but it not work. I have put the .htaccess in Release directory and cleared the browser cache but it not work, I have put the .htaccess in directory in which index.html and cleared the browser cache but it not work. Thank for you response but it not work, i need help!.

    Thank.
     
  43. daqriken

    daqriken

    Joined:
    Jan 16, 2014
    Posts:
    7
    Thanks for the response. I've left the .htaccess in the 'Release' subdir as is. For 1and1 shared hosting I'm not aware of any other place to add these MIME types other than in the .htaccess file. Here's what my .htaccess file looks like in the 'Release' subdir:
    Code (JavaScript):
    1. Options +FollowSymLinks
    2. RewriteEngine on
    3.  
    4. RewriteCond %{HTTP:Accept-encoding} gzip
    5. RewriteCond %{REQUEST_FILENAME}gz -f
    6. RewriteRule ^(.*)\.js$ $1\.jsgz [L]
    7.  
    8. RewriteCond %{HTTP:Accept-encoding} gzip
    9. RewriteCond %{REQUEST_FILENAME}gz -f
    10. RewriteRule ^(.*)\.data$ $1\.datagz [L]
    11.  
    12. RewriteCond %{HTTP:Accept-encoding} gzip
    13. RewriteCond %{REQUEST_FILENAME}gz -f
    14. RewriteRule ^(.*)\.mem$ $1\.memgz [L]
    15.  
    16. RewriteCond %{HTTP:Accept-encoding} gzip
    17. RewriteCond %{REQUEST_FILENAME}gz -f
    18. RewriteRule ^(.*)\.unity3d$ $1\.unity3dgz [L]
    19.  
    20. AddEncoding gzip .jsgz
    21. AddEncoding gzip .datagz
    22. AddEncoding gzip .memgz
    23. AddEncoding gzip .unity3dgz
     
    4fthawaiian likes this.
  44. nonlin

    nonlin

    Joined:
    Dec 12, 2013
    Posts:
    46
    I actually got it working by removing all .htaccess but I'm gonna try putting in the one for Release maybe that will also bring back the loading bar.

    Yea loading works if I keep the .htaccess inside the Release folder and most importantly the game doesn't crash with errors.
     
  45. JuanAntonio

    JuanAntonio

    Joined:
    Jan 4, 2013
    Posts:
    7
    I use the .htaccess file described by JeanSimonet and not find the MyProyect.js file but I get a 300 error (Multiple Choices). I tried it of many ways but it not worked of anyways. I think that I have to change some option of 1&1 for example Dinamyc compress, I'm going crazy. In this images you can see the errors:
     

    Attached Files:

  46. daqriken

    daqriken

    Joined:
    Jan 16, 2014
    Posts:
    7
    I finally called 1and1 for help and they said that it's impossible to add these compression directives for a shared hosting account. I would have thought that the htaccess file directives are additive and that the system should be able to do the proper thing given the htaccess file in the Release folder...
     
  47. daqriken

    daqriken

    Joined:
    Jan 16, 2014
    Posts:
    7
    So as a last resort for now I've produced a 'development' build which, among other things, doesn't use compression. It takes a while to load in the browser but at least it's working so I'll use this for now.
     
  48. JuanAntonio

    JuanAntonio

    Joined:
    Jan 4, 2013
    Posts:
    7
    Thank you, so much. I hope that I can build in the Release folder with 1&1 in the future.

    Regards.
     
  49. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Thanks a ton for your detailed non-technical explanation. It's very beneficial for other non technicals.
    Do you mind sharing who you are using for hosting? It sounds like a user friendly hosting service.

    I thought I was able to overcome this difficult web crap when free hosting opened up and allowed for embedded media, larger files and more storage - including webplayer. Unfortunately since the update to the browsers - it looks like searching for answers to issues like this to be able to successfully deploy WebGL builds is the norm.
    Hopefully WebGL build/hosting can be simplified in the near future so play testing isn't such a hassle.
     
  50. vivekchakraverty

    vivekchakraverty

    Joined:
    Mar 16, 2016
    Posts:
    5
    i hosted my agme project on itch.io then a friend suggested some improvements. while doing that unity crashed and ever since none of its webgl builds works. i tried uninstalling and re-installing unity but to effect.can you please help me.