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

UnityLoader.js Module.wasmRequest is not a function

Discussion in 'WebGL' started by CrazyGamesCom, Jan 30, 2019.

  1. CrazyGamesCom

    CrazyGamesCom

    Joined:
    Nov 11, 2016
    Posts:
    16
    Hello,


    We are trying out a modern UnityLoader ( 2018.3.0.b2, the latest version avail on Linux afaik ) the with older builds of WebGL games. UnityLoader.js is supposed to be backwards compatible, but fails for some games.

    An error we are currently seeing is `Module.wasmRequest is not a function`.
    Looking at UnityLoader.js; the one in 2018.2 has indeed a function wasmRequest that has been removed in 3.0.b2. An example of a game that is not working is https://www.crazygames.com/game/tank-off
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Could you try to build on Windows/Mac with the latest official 2018.3 ?
     
  3. CrazyGamesCom

    CrazyGamesCom

    Joined:
    Nov 11, 2016
    Posts:
    16
    We tried it with the latest UnityLoader on OSX, the same error persists.

    To clarify: we do no rebuild the game, we take an existing build and use a more recent UnityLoader to take advantage of some of the more recent features of the loader. We cannot rebuild the game as we are a publisher that host games, and do not have the source project files. As we understood it UnityLoader is supposed to be backwards compatible with older builds.
     
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Are you using your own WebGL Template? could you paste here your call to UnityLoader.instantiate() ?
     
  5. CrazyGamesCom

    CrazyGamesCom

    Joined:
    Nov 11, 2016
    Posts:
    16
    We are indeed using our own template to show a custom progress bar and overlay:

    Code (JavaScript):
    1.  
    2. UnityLoader.instantiate(
    3.   'game-container',
    4.   moduleJsonUrl, // variable assigned to url of module json for particular game
    5.   {
    6.             onProgress: tracker, // custom function that updates game progress
    7.             Module: {
    8.               onRuntimeInitialized: runTimeInitialized, // hide our own overlay
    9.               cacheControl: { default: 'immutable' },
    10.               companyName: 'CrazyGames',
    11.               productName: gameSlug, // unique slug for this game
    12.             },
    13.           }
    14. );
    15.  
    So far I have found two games that don't work:

    https://www.crazygames.com/game/3d-moto-simulator-2

    and the aforementioned one:
    https://www.crazygames.com/game/tank-off
     
  6. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    The instantiation looks fine. I believe the problem is in the loader. I just checked the 2018.3.0f2 UnityLoader.js and there is no reference to wasmRequest so you are probably using an old one stitll.
     
  7. CrazyGamesCom

    CrazyGamesCom

    Joined:
    Nov 11, 2016
    Posts:
    16
  8. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Ok, I see the problem.

    Could you try to pass this wasmRequest implementation at instantiate-time?

    Code (csharp):
    1.  
    2. UnityLoader.instantiate("gameContainer", "Build/test.json", {onProgress: UnityProgress,
    3.   Module: {
    4.     wasmRequest: function (wasmInstantiate, callback) {
    5.       wasmInstantiate(this.wasmBinary).then(function (result) { callback(result.instance); });
    6.     },
    7.   }
    8. });
    9.  
     
  9. CrazyGamesCom

    CrazyGamesCom

    Joined:
    Nov 11, 2016
    Posts:
    16
    That seems to solve the issue. Thank you for your help.