Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sandrade-dcl opened this issue May 20, 2022 · 11 comments

Comments

@sandrade-dcl
Copy link

sandrade-dcl commented May 20, 2022

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! :)

@jmpy
Copy link

jmpy commented Jun 2, 2022

@sandrade-dcl
If you have recently updated your Unity from 2019 it may be the same problem.
In my case, I solved the issue by changing the following part of the html template.

Before the change
<div id="unityContainer">
After the change
<div id="unity-container">

Hope this helps.

@sandrade-dcl
Copy link
Author

@sandrade-dcl If you have recently updated your Unity from 2019 it may be the same problem. In my case, I solved the issue by changing the following part of the html template.

Before the change <div id="unityContainer"> After the change <div id="unity-container">

Hope this helps.

Hey @jmpy, thanks for the workaround! I will try it! :)

@helmetica
Copy link

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]

@ronniechoyy
Copy link

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]

Where can change it? I'm happen this same issue

@fanling3
Copy link

fanling3 commented Sep 2, 2022

@sandrade-dcl If you have recently updated your Unity from 2019 it may be the same problem. In my case, I solved the issue by changing the following part of the html template.

Before the change <div id="unityContainer"> After the change <div id="unity-container">

Hope this helps.

Where can you find <div id="unityContainer">? I don't have this in my index.html..

@ronniechoyy
Copy link

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
image
to this
image
Hope this help

@sandrade-dcl
Copy link
Author

@sandrade-dcl If you have recently updated your Unity from 2019 it may be the same problem. In my case, I solved the issue by changing the following part of the html template.

Before the change <div id="unityContainer"> After the change <div id="unity-container">

Hope this helps.

It worked!! Thanks @jmpy 😄

@sandrade-dcl
Copy link
Author

sandrade-dcl commented 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.

@sandrade-dcl
Copy link
Author

It is definitively happening because of the name of the main div container... In my case, as I'm always using the name gameContainer for this div, I had to modify the WebGLInput code in order to set ALWAYS this name into WebGLInput.CanvasId and not others depending on the Unity version.

In my case I replaced this:

static WebGLInput()
 {
#if UNITY_2020_1_OR_NEWER
    WebGLInput.CanvasId = "unity-container";
#elif UNITY_2019_1_OR_NEWER
    WebGLInput.CanvasId = "unityContainer";
#else
    WebGLInput.CanvasId = "gameContainer";
#endif
    WebGLInputPlugin.WebGLInputInit();
}

by this:

static WebGLInput()
{
    WebGLInput.CanvasId = "gameContainer";
    WebGLInputPlugin.WebGLInputInit();
}

And it worked!

@KubilayHeterometa
Copy link

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.

@TreeBobber1
Copy link

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.

This should be referenced in how to install the WebGLInput because my god, I just spent 1 hour looking for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants