Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Bug Uncaught ReferenceError: unityFramework is not defined at HTMLScriptElement.script.onload (WebGL)

Discussion in '2020.1 Beta' started by hippocoder, Jan 5, 2020.

  1. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,734
    Any suggestions?

    Is WebGL is non functional in 2020.1 alpha?
     
  2. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    145
    Try to disable compression.
     
    Talmagett, balcides1 and isotian like this.
  3. TheCritters

    TheCritters

    Joined:
    Mar 23, 2015
    Posts:
    5
    Disabling compression worked for me: 2020.1.0.a.2166
     
    Talmagett, balcides1 and isotian like this.
  4. The_Unity_Cat

    The_Unity_Cat

    Unity Technologies

    Joined:
    Jun 12, 2017
    Posts:
    8
  5. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    214
  6. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    339
    The error occurs in both OSX and Windows standalone builds too using otherwise the same repro steps, reproducible / non-reproducible with the same 2020.1 alpha versions as the above logged bug @The_Unity_Cat
     
    Berz_ and Tarrag like this.
  7. ExtremeKaos

    ExtremeKaos

    Joined:
    Dec 4, 2016
    Posts:
    7
    Hi, with 2020.1 disable compression, in player "Publishing Settings" , Compresion Format and it works.
    The tracked bug is locked to vote up bug.

    Thanks @OneManArmy3D && @TheCritters
     
    specterdragon, Rasgefaanu and isotian like this.
  8. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    974
    should be fixed for 20.1a24
     
    hippocoder likes this.
  9. Syco753

    Syco753

    Joined:
    Feb 11, 2013
    Posts:
    25
    I fought with the same issue for days. Sometimes it worked, sometimes not. It stopped loading after 90%. After disabling the compression, the size increased from 60Mb to 80Mb but now it works. Thanks a lot.
    (I use Version 2020.1.0b2.3333)
     
    balcides1 likes this.
  10. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    974
    If you are still having this issue please do file a new bug report with a repro project and some extra info like what browsers you see this in, the browser log and any other extra info you can think of. Thanks!
     
  11. Graph

    Graph

    Joined:
    Jun 8, 2014
    Posts:
    148
    I've ran into the same issue in 2020.1b5 using webGL, trying to play it in opera

    edit: gzip crashes when i try to build, brotli crashes when i try to play.. webGL with compression has been broken for so long it's getting ridiculous when you consider that there's a 1-line workaround that could have been implemented
     
    Last edited: Apr 11, 2020
  12. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    34
    For us, it won't load even an empty project in 2020.1b5. (gzip or brotli)
    Turnining compression off solves it, but builds are too big.

    @Schubkraft when do you think this will be solved?

    As well as VideoPlayer from URL. Saw that it is on the known issues list.
     
  13. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    34
    We solved it partially by turning on gzip on the server.
    Build is still in uncompressed format, but what is sent from the server is now much smaller.
     
  14. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    208
    even with gzip enabled, Im still seeing unityFramework not defined.. Im on apache.. I looked at https://docs.unity3d.com/Manual/webgl-deploying.html but this hasnt helped fix the unityframework issue.

    PS I also noticed that the toggle full screen button doesnt show when on my website like it does when run from unity
     
    Last edited: Apr 23, 2020
  15. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,357
    Could be related to this issue: https://issuetracker.unity3d.com/product/unity/issues/guid/1229961/

    We'd have to look into your case though to be sure, so a bug report would be best.
     
    Last edited: Apr 24, 2020
  16. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    208
    @LeonhardP already did - but was hoping someone had some ideas - the full screen button issue went away with the new beta. However, I tried IE, edge, firefox and chrome and none seemed to like the compressed deployment
     
  17. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,357
    Could you please share the report ID here?
     
  18. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    208
    Hi, 1241196
     
    LeonhardP likes this.
  19. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,357
    Thanks, we'll have a look.
     
  20. kalineh

    kalineh

    Joined:
    Dec 23, 2015
    Posts:
    195
    Just reporting this still happens in 2020.1.0b7 (gzip compression fails with error).
     
  21. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    974
  22. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    208
    @Schubkraft it seems a very odd requirement to have a thing.js.gz need to report as uncompressed js - not everyone will have access to set this on their servers, and if it is gzipped as the extension implies, it would be correct for it to send it as something/gzip ...
     
  23. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    974
    I believe the difference lies between Content-Encoding (gzip for a gz zipped file) and Content-Type (application/javascript for the framework file).
     
  24. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Still hapenning in 2020.1.0b14
     
    bessa_unity and Ishnubarak like this.
  25. bessa_unity

    bessa_unity

    Joined:
    Jul 24, 2020
    Posts:
    1
    I have this problem in the version 2020.1.0f1. I have to tick the "Development build" option.
     
  26. bobcccc

    bobcccc

    Joined:
    Mar 12, 2014
    Posts:
    122
    still happening in 2020.2 had to remove compression for it to work too.
     
  27. eepUser

    eepUser

    Joined:
    Aug 23, 2017
    Posts:
    5
    Still hapenning in 2020.1.0f1
     
  28. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    208
    I did get mine to work. But I strongly feel the requirements for apache and iis are likely to cause issues on websites
     
  29. balcides1

    balcides1

    Joined:
    Jun 30, 2014
    Posts:
    9
    Updating to version 2020.1.2f1, still had this issue with Safari. Disabling compression fixed it.
     
  30. balcides1

    balcides1

    Joined:
    Jun 30, 2014
    Posts:
    9
    Thanks, worked like a charm.
     
    OneManArmy3D likes this.
  31. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    106
    What if I don't want to disable compression?? I need it T_T.
     
  32. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    145
    All you can do is wait... how long? who knows... as you can see, they are already trying to fix this bug 6+ months, so...
     
  33. unity_QTb-DngZr-5k5w

    unity_QTb-DngZr-5k5w

    Joined:
    Aug 26, 2020
    Posts:
    1
    This was the only solution i found only removing the compression didn't work for me, i was on the version 2020.1.0f1 and it worked after updating to the version 2020.1.3f1
     
  34. netkill

    netkill

    Joined:
    Feb 12, 2020
    Posts:
    3
    Same issue
     
    unnanego likes this.
  35. mrSaig

    mrSaig

    Joined:
    Jan 14, 2010
    Posts:
    49
    same issue with 2020.1.4f1
     
    Kronnect and unnanego like this.
  36. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    165
    same with 2020.1.4, disabling gzip seems to have helped
     
    julidr likes this.
  37. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    298
    Tried 2020.1.5 and 2020.2.0b2.

    • Using Gzip compression couldnot load eventough using new apache mime rules.
    • Disabled compression could load but getting the following from chrome :
    • Using Brotli on 2020.2.0b2, same error.
    Brotli and Gzip are throwing the same error when hosted remotely (not on localhost)
     
    Last edited: Sep 15, 2020
  38. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    106
    I could make it work on Amazon S3 and Netlify. You need to set custom headers for compression. You can see how I did it here. Any place you configure the headers just follow what I did for Netlify and it should work(well, I did it for Netlify, and it worked for Amazon S3 as well).
     
    siliwangi likes this.
  39. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    298
    @Marks4
    Thanks man, i made the changes to reflect your finding, managed to load it, but did you get the same errors as below from Chrome's developer tools? :
    The nginx rules :
    Code (csharp):
    1.  
    2.             location ~* \.(wasm)$ {
    3.             add_header Content-Type application/wasm;
    4.             }
    5.             location ~* \.(data.gz|symbols.json.gz)$ {
    6.             add_header Content-Encoding gzip;
    7.             add_header Content-Type application/octet-stream;
    8.             }
    9.             location ~* \.(wasm.gz)$ {
    10.             add_header Content-Encoding gzip;
    11.             add_header Content-Type application/wasm;
    12.             }
    13.             location ~* \.(js.gz)$ {
    14.             add_header Content-Encoding gzip;
    15.             add_header Content-Type application/javascript;
    16.             }
    17.  
     
    Diego_Graphics likes this.
  40. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    106
    I didn't get any errors at all. You're missing the configuration for *.js files. But other than that it seems ok.
     
  41. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    298
    Weird, they must doing a custom HTTPD, in nginx *.js is by default already defined in mime.types file/definition.
    Code (csharp):
    1.  
    2. application/javascript                           js;
    3.  
    Also i was already tried to define it also in above as :
    Code (csharp):
    1.  
    2. location ~* \.(js)$ {
    3. add_header Content-Type application/javascript;
    4. }
    5.  
    But the same errors logged, but managed to load the scene.

    Other weird things is, this apache mod_mime rules/.htaccess works flawlessly in localhost but getting errors if hosted remotely (remote server)
    Probably there is bug in the Unity WebGL loader?, perhaps it's all about timing?, but my remote server is only around below 100 ms apart from me.
     
  42. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    106
    Your best bet is try to get some help on the official Unity Discord. Sorry I can't help more.
     
  43. Jolan118

    Jolan118

    Joined:
    Oct 2, 2015
    Posts:
    2
    Any update in that case?
     
  44. Deonity

    Deonity

    Joined:
    May 16, 2018
    Posts:
    3
    Hello, is this all nginx rules for gz?

    Code (CSharp):
    1.  location ~ .+\.unityweb$ {
    2. root $root_path;
    3. add_header Content-Encoding gzip;
    4. add_header Content-Type application/octet-stream;
    5. }
    6. location ~* \.(wasm)$ {
    7.  add_header Content-Type application/wasm;
    8. }
    9. location ~* \.(data.gz|symbols.json.gz)$ {
    10. add_header Content-Encoding gzip;
    11. add_header Content-Type application/octet-stream;
    12.  }
    13. location ~* \.(wasm.gz)$ {
    14. add_header Content-Encoding gzip;
    15.  add_header Content-Type application/wasm;
    16.  }
    17.   location ~* \.(js.gz)$ {
    18.   add_header Content-Encoding gzip;
    19.   add_header Content-Type application/javascript;
    20.   }
     
  45. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    298
    @Deonity

    Found out the working nginx rules in here. Working without any errors, but only test it out on local, haven't tried on remote host. Also don't forget clear out all of your browser caches.
     
  46. vietman00

    vietman00

    Joined:
    Dec 27, 2018
    Posts:
    3
    I modified this from Unity's site:
    Notice i had to specify framework.js.gz as a mime extension

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <staticContent>
    <!--
    NOTE: IIS will throw an exception if a mimeType is specified multiple times for the same extension.
    To avoid possible conflicts with configurations that are already on the server, you should remove the mimeType for the corresponding extension using the <remove> element,
    before adding mimeType using the <mimeMap> element.
    -->
    <remove fileExtension=".data" />
    <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    <remove fileExtension=".wasm" />
    <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
    <remove fileExtension=".symbols.json" />
    <mimeMap fileExtension=".symbols.json" mimeType="application/octet-stream" />
    <!-- The following lines are required for builds compressed with gzip, which don't include decompression fallback. -->
    <remove fileExtension=".data.gz" />
    <mimeMap fileExtension=".data.gz" mimeType="application/octet-stream" />
    <remove fileExtension=".wasm.gz" />
    <mimeMap fileExtension=".wasm.gz" mimeType="application/wasm" />
    <remove fileExtension=".js.gz" />
    <mimeMap fileExtension=".js.gz" mimeType="application/javascript" />
    <remove fileExtension=".framework.js.gz" />
    <mimeMap fileExtension=".framework.js.gz" mimeType="application/javascript" />
    <remove fileExtension=".symbols.json.gz" />
    <mimeMap fileExtension=".symbols.json.gz" mimeType="application/octet-stream" />
    <!-- The following lines are required for builds compressed with Brotli, which don't include decompression fallback. -->
    <remove fileExtension=".data.br" />
    <mimeMap fileExtension=".data.br" mimeType="application/octet-stream" />
    <remove fileExtension=".wasm.br" />
    <mimeMap fileExtension=".wasm.br" mimeType="application/wasm" />
    <remove fileExtension=".js.br" />
    <mimeMap fileExtension=".js.br" mimeType="application/javascript" />
    <remove fileExtension=".symbols.json.br" />
    <mimeMap fileExtension=".symbols.json.br" mimeType="application/octet-stream" />
    </staticContent>

    <!--
    Hosting compressed Unity builds without decompression fallback relies on native browser decompression,
    therefore a proper "Content-Encoding" response header should be added for the compressed build files.
    NOTE: IIS will throw an exception if the following section is used without the "URL Rewrite" module installed.
    Download the "URL Rewrite" module from https://www.iis.net/downloads/microsoft/url-rewrite
    -->
    <rewrite>
    <outboundRules>
    <!--
    NOTE: IIS will throw an exception if the same rule name is used multiple times.
    To avoid possible conflicts with configurations that are already on the server, you should remove the mimeType for the corresponding extension using the <remove> element,
    before adding mimeType using the <mimeMap> element.
    -->
    <!-- The following section is required for builds compressed with gzip, which don't include decompression fallback. -->
    <remove name="Append gzip Content-Encoding header" />
    <rule name="Append gzip Content-Encoding header">
    <match serverVariable="RESPONSE_Content-Encoding" pattern=".*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" pattern="\.gz$" />
    </conditions>
    <action type="Rewrite" value="gzip" />
    </rule>
    <!-- The following section is required for builds compressed with Brotli, which don't include decompression fallback. -->
    <remove name="Append brotli Content-Encoding header" />
    <rule name="Append brotli Content-Encoding header">
    <match serverVariable="RESPONSE_Content-Encoding" pattern=".*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" pattern="\.br$" />
    </conditions>
    <action type="Rewrite" value="br" />
    </rule>
    </outboundRules>
    </rewrite>
    </system.webServer>
    </configuration>
     
  47. Dante_

    Dante_

    Joined:
    Apr 2, 2015
    Posts:
    14
    Guys you are all talking about disabling compression and nginx server etc..
    But I am just trying to send my webgl exported project to facebook. (as zip since it's required)
    I tried to host my game using wamp and it start perfectly.

    So I don't get why I am getting this error when the game is hosted by facebook...
     

    Attached Files:

  48. Nials

    Nials

    Joined:
    Oct 29, 2019
    Posts:
    4
    Got this issue as well with 2020.1.10f1. Removing compression fixes it. But it is a lot slower to laod.
     
    Last edited: Oct 27, 2020
  49. sd_zeus

    sd_zeus

    Joined:
    Mar 9, 2017
    Posts:
    14
    Got this issue as well with 2020.1.11f1c1 with Gzip compression whild upload to webserver , I am waiting for the solution urgently.
     
  50. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    614
    To currently fix this issue I'm doing a post process on the WebGL build to rename those compressed files.

    My post process file looks like this:
    Code (CSharp):
    1. #if UNITY_EDITOR && UNITY_WEBGL
    2. using System.IO;
    3. using System.Linq;
    4. using UnityEditor.Build;
    5. using UnityEditor.Build.Reporting;
    6. using UnityEngine;
    7.  
    8. public class WebGLPostProcess : IPostprocessBuildWithReport {
    9.   public int callbackOrder => 0;
    10.  
    11.   public void OnPostprocessBuild(BuildReport report) {
    12.     var data = report.files.FirstOrDefault(f => f.role == "Application Data").path;
    13.     var framework = report.files.FirstOrDefault(f => f.role == "WebAssembly Framework").path;
    14.     var code = report.files.FirstOrDefault(f => f.role == "WebAssembly Code").path;
    15.     RenameFilename(data, "data");
    16.     RenameFilename(framework, "framework");
    17.     RenameFilename(code, "wasm");
    18.   }
    19.  
    20.   static void RenameFilename(string path, string type) {
    21.     var ext = Path.GetExtension(path);
    22.     var filenameWithoutExt = Path.GetFileNameWithoutExtension(path);
    23.     var pathWithoutFilename = path.Trim($"{filenameWithoutExt}.{ext}".ToArray());
    24.     var newPath = filenameWithoutExt.Contains(type) ? path : $"{pathWithoutFilename}/{filenameWithoutExt}.{type}{ext}";
    25.     if (path != newPath) {
    26.       File.Move(path, newPath);
    27.       Debug.Log($"File {path} was renamed to {newPath}");
    28.     }
    29.   }
    30. }
    31. #endif
    Then i also had to create a new WebGL template for this to work. Just copy the default WebGL template from Unity installation folder and change the *index.html* file.
    Changes on the index.hml:
    Code (CSharp):
    1. var config = {
    2.         dataUrl: buildUrl + "/{{{ DATA_FILENAME.replace('.gz', '.data.gz').replace('.br', '.data.br') }}}",
    3.         frameworkUrl: buildUrl + "/{{{ FRAMEWORK_FILENAME.replace('.gz', '.framework.gz').replace('.br', '.framework.br') }}}",
    4.         codeUrl: buildUrl + "/{{{ CODE_FILENAME.replace('.gz', '.wasm.gz').replace('.br', '.wasm.br') }}}",
    5. #if MEMORY_FILENAME
    6.         memoryUrl: buildUrl + "/{{{ MEMORY_FILENAME }}}",
    7. #endif
    8. #if SYMBOLS_FILENAME
    9.         symbolsUrl: buildUrl + "/{{{ SYMBOLS_FILENAME }}}",
    10. #endif
    11.         streamingAssetsUrl: "StreamingAssets",
    12.         companyName: "{{{ COMPANY_NAME }}}",
    13.         productName: "{{{ PRODUCT_NAME }}}",
    14.         productVersion: "{{{ PRODUCT_VERSION }}}"
    15.       };
    I'm using nginx to serve my content and here is my server block:

    Code (CSharp):
    1. server {
    2.       listen 8080;
    3.       listen 8443 ssl;
    4.       server_name myWebGL;
    5.  
    6.       ssl_session_cache    shared:SSL:1m;
    7.       ssl_session_timeout  5m;
    8.  
    9.       ssl_ciphers  HIGH:!aNULL:!MD5;
    10.       ssl_prefer_server_ciphers  on;
    11.  
    12.       root /app;
    13.       location ~ .+\.unityweb$ {
    14.             add_header Content-Encoding gzip;
    15.       }
    16.  
    17.       location ~ .+\.wasm$ {
    18.             add_header Content-Encoding gzip;
    19.             default_type application/wasm;
    20.       }
    21.  
    22.       location ~* .(wasm.gz)$ {
    23.             gunzip on;
    24.             gzip off;
    25.             types {}
    26.             default_type application/wasm;
    27.             add_header Content-Encoding gzip;
    28.       }
    29.  
    30.       location ~* .(framework.gz|js.gz)$ {
    31.             gunzip on;
    32.             gzip off;
    33.             types {}
    34.             default_type application/javascript;
    35.             add_header Content-Encoding gzip;
    36.       }
    37.        
    38.       location ~* .(data.gz|symbols.json.gz)$ {
    39.             gunzip on;
    40.             gzip off;
    41.             types {}
    42.             default_type application/octet-stream;
    43.             add_header Content-Encoding gzip;
    44.       }
    45.  
    46.       location / {
    47.             index index.html index.htm;
    48.       }
    49. }
    50.  
    Hope this helps others until the filenames come out with correct naming when content is compressed.
     
    Last edited: Nov 4, 2020
unityunity