emscripten-core / emscripten-core/emscripten

Crash in _emscripten_set_wheel_callback_on_thread

オープン
#17,517 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
27.6k
フォーク
3.6k
平均マージ
1日 14時間
マージ済み PR(30日)
125

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/library_html5.js の _emscripten_set_wheel_callback_on_thread 内にある参照された行から開始し、callback のターゲットがどのように取得されるかを調べます。React が canvas を削除した後の SDL_DestroyWindow パスを再現し、その後、ターゲットが存在しない場合でも callback のクリーンアップ中に例外が発生しなくなったことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react, wasm
領域
frontend, web-dev
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。