@@ -18,13 +18,13 @@ Table of contents:
18
18
* [ Hello world] ( #hello-world )
19
19
* [ Architecture] ( #architecture )
20
20
* [ Handling Python exceptions] ( #handling-python-exceptions )
21
- * [ Message loop] ( #message-loop )
22
21
* [ Settings] ( #settings )
23
22
* [ Change user agent string] ( #change-user-agent-string )
24
23
* [ Client handlers] ( #client-handlers )
25
24
* [ Javascript integration] ( #javascript-integration )
26
25
* [ Javascript exceptions and Python exceptions] ( #javascript-exceptions-and-python-exceptions )
27
26
* [ Plugins and Flash support] ( #plugins-and-flash-support )
27
+ * [ Message loop] ( #message-loop )
28
28
* [ Off-screen rendering] ( #off-screen-rendering )
29
29
* [ Build executable] ( #build-executable )
30
30
* [ Support and documentation] ( #support-and-documentation )
@@ -151,73 +151,17 @@ sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
151
151
See Python docs for [ sys.excepthook] ( https://docs.python.org/2/library/sys.html#sys.excepthook ) .
152
152
153
153
The cef.ExceptHook helper function does the following:
154
- 1 . Calls cef. [ QuitMessageLoop ] ( ../api/cefpython.md#quitmessageloop )
155
- 2 . Calls cef. [ Shutdown ] ( ../api/cefpython.md#shutdown )
156
- 3 . Writes exception to "error.log" file
157
- 4 . Prints exception
154
+ 1 . Writes exception to "error.log" file
155
+ 2 . Prints exception
156
+ 3 . Calls cef. [ QuitMessageLoop ] ( ../api/cefpython.md#quitmessageloop )
157
+ 4 . Calls cef. [ Shutdown ] ( ../api/cefpython.md#shutdown )
158
158
5 . Calls [ os._ exit(1)] ( https://docs.python.org/2/library/os.html#os._exit ) -
159
159
which exits the process with status 1, without calling
160
160
cleanup handlers, flushing stdio buffers, etc.
161
161
162
162
See CEF Python's ExceptHook source code in src/[ helpers.pyx] ( ../src/helpers.pyx ) .
163
163
164
164
165
- ## Message loop
166
-
167
- Message loop is a programming construct that waits for and
168
- dispatches events or messages in a program. All desktop GUI
169
- programs must run some kind of message loop. The hello_world.py
170
- example doesn't depend on any third party GUI framework and thus
171
- can run CEF message loop directly by calling cef.MessageLoop().
172
- However in other examples that embed CEF browser with GUI frameworks
173
- such as Qt/wxPython/Tkinter you can't call cef.MessageLoop(), because
174
- these frameworks run a message loop of its own. For such cases CEF
175
- provides cef.MessageLoopWork() which is for integrating CEF message
176
- loop into existing application message loop. Usually
177
- cef.MessageLoopWork() is called in a 10ms timer.
178
-
179
- ** Performance**
180
-
181
- Calling cef.MessageLoopWork() in a timer is not the best performant
182
- way to run CEF message loop, also there are known bugs on some
183
- platforms when calling message loop work in a timer. There are two
184
- options to increase performance depending on platform. On Windows
185
- use a multi-threaded message loop for best performance. On Mac use
186
- an external message pump for best performance.
187
-
188
- ** Windows: multi-threaded message loop**
189
-
190
- On Windows for best performance a multi-threaded message loop should
191
- be used instead of cef.MessageLoopWork() or external message pump. To do
192
- so, set ApplicationSettings.[ multi_threaded_message_loop] ( ../api/ApplicationSettings.md#multi_threaded_message_loop )
193
- to True and run a native message loop in your app. Don't call CEF's
194
- message loop. Create browser using ` cef.PostTask(cef.TID_UI, cef.CreateBrowserSync, ...) ` .
195
- Note that when using multi-threaded message loop, CEF's UI thread
196
- is no more application's main thread, and that makes it a bit harder
197
- to correctly use CEF API. API docs explain on which threads a function
198
- may be called and in case of handlers' callbacks (and other interfaces)
199
- it is stated on which thread a callback will be called. See also
200
- [ Issue #133 ] ( ../../../issues/133 ) .
201
-
202
- ** Mac: external message pump**
203
-
204
- CEF provides ApplicationSettings.[ external_message_pump] ( ../api/ApplicationSettings.md#external_message_pump )
205
- option for running an external message pump that you should use for
206
- best performance and to get rid of some bugs that appear when using
207
- cef.MessageLoopWork() in a timer.
208
-
209
- This option is currently marked experimental as it wasn't yet fully
210
- tested. This option should work good on Mac - in upstream CEF it was
211
- tested mainly on Mac. If you've successfully used this option on Mac
212
- please let us know on the Forum.
213
-
214
- ** Linux**
215
-
216
- External message pump option is not recommended to use on Linux,
217
- as during testing it actually made app x2 slower - it's a bug in
218
- upstream CEF. See [ Issue #246 ] ( ../../../issues/246 ) for more details.
219
-
220
-
221
165
## Settings
222
166
223
167
CEF settings are provided in multiple ways. There are global
@@ -520,6 +464,62 @@ For the old CEF Python v31 release instructions for enabling Flash
520
464
support are available on Wiki pages.
521
465
522
466
467
+ ## Message loop
468
+
469
+ Message loop is a programming construct that waits for and
470
+ dispatches events or messages in a program. All desktop GUI
471
+ programs must run some kind of message loop. The hello_world.py
472
+ example doesn't depend on any third party GUI framework and thus
473
+ can run CEF message loop directly by calling cef.MessageLoop().
474
+ However in other examples that embed CEF browser with GUI frameworks
475
+ such as Qt/wxPython/Tkinter you can't call cef.MessageLoop(), because
476
+ these frameworks run a message loop of its own. For such cases CEF
477
+ provides cef.MessageLoopWork() which is for integrating CEF message
478
+ loop into existing application message loop. Usually
479
+ cef.MessageLoopWork() is called in a 10ms timer.
480
+
481
+ ** Performance**
482
+
483
+ Calling cef.MessageLoopWork() in a timer is not the best performant
484
+ way to run CEF message loop, also there are known bugs on some
485
+ platforms when calling message loop work in a timer. There are two
486
+ options to increase performance depending on platform. On Windows
487
+ use a multi-threaded message loop for best performance. On Mac use
488
+ an external message pump for best performance.
489
+
490
+ ** Windows: multi-threaded message loop**
491
+
492
+ On Windows for best performance a multi-threaded message loop should
493
+ be used instead of cef.MessageLoopWork() or external message pump. To do
494
+ so, set ApplicationSettings.[ multi_threaded_message_loop] ( ../api/ApplicationSettings.md#multi_threaded_message_loop )
495
+ to True and run a native message loop in your app. Don't call CEF's
496
+ message loop. Create browser using ` cef.PostTask(cef.TID_UI, cef.CreateBrowserSync, ...) ` .
497
+ Note that when using multi-threaded message loop, CEF's UI thread
498
+ is no more application's main thread, and that makes it a bit harder
499
+ to correctly use CEF API. API docs explain on which threads a function
500
+ may be called and in case of handlers' callbacks (and other interfaces)
501
+ it is stated on which thread a callback will be called. See also
502
+ [ Issue #133 ] ( ../../../issues/133 ) .
503
+
504
+ ** Mac: external message pump**
505
+
506
+ CEF provides ApplicationSettings.[ external_message_pump] ( ../api/ApplicationSettings.md#external_message_pump )
507
+ option for running an external message pump that you should use for
508
+ best performance and to get rid of some bugs that appear when using
509
+ cef.MessageLoopWork() in a timer.
510
+
511
+ This option is currently marked experimental as it wasn't yet fully
512
+ tested. This option should work good on Mac - in upstream CEF it was
513
+ tested mainly on Mac. If you've successfully used this option on Mac
514
+ please let us know on the Forum.
515
+
516
+ ** Linux**
517
+
518
+ External message pump option is not recommended to use on Linux,
519
+ as during testing it actually made app x2 slower - it's a bug in
520
+ upstream CEF. See [ Issue #246 ] ( ../../../issues/246 ) for more details.
521
+
522
+
523
523
## Off-screen rendering
524
524
525
525
Off-screen rendering, in short OSR, also known as windowless
0 commit comments