Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Uncaught SyntaxError: Unexpected token <

Discussion in 'Web' started by troy_halsey, Apr 30, 2015.

  1. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Hi Guys-

    I keep getting an "Uncaught SyntaxError: Unexpected token <" error with chrome using WebGL...Unity version 5. Is this a known bug or do I have an error in my code somewhere?

    http://thehalseygroupllc.com/FR_BB_Demo_Compressed/

    Thank you,

    Troy
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    When are you seeing this ? I just opened it in Firefox with no errors...
     
  3. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    That is what is frustrating, my client is getting the error using Chrome. Doesn't chrome update automatically? So frustrated, we have tested on 25 machines in several networks...no issues. I can't replicate the error to solve it.
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    do you know if the game even starts for this specific client ?
    You can add analytics and attempt to report the browser version perhaps.
     
  5. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Well the client is giving me limited info...I'm starting to drain their patience with test links. I believe they get the error once the file is downloaded and the Unity engine tries to engage. This is a proposal situation so I am trying to limit how many times I ask them to test links. Odds are something is very strict in their security...but again, can't replicate so no idea. Was just hoping someone had come across the same error.

    Again, doesn't chrome update automatically, or could their IT disable that.

    How do you add analytics to a webGL page? As in Google Analytics?

    Really appreciate your help, winning their business would really help our little company. Just a challenge with the murky waters of Unity & WebGL.
     
  6. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Actually playing detective here...looks like the error happens either during the load or right after it has downloaded before parsing. This image is from Firefox...can't confirm the version.

     
  7. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Here is the Chrome error...
     
  8. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I'm guessing you don't have access to the JS console...

    When attempting to load the game in Chrome now, I am seeing this:

    Resource interpreted as Script but transferred with MIME type text/plain: "http://thehalseygroupllc.com/FR_BB_Demo_Compressed/Release/UnityConfig.js".
    (index):62 Resource interpreted as Script but transferred with MIME type text/plain: "http://thehalseygroupllc.com/FR_BB_Demo_Compressed/Release/fileloader.js".
    (index):66 Resource interpreted as Script but transferred with MIME type text/plain: "http://thehalseygroupllc.com/FR_BB_Demo_Compressed/Release/FR_BB_Demo_Compressed.js".

    May not be related, but looks like the server you're using for hosting doesn't send the appropriate headers (gzip) for the compressed files ? May be totally unrelated though...

    Regarding analytics - we are reporting to our own backend, but you can work out integration with JS pretty easily I guess.

    If that's something you're interested in we can discuss it offline :)
     
  9. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    We use Bluehost for our server...wonder how I approach this with them. At this point I am interested in anything that will help us win this business and make an awesome product for our client....including renting space on another server for demos. So if you have suggestions, feel free to email me directly. My knowledge is very limited...working with a young developer for scripting. Our skillset is 3d modeling and visualization...this is our first attempt at building an app other than a few simple walk-through simulations in Unity for the desktop.
     
  10. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    We are hosting our game on AWS (in S3 you can set these headers for the game files).
     
  11. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    I'm surprised no one else has come across this issue...was hoping Unity might jump in and give me good news like...this is a known issue...or change your server settings to XYZ.
     
  12. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    So we have determined it is our website that is causing the issues. We use Bluehost.com. I have a work ticket into them to help solve. We came to this conclusion because the same file hosted on Dropbox worked fine for our client - which is great news...kind of.

    Anyone else use Bluehost and run into this?
     
  13. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Update and a desperate plea for help...

    Not our host. Our client gets the same error. What is tricky is several other WebGL demos work fine for them.

    So, not our host and not a general problem with WebGL. What the heck am I missing? Has anyone else come across this issue? Would love some insight.

    Thanks!

    Troy
     
  14. dterbeest

    dterbeest

    Joined:
    Mar 23, 2012
    Posts:
    389
    Works fine for me (Chrome 43.0.2357.81 m)
     
  15. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Yeah, works for everyone except my most important client...only in their network. But again, only content I produce...other WebGL demos work fine.
     
  16. dterbeest

    dterbeest

    Joined:
    Mar 23, 2012
    Posts:
    389
    What are specifics about their network (it must be the problem)?

    have you tried creating a "Hello World" project in Unity? Does that run on their network? Are you using any 3rd party stuff that might be interfering?

    Do some basic tests to determine where the problem is. My bet is that there is an eager network admin that has you fooled
     
  17. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    You would think that, but again, much more complex WebGL demos work fine...we have done every basic test we can think of. The challenge is we have limited access to their network and my inside "tester" is getting tired of daily tests.
     
  18. dterbeest

    dterbeest

    Joined:
    Mar 23, 2012
    Posts:
    389
    Well, i think we have established that your webgl app is not a problem here, so it needs to be somewhere else right?
    If possible it might help to go to your clients office and see if you can debug there (see it first hand)
     
  19. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Yeap, that would be neat. But I don't have access...it's a long pitch situation. It would be like having an electrician come into your home and experiment on your breaker box to see IF he can sell you something.

    Maybe someone will come across this thread who has experienced the same thing. Rather hopeless at the moment.
     
  20. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    68
    Just had to share our exciting news. Thanks to @PlatformSix we have finally solved this unbelievably hard to solve issue. Came down to needing an SSL certificate for our website. Without it, our client's web security was translating the WebGL incorrectly. Sometimes it's the simplest thing that can't be figured out. @PlatformSix is now a legend to our small team. All hail @PlatformSix

    I hope this helps anyone else running into this issue.

    Cheers!
     
    Dantus likes this.
  21. SpiralConDave

    SpiralConDave

    Joined:
    Dec 29, 2014
    Posts:
    37
    Hmm. Just found this thread. I have the same issue, but:
    It's only in Chrome (and I'm on Windows 7)
    It looks like, in the debugger console, that headers are included in the HTML body, and it dies parsing that (???)
    A bug has been logged for this (not by me)
    And it's happening on Unity's local server. Which is really really bad. How can the server be at fault (SSL or whatnot) and it be the development server from Unity? Guys, please.
    If there is a work-around, let me know.
     
  22. Chronovore

    Chronovore

    Joined:
    Dec 20, 2014
    Posts:
    6
    I'm also having this issue. I'd be interested to hear what the fix is.
     
  23. alexsuvorov

    alexsuvorov

    Unity Technologies

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

    Do you mean the local Unity server that servers the files when you use Build and Run in the editor? Yes, there has been an issue with it a while ago that caused a bit different console error like "incorrect header check" in Chrome on Windows. The issue has been fixed and the fix should be already available in the latest releases. Which version of Unity are you using to reproduce this bug?
     
  24. alexsuvorov

    alexsuvorov

    Unity Technologies

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

    The initial issue mentioned in the thread was not particularly specific to Unity, as it was related to accessing resources from external server without SSL certificate. Consider creating a new thread. If you have a similar error, please provide more details, including server configuration and console logs if possible. The easiest way to resolve the issue would be to provide the actual content url (if you can not share the url publicly you can provide it using a private message).
     
  25. Chronovore

    Chronovore

    Joined:
    Dec 20, 2014
    Posts:
    6
    I'm sorry about that. I was referring to the original issue, which was actually just resolved by correcting my web.config. For me it had nothing to do with SSL certs, but with configuring compression.
     
  26. Kubold

    Kubold

    Joined:
    May 10, 2012
    Posts:
    359
    Hi, I'm also getting errors.

    I built a webgl build and uploaded it. Firefox displays this while trying to load it:

    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


    Trying to open the same file with Chrome I get:

    Syntax error: Invalid or unexpected token.
     
  27. Radzievskyi

    Radzievskyi

    Joined:
    May 23, 2013
    Posts:
    6
    I got same error "Unexpected token <" on Unity 5.5.0f3.

    When I build WebGL and start project local, Unity show error about not enough memory, so I extend it in Settings of Player. I extend from 256 to 300Mb and in my situation is help.

    But when I upload it to web server, I got error "Unexpected token <" on different devices and different browsers. I found solution, this problem, when change settings of "Compression Format", I set "Disabled", and seem error gone.

    But I hope Unity team will fix this problem for is never happened more in any case.
     
    AsyncAudio and xxZap like this.
  28. ludusy

    ludusy

    Joined:
    Feb 26, 2015
    Posts:
    1
    I also got the same error "Unexpected token <" on Unity 5.5.0f3 when trying to run the game on the web browser and hosted on Firebase server.

    1. I did the same thing as Radzievskyi,
    Change settings of "Compression Format", I set "Disabled"

    2. And change the In the firebase.json file that gets created in your Firebase project folder, the following line to the "hosting" block:

    "trailingSlash": false

    With those two changes, I got it to run on the server.

    Thanks to all.
     
  29. FlorianeRetinad

    FlorianeRetinad

    Joined:
    Feb 28, 2017
    Posts:
    1
    I had the same error too, @Radzievskyi 's solution solved it.
     
  30. foxvalleysoccer

    foxvalleysoccer

    Joined:
    May 11, 2015
    Posts:
    108
    WE had the same Issues with our server and deployment of webgl.
    WE had to add .unityweb as a mime type on our server. Once added error went away.
     
    Dan_Miller likes this.
  31. JefferyChen

    JefferyChen

    Joined:
    Sep 9, 2014
    Posts:
    2
    can you tell me how to change the setting "Compression Format",in the unity i can't find it . my unity version is 5.4.4p2
     
    LaurieAnnis likes this.
  32. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    The option for compression setting was introduced in 5.5 and there under Player Settings > Publishing
     
    LaurieAnnis likes this.
  33. Iamgeek

    Iamgeek

    Joined:
    Sep 1, 2017
    Posts:
    1
  34. ayeshaggupta

    ayeshaggupta

    Joined:
    Jan 12, 2018
    Posts:
    1
  35. ClaireJohnson

    ClaireJohnson

    Joined:
    Jan 14, 2018
    Posts:
    1
  36. arnoldsmith

    arnoldsmith

    Joined:
    May 23, 2018
    Posts:
    1
  37. unity_oC8QrCoX-oqUVg

    unity_oC8QrCoX-oqUVg

    Joined:
    Jul 6, 2018
    Posts:
    1
  38. jemonsuarez

    jemonsuarez

    Joined:
    Sep 24, 2012
    Posts:
    151
    I was experiencing the same "Uncaught SyntaxError: Unexpected token <" error, but adding the web.config file fixed my issue.
    Here is the link.