Callbacks vs Functions results (CEF3 vs CEF1)

155 views
Skip to first unread message

ric...@gmail.com

unread,
Apr 28, 2015, 9:36:21 PM4/28/15
to cefp...@googlegroups.com
As I was porting an older CEF Python project to the lastest version, (from cef1 to cef3), I noticed that all the areas I used to get function returns from, are now callbacks. Even frame.GetSource() has been changed to work as a callback, instead of as a function that returns data.

Why the change from function results to callbacks?
Does this have to do with cef3 specs, or the change is for some other reason like performance, etc.

ric...@gmail.com

unread,
May 2, 2015, 2:04:08 PM5/2/15
to cefp...@googlegroups.com, ric...@gmail.com
Still waiting on a response about WHY the change occurred, but I can tell what I've discovered so far, during my transfer of projects.

The older CEF Python which ran CEF 1, got it's values from function returns. So if you called a python function within Javascript, the Javascript would wait until Python returns a value. This is very convenient for coding purposes, but caused trouble with timing related issues. Since the JS is waiting, any heavy loops, or never-ending loops would cause JS to wait and hang. A work-around I discovered is to use Javascript to handle timers. Not ideal, but it works.

The latest CEF Python runs CEF 3, which sends Python data to Javascript via Callbacks or direct JS calls. In this manor Python will communicate with Javascript, whenever it wants, and is not dependent on what the JS is doing. While not as simple to code for as a return value, it frees the Python to run at whatever rate it wants (fast/slow), and is not slowed down by the Javascript. JS Timers are not needed, and you can simply use Python threads to handle timers and such.

So CEF 1vs3 IMO, is like a single threaded app vs a multi-threaded app. The multi-threaded is not as easy to code, but provides the performance you want.

Czarek Tomczak

unread,
May 13, 2015, 1:02:29 PM5/13/15
to cefp...@googlegroups.com
Sorry for the late response. CEF 3 uses a multi process architecture and communication between processes (renderer/js <> browser) occurs asynchronously. Thus the need for async callbacks.


--
You received this message because you are subscribed to the Google Groups "CEF Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefpython+...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefpython.
To view this discussion on the web visit https://groups.google.com/d/msgid/cefpython/2a460d4a-6619-4aac-a689-440a208fe6b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages