Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use MsgBox in worker #34

Open
ObserverOfTime opened this issue Jul 8, 2020 · 0 comments
Open

Can't use MsgBox in worker #34

ObserverOfTime opened this issue Jul 8, 2020 · 0 comments

Comments

@ObserverOfTime
Copy link

ObserverOfTime commented Jul 8, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant