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. Dismiss Notice

Difficulties to switch from Web Player to WebGL

Discussion in 'WebGL' started by Raitoning, Jan 10, 2016.

  1. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    Hi everyone,

    Now that WebGL build is officially supported, I just tried to build my new game on it. After a very, very long compilation time ( near 5 minutes with "Fastest" optimisation option, versus under a minute in WebPlayer ), my game just won't load. Either locally or on my website server, the WebGL player won't do anything. The page loads fine, but then nothing. It doesn't load the game as it should. I don't know what I'm doing wrong.

    My WebPlayer releases always worked like a charm and run fast and fine. Switching to WebGL is a pretty hard moment, and I'm not ready to only use it, as the Web Player build will be removed in the future. OK, it would run normally faster, and allow more people to run the game, and so on. But for me, everything goes wrong with it. My workstation won't load WebGL players 75% of the time ( Out of Memory error ), and when I run Linux, without proprietary drivers, the game "runs", the screen is messed up and is unusable, but it "runs". With proprietary drivers, I got a nice pinkish bubblegum screen and nothing works.

    So well, I would like someone to teach me this new tool, as reading the documentation about it doesn't help me much (not that it is bad, it always been good and precise, but nothing written inside works for me for that case). For those who wonder, I use Internet Explorer 11 (Inori version) x64 on Windows 7 x64. Yeah I know it got huge problems with WebGL and won't be fixed, but well, it worked perfectly for me since years.

    Thanks everyone for reading me, I hope someone would take his time to help me :)
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Although Unity WebGL and WebPlayer both target the Web, they are very different platform.
    As you con see from the browser compatibility matrix IE11 support is limited so, first of all, I would recommend to get your project to work on Chrome and Firefox, and only at that point attempt to run on IE11.
     
  3. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    Hi.

    I finally installed Mozilla Firefox 43.0.4 because I don't really have the choice if I want to continue working with Unity. So now WebGL players works well. But mine still doesn't.

    I can run the WebGL player located on my hard drive, but when I put it on my website, I can still access the HTML page, but then nothing, it doesn't load the game. Maybe my server has not the right configuration or I've done something wrong somewhere, I don't know. Maybe my server doesn't support Gzip compression, which wouldn't suprise me, as it's a free server I got shipped with my subscription to my ISP.
     
  4. lloydsummers

    lloydsummers

    Joined:
    May 17, 2013
    Posts:
    343
    Are you able to see an error message? You might want to do a development build least optimized (note: it'll be slow - its for debugging only). Open the page from your server, and turn on the Java Console from the Firefox development menu.

    There should be a stack trace error. It'll end with abort or header error or something there in. I'm suspecting you need to only add the mime-types but it's best to 'follow the log' when troubleshooting and finding the error message first.
     
  5. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    I've made a development build and ran it from my hard drive, there were no errors. Then I've uploaded it on my website server, and tried to run it. I got an error right after the page finishes from loading. This is a screenshot from what's happening.
    bug webgl.jpg

    "incorrect header check" sounds like the transfer from my computer to the server failed somewhere, or maybe my server doesn't like the .htaccess file, or something like this.
     
  6. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    it's possible, try to delete the .htaccess file
     
  7. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    I think I got another problem, I've got an .htaccess file in the release folder on my server, but there's none in the development build on the server, and Unity did not created one when building.

    Edit: I've deleted the .htaccess from the release build on my server, and now the game loads and seems to run fine. I got some errors in the Javascript console:


     
  8. lloydsummers

    lloydsummers

    Joined:
    May 17, 2013
    Posts:
    343
    Incorrect header check is usually just caused by missing Mime-Types. IIS (depending on your Web server) doesn't really recognize many file extensions by default and the WebGL mime-types are non standard.

    You should just need to include the mime-types somewhere to get it working (depends on your type of web server)

    1. <mimeMapfileExtension=".memgz"mimeType="application/octet-stream"/>
    2. <mimeMapfileExtension=".datagz"mimeType="application/octet-stream"/>
    3. <mimeMapfileExtension=".unity3dgz"mimeType="application/octet-stream"/>
    4. <mimeMapfileExtension=".jsgz"mimeType="application/x-javascript; charset=UTF-8"/>

    You probably also need four for the non-gz file extensions.

    Because .htaccess did something for you though your probably not using IIS, so I can't help configure unfortunately...
     
    Last edited: Jan 11, 2016
  9. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    I don't know a lot about my server, but there are a lot of limitations, such as PHP 4.0 max and query content forbidden. The file compression is not allowed I think. At least if it seems to work for the moment, I'd rather not play around with the server settings and break it, or getting banned from my ISP's server, which I got for free ( 10Gb for free when you subscribe ). At least I've got a place where to share my games.