emscripten-core / emscripten-core/emscripten

Crash in _emscripten_set_wheel_callback_on_thread

Open
#17,517 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

When my WASM code calls SDL_DestroyWindow, it proceeds to unregister various callbacks. As part of this it calls _emscripten_set_wheel_callback_on_thread, which throws an exception `null is not an object (evaluating 'target.onwheel')`, because `target` is null, because the canvas has already been removed from the DOM.

SDL_DestroyWindow is ultimately called from componentDidUnmount by Reactjs. The canvas is there at the time of SDL_DestroyWindow, but _emscripten_set_wheel_callback_on_thread is called asynchronously on the next tick (because of the _on_thread) and by that time the canvas is gone.

The offending line is:

https://github.com/emscripten-core/emscripten/blob/77da62969eb0b5efe4ce4a0c9ce67c45b9e32638/src/library_html5.js#L700

I think this line should check that target isn't null and do nothing if it is.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.