webview icon indicating copy to clipboard operation
webview copied to clipboard

crash in thread

Open SongTianZuo opened this issue 5 years ago • 1 comments
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()

SongTianZuo avatar Mar 03 '20 14:03 SongTianZuo

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?

TheSimpleZ avatar Mar 15 '20 21:03 TheSimpleZ