I'm trying to run a background task using a worker and display a message when an exception is caught.
Here's a minimal reproducible example:
package example
import kotlin.native.concurrent.TransferMode
import kotlin.native.concurrent.Worker
import libui.ktx.*
fun main() = appWindow("Test", 800, 600) {
vbox {
button("Test") {
action {
Worker.start().execute(TransferMode.UNSAFE, {}) {
MsgBox("This doesn't work")
}
}
}
}
}
That fails with this error when clicking the button:
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
at ThrowIncorrectDereferenceException (0x232c5c)
at kfun:example.$<bridge-UNNN>main$lambda-2$<anonymous>_3_6$<anonymous>_5_8(kotlin.Unit)#internal (0x2485c0)
at _ZN6Worker19processQueueElementEb (0x25d2ac)
at _ZN12_GLOBAL__N_113workerRoutineEPv (0x25d96d)
at (0x7f70ac741422)
at clone (0x7f70ac656bf3)
at ((nil))
- platform:
Linux x86_64
- kotlin:
1.3.72
- kotlin-libui:
0.1.7
- coroutines:
1.3.5-native-mt
I'm trying to run a background task using a worker and display a message when an exception is caught.
Here's a minimal reproducible example:
That fails with this error when clicking the button:
Linux x86_641.3.720.1.71.3.5-native-mt