question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I always receive the exception: Cannot read properties of null (reading 'getElementsByTagName')

See original GitHub issue

I’m using the WebGLInput script in my input field (it is a TMP_InputField), and when I test it in my WebGL build, just when I put the focus on the input textbox, the execution is frozen and I receive these error logs in the Chrome console:

Error logs

rollbar.min.js:1 exception thrown: TypeError: Cannot read properties of null (reading 'getElementsByTagName'),TypeError: Cannot read properties of null (reading 'getElementsByTagName')
    at _WebGLInputCreate (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:56004)
    at _WebGLInputPlugin_WebGLInputCreate_m285C4119EA43278205F4BBED9564AE827288F456 (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[127768]:0x200473a)
    at _WebGLInput_OnSelect_mA26F770E527D1E37BA62A28B7202E2491C9D5CDF (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[127767]:0x20044de)
    at _WebGLInput_Update_mB2E249ED9D67301C1B3993B0C6087CA81D2D4066 (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[127781]:0x2004b8b)
    at __Z65RuntimeInvoker_TrueVoid_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5PFvvEPK10MethodInfoPvPS4_ (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[126254]:0x1fdae04)
    at dynCall_iiiii (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[128463]:0x2020ef0)
    at Object.dynCall_iiiii (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:534043)
    at invoke_iiiii (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:365569)
    at __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[122183]:0x1f64817)
    at _il2cpp_runtime_invoke (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[120889]:0x1f3da08)
    at __Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[5531]:0x25722d)
    at __ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[5529]:0x256f19)
    at __ZN13MonoBehaviour16CallUpdateMethodEi (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12156]:0x48c0e0)
    at __ZN13MonoBehaviour6UpdateEv (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12128]:0x48ab8d)
    at __ZN20BaseBehaviourManager12CommonUpdateI16BehaviourManagerEEvv (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[14625]:0x5bbcc3)
    at __ZN13UpdateManager6UpdateEv (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[14624]:0x5bb9dc)
    at __ZZ23InitPlayerLoopCallbacksvEN41UpdateScriptRunBehaviourUpdateRegistrator7ForwardEv (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12656]:0x4bb30a)
    at __Z17ExecutePlayerLoopP22NativePlayerLoopSystem (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12272]:0x495b36)
    at __Z17ExecutePlayerLoopP22NativePlayerLoopSystem (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12272]:0x495b4b)
    at __Z10PlayerLoopv (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12260]:0x495688)
    at __ZL8MainLoopv (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[12248]:0x49396b)
    at dynCall_v (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.wasm.br?v=1653067972662:wasm-function[128569]:0x2021b7f)
    at Object.dynCall_v (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:547221)
    at browserIterationFunc (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:189514)
    at Object.runIter (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:192575)
    at Array.Browser_mainLoop_runner (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:408:191037)
    at tick (https://renderer-artifacts.decentraland.org/branch/fix/cjk-fonts-issues/unity.framework.js.br?v=1653067972662:363:28)
Uncaught TypeError: Cannot read properties of null (reading 'getElementsByTagName')
    at _WebGLInputCreate (unity.framework.js.br?v=1653067972662:408:56004)
    at _WebGLInputPlugin_WebGLInputCreate_m285C4119EA43278205F4BBED9564AE827288F456 (unity.wasm.br?v=1653067972662:0x200473a)
    at _WebGLInput_OnSelect_mA26F770E527D1E37BA62A28B7202E2491C9D5CDF (unity.wasm.br?v=1653067972662:0x20044de)
    at _WebGLInput_Update_mB2E249ED9D67301C1B3993B0C6087CA81D2D4066 (unity.wasm.br?v=1653067972662:0x2004b8b)
    at __Z65RuntimeInvoker_TrueVoid_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5PFvvEPK10MethodInfoPvPS4_ (unity.wasm.br?v=1653067972662:0x1fdae04)
    at dynCall_iiiii (unity.wasm.br?v=1653067972662:0x2020ef0)
    at Object.dynCall_iiiii (unity.framework.js.br?v=1653067972662:408:534043)
    at invoke_iiiii (unity.framework.js.br?v=1653067972662:408:365569)
    at __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException (unity.wasm.br?v=1653067972662:0x1f64817)
    at _il2cpp_runtime_invoke (unity.wasm.br?v=1653067972662:0x1f3da08)
    at __Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb (unity.wasm.br?v=1653067972662:0x25722d)
    at __ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb (unity.wasm.br?v=1653067972662:0x256f19)
    at __ZN13MonoBehaviour16CallUpdateMethodEi (unity.wasm.br?v=1653067972662:0x48c0e0)
    at __ZN13MonoBehaviour6UpdateEv (unity.wasm.br?v=1653067972662:0x48ab8d)
    at __ZN20BaseBehaviourManager12CommonUpdateI16BehaviourManagerEEvv (unity.wasm.br?v=1653067972662:0x5bbcc3)
    at __ZN13UpdateManager6UpdateEv (unity.wasm.br?v=1653067972662:0x5bb9dc)
    at __ZZ23InitPlayerLoopCallbacksvEN41UpdateScriptRunBehaviourUpdateRegistrator7ForwardEv (unity.wasm.br?v=1653067972662:0x4bb30a)
    at __Z17ExecutePlayerLoopP22NativePlayerLoopSystem (unity.wasm.br?v=1653067972662:0x495b36)
    at __Z17ExecutePlayerLoopP22NativePlayerLoopSystem (unity.wasm.br?v=1653067972662:0x495b4b)
    at __Z10PlayerLoopv (unity.wasm.br?v=1653067972662:0x495688)
    at __ZL8MainLoopv (unity.wasm.br?v=1653067972662:0x49396b)
    at dynCall_v (unity.wasm.br?v=1653067972662:0x2021b7f)
    at Object.dynCall_v (unity.framework.js.br?v=1653067972662:408:547221)
    at browserIterationFunc (unity.framework.js.br?v=1653067972662:408:189514)
    at Object.runIter (unity.framework.js.br?v=1653067972662:408:192575)
    at Array.Browser_mainLoop_runner (unity.framework.js.br?v=1653067972662:408:191037)
    at tick (unity.framework.js.br?v=1653067972662:363:28)

Chrome console screenshot

image

My input field configuration in Unity

image image

Unity version used

Unity 2020.3.0f1

Thanks in advance! 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

3reactions
KubilayHeterometacommented, Apr 14, 2023

error here: image

first there is a call to the method of container, and then a check for null

container.getElementsByTagName('canvas')[0] replace with document.getElementsByTagName('canvas')[0]

That solved my problem thx. I am using 2021.3.15f1. For the one who couldn’t find the file, it is “webgl-build.framework.js”. Which is one of the four files in your Build folder.

1reaction
sandrade-dclcommented, Sep 9, 2022

Finally I change the WebGLInput script, not on the webgl template You can find something like that on the script but th elif and else is set by commend, just delete the commend symbol Also see your webgl template canvasid is that same as the script to this. Hope this help

Yeah, after what @jmpy told me about the name of the div name, I looked for where in the code it was being used and I finally reached to the same solution that you suggest 😃 In my case I always use the name gameContainer for this div.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'getElementsByTagName' of null - ...
I'm trying to select elements with .getElementsByTagName() . var tags = document.body.getElementsByTagName("*");.
Read more >
Cannot read property 'getElementsByTagName' of null' ...
This could possibly happen if the list you are trying load contains fields such as comments and work notes that might contain a...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
Cannot read property 'getElementsByTagName' of null
I have been trying to extract xml data and use it to plot the graphs in JS but keep getting Cannot read property...
Read more >
HTML DOM Document getElementsByTagName() Method
The getElementsByTagName() method returns an HTMLCollection. The getElementsByTagName() property is read-only.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found