Bug 1799173 Comment 6 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

State something I found.

1. [WorkerRunnable::PreDispatch() checks if the current thread has the permit to modify the busy count of the target thread.](https://searchfox.org/mozilla-central/rev/0062309958c212504556ae21a7e3eb120c9bd093/dom/workers/WorkerRunnable.cpp#77-80)  For the case WorkerThreadModifyBusyCount and WorkerThreadUnchangedBusyCount, we only allow its parent thread to dispatch the WorkerRunnable. That means for the top-level worker, it is the main thread, otherwise, it should be its parent worker thread.
2. [CreateImageBitmapFromBlob::OnImageReady() is only allowed to run on the main thread](https://searchfox.org/mozilla-central/rev/0062309958c212504556ae21a7e3eb120c9bd093/dom/canvas/ImageBitmap.cpp#1981) even though CreateImageBitmap can be triggered a worker thread.
3. When doing a CreateImageBitmap in a nested worker. CreateImageBitmapFromBlob::OnImageReady runs on the main thread and tries to [dispatch a WorkerRunnable to the nested worker to complete the work.](https://searchfox.org/mozilla-central/rev/0062309958c212504556ae21a7e3eb120c9bd093/dom/canvas/ImageBitmap.cpp#2092,2109) However, this violates the limitation of 1. Then we hit the assertion.

It seems we should not limit WorkerRunnable dispatching in this way. But I need some time to figure out what is a reasonable solution for this.
State something I found.

1. [WorkerRunnable::PreDispatch() checks if the current thread has the permit to modify the busy count of the target thread.](https://searchfox.org/mozilla-central/rev/0062309958c212504556ae21a7e3eb120c9bd093/dom/workers/WorkerRunnable.cpp#77-80)  For the case WorkerThreadModifyBusyCount and WorkerThreadUnchangedBusyCount, we only allow its parent thread to dispatch the WorkerRunnable. That means for the top-level worker, it is the main thread, otherwise, it should be its parent worker thread.
2. [CreateImageBitmapFromBlob::OnImageReady() is only allowed to run on the main thread](https://searchfox.org/mozilla-central/rev/0062309958c212504556ae21a7e3eb120c9bd093/dom/canvas/ImageBitmap.cpp#1981) even though CreateImageBitmap can be triggered from a worker thread.
3. When doing a CreateImageBitmap in a nested worker. CreateImageBitmapFromBlob::OnImageReady runs on the main thread and tries to [dispatch a WorkerRunnable to the nested worker to complete the work.](https://searchfox.org/mozilla-central/rev/0062309958c212504556ae21a7e3eb120c9bd093/dom/canvas/ImageBitmap.cpp#2092,2109) However, this violates the limitation of 1. Then we hit the assertion.

It seems we should not limit WorkerRunnable dispatching in this way. But I need some time to figure out what is a reasonable solution for this.

Back to Bug 1799173 Comment 6