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

Bug Getting Invalid JS from USER_JSPRE_PLACEHOLDER

Discussion in 'WebGL' started by jasonboukheir, Feb 27, 2022.

  1. jasonboukheir

    jasonboukheir

    Joined:
    May 3, 2017
    Posts:
    80
    Unity version 2021.2.13f1

    I'm using the js-sha512 library attached. When I run standalone tests for WebGL, I'm getting the error:

    Unable to parse Build/PlayerWithTests.framework.js! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)
    Checking the console, I'm getting an error

    Uncaught SyntaxError: Invalid left-hand side in assignment
    When I look at the code in the PlayerWithTests.framework.js source file, I noticed the minified JS script I added has been modified with

    Module["USER_JSPRE_PLACEHOLDER"]="USER_JSPRE_PLACEHOLDER";

    For example, in my sha512.min.jspre script, this snippet

    Code (JavaScript):
    1. g=$&th^~$&sh
    Was turned into:

    Code (JavaScript):
    1. g=Module["USER_JSPRE_PLACEHOLDER"] = "USER_JSPRE_PLACEHOLDER";th^~Module["USER_JSPRE_PLACEHOLDER"] = "USER_JSPRE_PLACEHOLDER";sh
     

    Attached Files:

    Last edited: Feb 27, 2022
  2. jasonboukheir

    jasonboukheir

    Joined:
    May 3, 2017
    Posts:
    80
    Still getting this issue, seems there is an incorrect replacement.
     
  3. anthony_b_

    anthony_b_

    Unity Technologies

    Joined:
    Oct 27, 2020
    Posts:
    23
    Our recommendation would be to use the un-minified js-sha512 library as a prejs in Unity and have Unity perform the minification with the non-development build.