X Tutup
Skip to content

Commit b20c79b

Browse files
committed
Fix qt.py and wxpython.py examples on Mac (cztomczak#442).
Enable external message pump to temporarily fix Issue cztomczak#442.
1 parent c760eb5 commit b20c79b

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

api/ApplicationSettings.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,13 @@ Downloads are handled automatically. A default `SaveAs` file dialog provided by
185185
(bool)
186186
Default: False
187187

188-
EXPERIMENTAL: So far this was tested only on Linux and actually made app
189-
significantly slower. Windows and Mac platforms were not
190-
tested yet. Reported issue in upstream, see
191-
[Issue #246](https://github.com/cztomczak/cefpython/issues/246)
192-
for details.
188+
This option is for use on Mac and Linux only. On Windows for best
189+
performance you should use a multi-threaded message loop instead
190+
of calling CefDoMessageLoopWork in a timer.
191+
192+
EXPERIMENTAL (Linux): There are issues with this option on Linux. See
193+
[Issue #246](https://github.com/cztomczak/cefpython/issues/246)
194+
for details.
193195

194196
It is recommended to use this option as a replacement for calls to
195197
cefpython.MessageLoopWork(). CEF Python will do these calls automatically
@@ -198,6 +200,14 @@ on Windows and Mac and resolves some bugs with missing keyboard events
198200
on these platforms. See [Issue #246](https://github.com/cztomczak/cefpython/issues/246)
199201
for more details.
200202

203+
IMPORTANT: Currently there are issues on Mac with both message loop work
204+
and external message pump. The working solution is to call
205+
a message loop work in a timer and enable external message pump
206+
both at the same time (an incorrect approach, but it works).
207+
This is just a temporary solution and how this affects
208+
performance was not tested. See [Issue #442](../../../issues/442)
209+
for more details.
210+
201211
Description from upstream CEF:
202212
> Set to true (1) to control browser process main (UI) thread message pump
203213
> scheduling via the CefBrowserProcessHandler::OnScheduleMessagePumpWork()

examples/qt.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@
7676
def main():
7777
check_versions()
7878
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
79-
cef.Initialize()
79+
settings = {}
80+
if MAC:
81+
# Issue #442 requires enabling message pump on Mac
82+
# and calling message loop work in a timer both at
83+
# the same time. This is an incorrect approach
84+
# and only a temporary solution.
85+
settings["external_message_pump"] = True
86+
cef.Initialize(settings)
8087
app = CefApplication(sys.argv)
8188
main_window = MainWindow()
8289
main_window.show()

examples/wxpython.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def main():
3333
check_versions()
3434
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
3535
settings = {}
36+
if MAC:
37+
# Issue #442 requires enabling message pump on Mac
38+
# and calling message loop work in a timer both at
39+
# the same time. This is an incorrect approach
40+
# and only a temporary solution.
41+
settings["external_message_pump"] = True
3642
if WINDOWS:
3743
# noinspection PyUnresolvedReferences, PyArgumentList
3844
cef.DpiAware.EnableHighDpiSupport()

0 commit comments

Comments
 (0)
X Tutup