Search Unity

Illegal character error in Firefox

Discussion in 'Web' started by opertoonist, May 13, 2016.

  1. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    257
    Hi, I've got a WebGL project that's running fine in Safari and Chrome, but shows this error in Firefox:

    An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was:
    SyntaxError: illegal character​

    Here is what appears in the console:

    Error: WebGL: Disallowing antialiased backbuffers due to blacklisting. UnityLoader.js:1:4116
    Invoking error handler due to
    SyntaxError: illegal character UnityLoader.js:1:6461
    You can view the project here: http://opertoon.com/pnply/panelpoems/
    Here is a development build of the same project, which works fine in Firefox: http://opertoon.com/pnply/panelpoemsdev/

    Built with Unity 5.3.4f1.

    Any ideas as to what might be causing this? Thanks.
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Hey,
    I can reproduce if i go to http://opertoon.com/pnply/panelpoems/

    however, i can't if i download all files and run them locally with a http server. Perhaps it's a web server configuration issue.

    By the way, make sure in the Release folder, you only have these files:
    1. UnityLoader.js
    2. PanelTransitions WebGL.jsgz
    3. PanelTransitions WebGL.datagz
    4. PanelTransitions WebGL.memgz
     
  3. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Hello opertoonist.

    Your build does not work because you are serving compressed content on requests which expect uncompressed data, but your server does not provide Content-Encoding: gzip header for those responses, necessary for such scenario. Most probably your server in it's current configuration is not capable to append headers to the response. You should either adjust your server configuration or just remove the .htaccess file from the Release subfolder and the build should work.
     
  4. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    257
    Thanks @alexsuvorov and @Marco Trivellato -- this is very helpful. I can confirm that removing the .htaccess file fixes the issue, and I'll look into updating my server config so I can serve up the compressed files correctly.
     
  5. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    257
    Sorry to revive this old post @alexsuvorov and @Marco-Trivellato — I'm still struggling with this. When I remove the .htaccess file Firefox works, but then Safari and Chrome break with an "unknown compression method" error.

    When I look at the headers for the .data file (this is with .htaccess intact), in the case of Safari, the server does seem to be sending Content-Encoding: gzip, while in Firefox it isn't, which matches the diagnosis above.

    What seems odd to me is that the FF request headers include Accept-Encoding: gzip, deflate, while the Safari request headers do not, and yet Safari is the browser that is receiving the Content-Encoding: gzip header. This seems like the opposite of what would be expected, but I confess I don't have a good understanding of what's going on. Any ideas?
     
  6. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Hello opertoonist.

    If you remove the .htaccess then the content should load correctly in all browsers. If it is not the case, then you have either modified the server configuration (should restore to default) or you might have another .htaccess somewhere at the upper level.

    Your build does not load because you have set Content-Type: application/x-gzip in your response. Do you have some other content hosted on your website that requires this header? Look for another .htaccess at the upper levels (it may be automatically added when you install some forum/cms into the root for example).
     
    Last edited: Jul 26, 2016
  7. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    257
    Thanks for the suggestions. Adding the following to my .htaccess solved the problem:

    <Files *.datagz>
    ForceType application/octet-stream
    </Files>
    <Files *.jsgz>
    ForceType application/javascript
    </Files>
    <Files *.memgz>
    ForceType application/octet-stream
    </Files>
    <Files *.unity3dgz>
    ForceType application/octet-stream
    </Files>
     
    exafred likes this.