Search Unity

Question getBoundingClientRect problem in an angular application

Discussion in 'Web' started by rachdan, Nov 30, 2022.

  1. rachdan

    rachdan

    Joined:
    Jan 14, 2021
    Posts:
    4
    Hey,

    I have a SPA and on a page there is a Unity WebGL container. I build the project with Unity 2020.3.24f1 and it works fine.

    I upgraded to a newer version of Unity (2021.3.13f1), but a problem occurred. After I change to another page (leaving the unityscene) my browser's console log is spammed everytime I move the mouse.

    Code (JavaScript):
    1. Unhandled exception occurred: Cannot read properties of null (reading 'getBoundingClientRect')
    2. Stack: TypeError: Cannot read properties of null (reading 'getBoundingClientRect')
    I tried different ways (quit in ngOnDestroy, moved UnityInstance in a seperate service), but nothing helped to quit the Unity Instance fast/safe enough.

    Has anyone a solution for a Unity WebGL in an angular component?

    Thank you :)