Search Unity

Bug Error when build and run on WebGL: TypeError: Cannot read properties of undefined (reading 'apply')

Discussion in 'Web' started by minhnguyen6418, Mar 6, 2023.

  1. minhnguyen6418

    minhnguyen6418

    Joined:
    Dec 3, 2022
    Posts:
    1
    I am building a Unity game and I have build and run it on iOS, Android, MacOS, Windows and all working fine. However, when I build and run the game on WebGL, I am encountering this error:
    Code (JavaScript):
    1. TypeError: Cannot read properties of undefined (reading 'apply') at Module._ _get_timezone (http://localhost:63337/Build/ web.framework.js.br:3:324937)
    2. at _tzset (http://localhost:63337/Build/ web.framework.js.br:3:76245)
    3. at _mktime (http://localhost:63337/Build/ web.framework.js.br:3:299687)
    4. at http://localhost:63337/Build/web.wasm.br:wasm-function [73753]:0×1533dc2
    5. at httn•lllanalhact.A2227/Duildluch
    I am using Unity 2021.3.12f1, I tried with 2023.1.0b6 and encountering the same issue.
    I did some searching on the internet, it seems like the method 'apply' is deprecated from jQuery 1.9 and above: https://stackoverflow.com/a/26659433
    So, it seems like when deploying to WebGL, Unity is using jQuery newer than 1.9 while the code is still calling a deprecated method.
    Does anyone know how to fix this? Or is there any version of Unity that doesn't have this issue?

    Screenshot:
     
    Last edited: Mar 6, 2023
  2. EnamulIslamJisan

    EnamulIslamJisan

    Joined:
    Oct 11, 2018
    Posts:
    93
    Can you show me your player settings?
     
  3. nguyenngocle2408

    nguyenngocle2408

    Joined:
    Nov 22, 2022
    Posts:
    1
    i'm the developer who posted this, let me know if you have anything to say thanks.
     

    Attached Files:

  4. Mccoyoo3

    Mccoyoo3

    Joined:
    Jul 5, 2018
    Posts:
    1

    Did you ever found a solution for this? I'm having the same problem.
     
  5. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    Could you submit a bug report with a sample project so I can dig into this?
    The issue is that mktime call that we shouldn't be reaching, I'd like to see if there's a C# API used that's calling it that we aren't handling correctly.
     
  6. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    Additionally, if you can make a development build, the error message should show a C# callstack that might be helpful in pinning down the issue, so you can share that as well.
     
  7. NikBezWork

    NikBezWork

    Joined:
    Feb 27, 2023
    Posts:
    1
    try clearing your browser cache, it seems to work for me
     
  8. Vecna

    Vecna

    Joined:
    Apr 2, 2014
    Posts:
    32
    Yes clearing browser cache does work, but I can't ask my players to do that every time.