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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Uncaught SyntaxError: Unexpected token 'var'

Discussion in 'WebGL' started by Rufus31415, Oct 4, 2020.

  1. Rufus31415

    Rufus31415

    Joined:
    Mar 16, 2020
    Posts:
    10
    I have just compiled a WebGL application with Unity 2019.4.11f1 and I get a popup when loading indicating the error :
    Uncaught SyntaxError: Unexpected token 'var'
    Uncaught TypeError: UnityLoader[n] is not a function
    upload_2020-10-4_16-20-47.png

    upload_2020-10-4_16-32-30.png

    Generally speaking, the problem occurs even with an empty project and the default scene.

    There was no worries with Unity 2018

    Maybe it is related to this post : https://forum.unity.com/threads/webgl-build-produces-invalid-code.927179/

    This new problem only occurs on the Oculus Quest browser (Android 7.1.1, Chromium 84). I know that this browser is not officially supported, but I would like to notify that there is a regression. Maybe other browsers are impacted.


    upload_2020-10-4_16-19-8.png
     
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    That is quite peculiar. Any chance you'd be able to zip up the build? What is on the first lines of UnityLoader.js, specifically line 4?

    The build works ok on regular desktop browsers?
     
  3. Rufus31415

    Rufus31415

    Joined:
    Mar 16, 2020
    Posts:
    10
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Indeed looks like a regular build, nothing wrong there. Unfortunately hard for me to reproduce since I do not have an Oculus Quest browser. What does running a Development build say? In a Development build the UnityLoader.js script will not be minified, so perhaps it will show a better stack trace in the error that would give a clue.
     
  5. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    553
    If you build an empty project, does it also happens?
     
  6. Rufus31415

    Rufus31415

    Joined:
    Mar 16, 2020
    Posts:
    10
    Yes it does
     
  7. Rufus31415

    Rufus31415

    Joined:
    Mar 16, 2020
    Posts:
    10
    @jukka_j I tried a development build, but the logs and the popup are the same.
     
  8. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Can you check the error line numbers and whole error call stack against the Development build. In the Release build the framework.js file is minified, so it would just give an error on line 4, which is a huge long line.

    In a Development build, the error callstack can give better line numbers since the source is not minified. Then seeing an error on line X is more helpful when not everything in the source is on the same line.