Description
Describe the bug
When using multiple independent libraries in JS Browser, that each bundle Kotlinx Coroutines, one of them might fail because it tries to use the WindowDispatcher
created by the other.
In the browser, the WindowDispatcher
is created once and stored on the global window
object as window.coroutineDispatcher
kotlinx.coroutines/kotlinx-coroutines-core/js/src/Window.kt
Lines 12 to 15 in 6e92c23
But the WindowDispatcher
from one library might not work with the WindowDispatcher
from the other because the function names got minified differently.
Provide a Reproducer
A sample project with instructions can be found in https://github.com/odzhychko/multiple-js-libs-with-coroutines
Thoughts
What would be the downsides to storing the WindowDispatcher on a static field instead, like in a classical singleton?
The property window.coroutineAnimationQueue
might have the same issues as window.coroutineDispatcher
.