webview
webview copied to clipboard
crash in thread
trafficstars
nim --threads:on c xx.nim
var
w=newWebView("test", getAppDir() & "/test.html")
thr : array[0..0, Thread[tuple[a, b:int]]]
proc threadFunc(args:tuple[a, b:int]) {.thread.}=
discard eval(w, "alert('hello')") #Crash Crash Crash
discard eval(w, "alert('hello')") # OK Ok Ok
createThread(thr[0],threadFunc,(0,0))
joinThreads(thr)
w.run()
w.exit()
According to https://github.com/zserge/webview/tree/0.1.1#api-1 (at the end), you must use the dispatch proc, when you want to eval from a background thread. However, it seems like dispatch cannot be called from a thread, because it's not GCsafe. Is there any workaround?