Tracktion / choc

A collection of header only classes, permissively licensed, to provide basic useful tasks with the bare-minimum of dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Many calls to webviews evaluateJavascript causes front end to crash?

lucenta opened this issue · comments

I've noticed that if I call evaluateJavascript very frequently, the front end of the app crashes, thereby crashing the JUCE app. I'm trying to use this function to send audio data from my processor to webview (by calling a javascript function with the data as a parameter to the function). Is there a better way to do this other than evaluateJavascript? As a follow up, if this function threadsafe? I'm also calling it from multiple c++ threads, many times.

Thanks!

The context is very definitely NOT threadsafe, so no wonder that would crash!

The comments describing the Context object do make that clear, but if you got as far as posting here to ask the question, then I guess I should add more comments to make that more obvious.

..and although it's not clear from your comment whether you're calling javascript directly from your audio thread, that's also obviously a big no-no, as nothing in there is realtime safe.

(..actually, sorry - when I said there was already a comment, I was looking at the other javascript classes, not the WebView, which doesn't have any such comments - definitely need to add a warning there!)

Yes, not calling from the audio thread! Thanks a ton for the comment!