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 Cannot set properties of undefined (setting '1') when running a UnityWebRequest

Discussion in 'WebGL' started by ctterrab, Mar 4, 2022.

  1. ctterrab

    ctterrab

    Joined:
    Feb 17, 2022
    Posts:
    2
    Hi,

    We've found that if using Unity 2022 beta with BestHttp2 added to the project that any UnityWebRequest made will result in a type error in the browser. Tested on 2022.1.0b2 & 2022.1.0b10 and issue persists, on 2020 LTS problem does not appear.

    We've gone ahead and created a bug ticket but would be great to know if anyone else has come across this and found a resolution.

    Log excerpts:
    Console:

    Build 2.loader.js:70 exception thrown: TypeError: Cannot set properties of undefined (setting '1'),TypeError: Cannot set properties of undefined (setting '1')
    at _JS_WebRequest_Create (http://localhost:57156/Build/Build 2.framework.js:2799:40)

    Framework.js

    function _JS_WebRequest_Create(url, method) {
    var _url = UTF8ToString(url);
    var _method = UTF8ToString(method);
    var abortController = new AbortController();
    var requestOptions = {
    url: _url,
    init: {
    method: _method,
    signal: abortController.signal,
    headers: {}
    }
    };
    wr.abortControllers[wr.nextRequestId] = abortController; **Error here
    wr.requests[wr.nextRequestId] = requestOptions;
    return wr.nextRequestId++;
    }
     
  2. jackcrosa

    jackcrosa

    Joined:
    Oct 16, 2012
    Posts:
    22
    Same bug. Did u find any fix?
     
  3. Apollo-Meijer

    Apollo-Meijer

    Joined:
    Mar 30, 2015
    Posts:
    31
    I got the same issue and also using BestHttp2. got any update?
     
  4. smilefr

    smilefr

    Joined:
    Dec 4, 2010
    Posts:
    108
    Hi guys, I managed to fix the problem by changing the WebGL.framework.js file in the Build folder:
    Replace this line:
    Code (JavaScript):
    1.  
    2. var wr = { requestInstances: {}, nextRequestId: 1, loglevel: 2 };
    3.  
    with
    Code (JavaScript):
    1.  
    2. var wr = { requestInstances: {}, nextRequestId: 1, loglevel: 2, responses:{}, timer:{}, requests:{}, abortControllers:{} };
    3.  
    I suggest unminifying the code to make it easier to read.
    Hope this helps!
     
  5. sofianehamza

    sofianehamza

    Joined:
    Feb 13, 2017
    Posts:
    19
    I am having the same bug with unity web requests as well as besthttp2....
     
  6. sofianehamza

    sofianehamza

    Joined:
    Feb 13, 2017
    Posts:
    19


    Thanks a lot.... you saved my day
     
  7. wang-dong

    wang-dong

    Joined:
    Mar 17, 2017
    Posts:
    2
    Why can't I find the file WebGL.framework.js, can you tell me where this file is?
     
  8. wang-dong

    wang-dong

    Joined:
    Mar 17, 2017
    Posts:
    2
    upload_2022-6-8_13-42-34.png
    My error is like this
     
  9. potatosquadgames

    potatosquadgames

    Joined:
    Apr 16, 2017
    Posts:
    2
    upload_2022-6-14_6-47-19.png
    I think this is it!
    WebGL.framework.js is files has .jslib extension
    It worked for me!
    Thank smilefr
     
    Last edited: Jun 14, 2022
  10. tester_unity474

    tester_unity474

    Joined:
    May 18, 2020
    Posts:
    1
  11. westsavage

    westsavage

    Joined:
    Jan 24, 2022
    Posts:
    1
    Thank you ,your guys , you save me lots of time
     
  12. mowax74

    mowax74

    Joined:
    Mar 3, 2015
    Posts:
    94
    Got the same error in 2021.3.9f1 - your solution fixed it for me. Thank you so much!
    But hopefully unity is fixing this too anyway and this is not another workaround to remember for years now.
     
  13. duetgames

    duetgames

    Joined:
    May 22, 2018
    Posts:
    1
     
  14. AnKOu

    AnKOu

    Joined:
    Aug 30, 2013
    Posts:
    123
    Hope you found out since then but if anyone else is having the same trouble... You need to build without compression. Otherwise, the file is embeded and you can't read and modify it.

    upload_2022-11-16_16-3-51.png