Search Unity

Uncaught TypeError: Cannot redefine property: asmLibraryArg

Discussion in 'Web' started by Endomlic, Jun 9, 2019.

  1. Endomlic

    Endomlic

    Joined:
    Jul 2, 2013
    Posts:
    4
    I just updated Unity to 2019.1.5f1 from 2018.2.5f1 and built the project for WebGL.
    In 2018 it builds and runs on webGL fine with no errors, however, after this build I'm getting this error when I run it (90% loaded):
    Uncaught TypeError: Cannot redefine property: asmLibraryArg

    I looked everywhere and can't find the cause for this. Any ideas? It's never had this error before, and I didn't make any changes other than updating Unity.

    (Not sure if related)
    I'm using a few some javascript files such as this one that need to be in the program.

    mergeInto(LibraryManager.library, {
    OpenWindow: function(link)
    {
    var url = Pointer_stringify(link);
    document.onmouseup = function()
    {
    window.open(url);
    document.onmouseup = null;
    }
    }
    });

    and calling it in C# like so:
    [DllImport("__Internal")]
    private static extern void OpenWindow(string url);
     
    Last edited: Jun 10, 2019
  2. Ironjuan

    Ironjuan

    Joined:
    Sep 17, 2018
    Posts:
    1
    I am having this error too, do you found how to solve it?
     
  3. Endomlic

    Endomlic

    Joined:
    Jul 2, 2013
    Posts:
    4
    Nope. I had to revert back to my older Unity version. :(
    I tried all sorts of things to no avail. No idea what's causing it or how to fix it. I wish someone could help still. I would really love to upgrade to 2019.
     
  4. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    117
    I'm having this issue too. I was wondering if maybe it is something to do with the differences between asmJS and WebAssembly that you could switch between in 2018.2? but I can't find the option to modify this in the player settings any more..
     
  5. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    117
    Anyone had any luck on this yet?
     
  6. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    117
    So I've located where it bugs out:

    problem.PNG

    So it looks like the error is occuring because it tries to "redefine" this. I found that it does indeed define this earlier:
    origin.PNG

    Does this mean anything to anyone?
     
  7. Xylph

    Xylph

    Joined:
    Dec 11, 2013
    Posts:
    30
    I found the cause of the problem. It was an external jslib plugin (https://github.com/kongregate/Unity-WebGL-Utilities). It worked after removing it. Looks like it's conflicting with 2019.1.

    If you're publishing your game in Kongregate, you might have come across this plugin.
     
    Cfirzi and MFKJ like this.
  8. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    117
    It was this, thanks very much :) :)
     
  9. carmenfan

    carmenfan

    Joined:
    Apr 27, 2018
    Posts:
    2
    Any fix/workaround for this problem?

    I don't use Kongregate's plugin but I have a jslib to talk to my external web application. I'm running into the same error.
     
  10. Endomlic

    Endomlic

    Joined:
    Jul 2, 2013
    Posts:
    4
    I updated to 2019.2 and removed the Unity-WebGL-Utilities and it's working now.
     
  11. Cfirzi

    Cfirzi

    Joined:
    Jul 30, 2018
    Posts:
    24
    I found a solution to this issue where you can still use unity 2019 and Unity-WebGL-Utilities plugin

    if you just comment out the problematic if statement :
    Code (JavaScript):
    1. Object.defineProperty(Module, "asmLibraryArg", {
    2.     get: function () { return Module.realAsmLibraryArg; },
    3.     set: function (value) {
    4.       if (typeof value == "object" && typeof value._JS_WebRequest_Create == "function")
    5.         value._JS_WebRequest_Create = CachedXMLHttpRequest.wrap(value._JS_WebRequest_Create);
    6.       Module.realAsmLibraryArg = value;
    7.     },
    8.   });
    9. }
    the plugin will still work and the build will run as usual.
    not sure whats going on there but it is possible that in 2019 Unity take care of this on their side so the plugin still works even tho the property is no longer available
     
  12. bigbrainz

    bigbrainz

    Joined:
    Jul 21, 2015
    Posts:
    177