react-unity-webgl: Unity 2021.2 build throws error when removing the canvas before invoking Quit on the Unity Instance
Please avoid duplicates
- I checked all open issues and discussions and none of them matched my problem.
Language and Compiler
Other TypeScript compiler
What environment are you using?
Local Development Server
When does your problem occur?
When the Unity Component unmounts
What does your problem relate to?
The problem seems Unity related
React-Unity-WebGL Version
latest
React Version
latest
Unity Version
2021.2
What happened?
Problem occurs within and outside of this module. An error is thrown when the canvas element is removed before invoking the Quit method on the Unity Instance.
TypeError: null is not an object (evaluating 'target.onwheel')
_emscripten_set_wheel_callback_on_thread@http://127.0.0.1:8080/Build/unity.framework.js
Reproducible test case
- Create a Unity WebGL build
- Add a button to the index.html which removed the Canvas element and than Quit’s Unity
- Run the application on a web server and click the button
- See error
Would you be interested in contributing a fix?
- yes, I would like to contribute a fix
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 23 (5 by maintainers)
Commits related to this issue
- Fix issue https://github.com/jeffreylanters/react-unity-webgl/issues/250 where calling emscripten_set_wheel_callback() on an event target that does not exist would result in the page throwing an excep... — committed to juj/emscripten by juj 4 years ago
- Fix issue https://github.com/jeffreylanters/react-unity-webgl/issues/250 where calling emscripten_set_wheel_callback() on an event target that does not exist would result in the page throwing an excep... — committed to juj/emscripten by juj 4 years ago
- Fix issue https://github.com/jeffreylanters/react-unity-webgl/issues/250 where calling emscripten_set_wheel_callback() on an event target that does not exist would result in the page throwing an excep... — committed to juj/emscripten by juj 4 years ago
- Fix issue https://github.com/jeffreylanters/react-unity-webgl/issues/250 where calling emscripten_set_wheel_callback() on an event target that does not exist would result in the page throwing an excep... — committed to juj/emscripten by juj 4 years ago
- Fix emscripten_set_*_callback() to return EMSCRIPTEN_RESULT_UNKNOWN_TARGET if the target is not known. (#18977) * Fix issue https://github.com/jeffreylanters/react-unity-webgl/issues/250 where callin... — committed to emscripten-core/emscripten by juj 4 years ago
It’s a double problem…
assuming you have a unityContext var and a state var “isLoaded”… the following is a fix.
I fixed this issue. https://github.com/jeffreylanters/react-unity-webgl/discussions/412
There is a suggested workaround in the Unity forums. Haven’t tried yet but it is worth checking out.
https://forum.unity.com/threads/ionic-webgl-out-of-memory-on-quit.1244074/#post-8224548
hey @jeffreylanters looks like the Unity ticket is Closed.
@SashaVigneron1 I’m wrestling with this as well. I can explicitly call unityContext.quitUnityInstance() with a button on my page but when trying to handle the browser navigation I’m not able to work around it. .
Hey, thanks for the report. This issue reached my attention only now, we had not unfortunately received actionable bug reports about the issue before.
Bugfix to the JS exception in
_emscripten_set_wheel_callback_on_threadis available in the above Emscripten PR.Reading this issue tracker, there seem to be several Unity-related issues collated into a few common threads, that are unclear whether they are of the same root cause. I would recommend raising minimal bug reports directly to either Unity or Emscripten about issues that have been triaged to relate to problem in their domain. That way we can ensure the best way that there will be progress made in the correct repository without requiring other repositories to persist workarounds indefinitely.
Docs seem to leave out how to unmount the canvas/quit the unity instance.
Is this something thats not currently enabled?
Trying to unmount the unity engine/quit it (child webgl renderer component) when my modal closes (parent component).