Search Unity

WebGL Error: "Uncaught TypeError: this.decompress is not a function"

Discussion in 'Web' started by ywj7931, Sep 20, 2017.

  1. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    I am having this error 4 times when opening the webGL website, it is should be caused by failure to decompress ".unityweb" files. Any idea how to solve this? This only happened in WeChat dev browser ( a chat app)
     
  2. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    I am using Unity5.6.1
     
  3. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    I tried 2017.1.1's UnityLoader.js but it also didn't work.
     
  4. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    This is error in blob:

    this.require = function () {
    return {};
    }; this.decompress = function (data) {
    return data;
    }; this.onmessage = function (e){var t={id:e.data.id,decompressed:this.decompress(e.data.compressed)};postMessage(t,t.decompressed?[t.decompressed.buffer]:[])}; postMessage({ ready: true });
     
  5. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    I solved the problem by chaning the option to:

    var options = ["this.require = ",decompressor.require,"; var vv = this;this.decompress = ",decompressor.decompress,"; this.onmessage = ",function(e){var t={id:e.data.id,decompressed:vv.decompress(e.data.compressed)};postMessage(t,t.decompressed?[t.decompressed.buffer]:[])},"; postMessage({ ready: true });"];

    Anyone knows why this happened only in one specific browser?
     
  6. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I am not quite sure why that happens, however, I would be interested in knowing how that runs in WeChat browser :)
     
  7. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    Thanks for replying.

    Can I ask
    1. How will I know if the browser decompresses using javascript or browser built-in gzip decompression?

    2. Do I need to set header of every ".unityweb" to content-encoding to gzip? It seems even I didn't specify this, the browser will still decompress using gzip.

    3. Will browser built-in gzip decompression be faster than javascript decompression?

    4. Is there any tip reducing loading and initialization time after downloading? Right now even an empty project is taking at around 10s to load on a middle-end mobile phone. (my way to calculate loading time is start a timer between "addRunDependency" and "removeRunDependency", and then stop the timer in one of the Start() function in the scene).
     
    Last edited: Sep 20, 2017
  8. sqxaf

    sqxaf

    Joined:
    Oct 9, 2016
    Posts:
    1
    How to solve this problem?
     
  9. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    if using JS fallback, we usually print the following message in the browser log:
    "You can reduce your startup time if you configure your web server to host .unityweb files using gzip compression."
    You should set it up as described here.
    Yes.

    Does it improve if you enable WebAssembly?
     
  10. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    162
    Well, unity should fix this.

    Is very simple to fix but i must edit unityloader.js, by my self, everytime i made a new build.

    This bug happens in Chrome 50/Chrome 51 32 bits in Windows and in many other old browsers.
     
  11. AlexHell

    AlexHell

    Joined:
    Oct 2, 2014
    Posts:
    167
    Fix is not available yet?!
    We have encountered same problem in unity 5.6. If the fix will be in stable unity 2017 - may be we will migrate, but it's not expected to migrate now, we at release stage of our project, and encountered this error on winXP in chrome 49. The user not want to migrate from winXP, and chrome will not updates on winXP.

    Also is it acceptable for unity overall to work in chrome 49? Or in any case we will encounter any other problems?

    Is this code safe? Is it stable? For which unity version?

    I have found only this reference to "this.decompress" in minified Build\UnityLoader.js
    Code (CSharp):
    1. new Blob(["this.require = ",r.require.toString(),"; this.decompress = ",r.decompress.toString(),"; this.onmessage = ",function(e){var t={id:e.data.id,decompressed:this.decompress(e.data.compressed)};
    How to fix it?
     
    Last edited: Jun 9, 2019
  12. AlexHell

    AlexHell

    Joined:
    Oct 2, 2014
    Posts:
    167
    decompress using browser built-in gzip is work (I see encoding in response header), but NOT eliminates this error on user's machine in chrome 49. Cache is cleared, user reloads page and redownload unityweb, as he say.

    p.s. FIXED WITH HACK UnityLoader.js
     
    Last edited: Jun 12, 2019