Skip to content

Unity WebGL Build Throws Exception if Unmounted Before Load Completion #584

@sabarishr-dev

Description

@sabarishr-dev

Please avoid duplicates

Language and Compiler

TypeScript's built-in 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?

I don't know

React-Unity-WebGL Version

9.8.0

React Version

Next Js 15.3.2

Unity Version

2022.3.19f1

What happened?

When navigating away from the page or unmounting the Unity WebGL component before the Unity build loads, an error alert appears.

Image

Error :

builds.framework.js:1294 Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
at Object.registerOrRemoveHandler (builds.framework.js:1294:197539)
at registerKeyEventCallback (builds.framework.js:1294:225340)
at _emscripten_set_keydown_callback_on_thread (builds.framework.js:1294:225484)
at builds.wasm:0x214dba8
at builds.wasm:0x216830d
at Module._main (builds.framework.js:1294:334358)
at callMain (builds.framework.js:1294:428539)
at doRun (builds.framework.js:1294:428986)
at run (builds.framework.js:1294:429158)
at runCaller (builds.framework.js:1294:428198)
at Object.removeRunDependency (builds.framework.js:1294:17133)
at builds.framework.js:1294:1913
at doCallback (builds.framework.js:1294:108932)
at done (builds.framework.js:1294:109086)
at IDBTransaction. (builds.framework.js:1294:102738)

Reproducible test case

Steps to Reproduce:

  1. Start loading the Unity WebGL content (the Unity component mounts and begins initialization).
  2. Within about one / two seconds after Unity starts loading-but, before it finishes initializing or fully loads - navigate away from the page (for example, trigger a route change or unmount the Unity component).

Would you be interested in contributing a fix?

  • yes, I would like to contribute a fix

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions