Tracktion / choc

A collection of header only classes, permissively licensed, to provide basic useful tasks with the bare-minimum of dependencies.
Other
543 stars 49 forks source link

Many calls to webviews evaluateJavascript causes front end to crash? #33

Closed lucenta closed 12 months ago

lucenta commented 12 months ago

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!

julianstorer commented 12 months ago

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.

julianstorer commented 12 months ago

(..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!)

lucenta commented 12 months ago

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