Invoke ExecuteJavaScript from multiple threads

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Invoke ExecuteJavaScript from multiple threads

Postby videoaudio » Tue Nov 17, 2015 11:56 pm

Hi,

In my application I am using ExecuteJavaScript calls to execute JS routines.
ExecuteJavaScript calls are being made from different threads (each thread invokes different JS routine using ExecuteJavaScript call) of my cef application running at browser process.
Till now I could not observe any issue or crash with the implementation.

My doubt is, will calling of ExecuteJavaScript from different threads (without serializing the calls to JS) can lead to any crashes or race conditions?
Or serializing of JS routine execution is already taken care inside cef.

Need your valuable suggestions.

Thanks.
videoaudio
Techie
 
Posts: 36
Joined: Tue Feb 17, 2015 10:08 am

Re: Invoke ExecuteJavaScript from multiple threads

Postby PolesApart » Wed Nov 18, 2015 8:10 am

The ExecuteJavaScript most likely sends an IPC message to (one of) the renderer process(es). Probably it's buffered (either in-process or in the IPC network level) and executed in order, a serialization by side-effect (if not by implementation). Assuming ExecuteJavaScript and the IPC layer is race-free, you should be fine. If not, you can use a mutex/spinlock/whatever around it, but I suspect you won't need it. Most IPC systems nowadays has race-free (atomic) message passing.

Of course, if I'm wrong, someone feel free to correct me, as I'm talking conceptually and not familiar with CEF's particular implementation intrinsics.
PolesApart
Mentor
 
Posts: 73
Joined: Fri Dec 05, 2014 1:24 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 79 guests