cztomczak / cefpython

Python bindings for the Chromium Embedded Framework (CEF)
Other
3.07k stars 472 forks source link

Linux: Crash in Qt and wxPython examples during browser creation due to x11 FindChild() failing #452

Open cztomczak opened 6 years ago

cztomczak commented 6 years ago

This needs to be patched during next CEF Python release (internal patch or merged PR upstream).

Reported in upstream CEF tracker: https://bitbucket.org/chromiumembedded/cef/issues/2490/x11-findchild-fails-during-a-call-to

Reported problem on the CEF Forum: https://magpcss.org/ceforum/viewtopic.php?f=6&t=16203

Reproducible so far with the following examples:

The PyQt5 example works fine (Python 3.6, Ubuntu 14.04 same machine).

Stack trace for qt.py pyqt4 example running on Python 2.7.6 and Ubuntu 14.04:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff1d9e0bf in FindChild () at ../../cef/libcef/browser/native/window_x11.cc:44
44  ../../cef/libcef/browser/native/window_x11.cc: No such file or directory.
(gdb) bt
#0  0x00007ffff1d9e0bf in FindChild () at ../../cef/libcef/browser/native/window_x11.cc:44
#1  Show () at ../../cef/libcef/browser/native/window_x11.cc:178
#2  0x00007ffff1d9aa57 in CreateHostWindow ()
    at ../../cef/libcef/browser/native/browser_platform_delegate_native_linux.cc:89
#3  0x00007ffff1cb5879 in CreateHostWindow () at ../../cef/libcef/browser/browser_host_impl.cc:3159
#4  CreateInternal () at ../../cef/libcef/browser/browser_host_impl.cc:418
#5  0x00007ffff1cb436f in Create () at ../../cef/libcef/browser/browser_host_impl.cc:359
#6  0x00007ffff1cb3b3d in CreateBrowserSync () at ../../cef/libcef/browser/browser_host_impl.cc:275
#7  0x00007ffff046be21 in cef_browser_host_create_browser_sync ()
    at ../../cef/libcef_dll/cpptoc/browser_host_cpptoc.cc:94
#8  0x00007fffe743ad58 in CefBrowserHost::CreateBrowserSync(CefWindowInfo const&, scoped_refptr<CefClient>, CefStringBase<CefStringTraitsUTF16> const&, CefStructBase<CefBrowserSettingsTraits> const&, scoped_refptr<CefRequestContext>) ()
   from /usr/local/lib/python2.7/dist-packages/cefpython3/cefpython_py27.so
#9  0x00007fffffffcb70 in ?? ()
#10 0x0000000001067c50 in ?? ()
#11 0x00000000010406b0 in ?? ()
#12 0x00000000010406b0 in ?? ()
#13 0x00007fffe76f2fc0 in __pyx_v_14cefpython_py27_g_external_message_pump ()
   from /usr/local/lib/python2.7/dist-packages/cefpython3/cefpython_py27.so
#14 0x00000000009420a0 in ?? ()
#15 0x00007fffffffcd60 in ?? ()
#16 0x00007fffe24a4fc8 in ?? ()
#17 0x00007ffff7e7f8f0 in ?? ()
#18 0x0000000000000000 in ?? ()

Stack for qt.py pyside is the same.

Corresponding CEF source codes for the stack trace:

  1. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/native/window_x11.cc#L44
  2. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/native/window_x11.cc#L178
  3. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/native/browser_platform_delegate_native_linux.cc#L89
  4. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/browser_host_impl.cc#L3159
  5. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/browser_host_impl.cc#L418
  6. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/browser_host_impl.cc#L359
  7. https://github.com/chromiumembedded/cef/blob/3359/libcef/browser/browser_host_impl.cc#L275
cztomczak commented 6 years ago

PyQt4 and PySide examples disabled from auto running in commit cb9628b.

cztomczak commented 5 years ago

I've provided a patch that fixes the issue in upstream CEF. However this still needs testing with PyQt4 and PySide to see if that resolves the issue completely.

dee42 commented 5 years ago

This is biting me with wxPython 4 with GTK 3. Is there any way to work around the issue with cefpython 66? If not, when are you expecting the next cefpython release?

cztomczak commented 5 years ago

@dee42 You can build CEF 66 from sources and apply the patch. See the build instructions document and inject the patch via patches/patch.py script before building. There is no known schedule for the next release at the moment.

dee42 commented 5 years ago

@cztomczak Thanks. I've done so, but there seem to be knock-on issues. With that patch, I see a consistent segmentation fault which seems very similar to the crash reported here: https://magpcss.org/ceforum/viewtopic.php?f=6&t=16634. Traceback is:

(gdb) bt
#0  0x00007ffff352f2e1 in XRenderCreatePicture () at /usr/lib/libXrender.so.1
#1  0x00007fffef866298 in EndPaint() () at ../../components/viz/service/display_embedder/software_output_device_x11.cc:86
#2  0x00007fffef82d840 in FinishDrawingFrame() () at ../../components/viz/service/display/software_renderer.cc:66
#3  0x00007fffef803831 in DrawFrame() () at ../../components/viz/service/display/direct_renderer.cc:332
#4  0x00007fffef807402 in DrawAndSwap() () at ../../components/viz/service/display/display.cc:356
#5  0x00007fffef80949e in DrawAndSwap () at ../../components/viz/service/display/display_scheduler.cc:213
#6  0x00007fffef80949e in AttemptDrawAndSwap() () at ../../components/viz/service/display/display_scheduler.cc:487
#7  0x00007fffef808cda in OnBeginFrameDeadline() () at ../../components/viz/service/display/display_scheduler.cc:503
#8  0x00007fffee801a0d in Run () at ../../base/callback.h:95
#9  0x00007fffee801a0d in RunTask() () at ../../base/debug/task_annotator.cc:61
#10 0x00007fffee81dc6b in RunTask() () at ../../base/message_loop/message_loop.cc:395
#11 0x00007fffee81e2b5 in DeferOrRunPendingTask () at ../../base/message_loop/message_loop.cc:407
#12 0x00007fffee81e2b5 in DoWork() () at ../../base/message_loop/message_loop.cc:451
#13 0x00007fffee81f6ae in HandleDispatch () at ../../base/message_loop/message_pump_glib.cc:263
#14 0x00007fffee81f6ae in WorkSourceDispatch() () at ../../base/message_loop/message_pump_glib.cc:109
#15 0x00007ffff44d7cf4 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#16 0x00007ffff44d9b11 in  () at /usr/lib/libglib-2.0.so.0
#17 0x00007ffff44d9b51 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#18 0x00007fffee81f4a3 in base::MessagePumpGlib::Run(base::MessagePump::Delegate*) () at ../../base/message_loop/message_pump_glib.cc:305
#19 0x00007fffee83d788 in Run () at ../../base/run_loop.cc:133
#20 0x00007fffee83d788 in RunUntilIdle() () at ../../base/run_loop.cc:146
#21 0x00007fffee6a46bf in CefBrowserMessageLoop::DoMessageLoopIteration() () at ../../cef/libcef/browser/browser_message_loop.cc:116
#22 0x00007fffea6206a8 in __pyx_pw_14cefpython_py27_35MessageLoopWork(_object*, _object*) [clone .lto_priv.278] ()
    at python/lib/python2.7/site-packages/cefpython3/cefpython_py27.so
#23 0x00007ffff7ebba8d in call_function (oparg=<optimized out>, pp_stack=0x7fffffffc6e0) at Python/ceval.c:4360
#24 0x00007ffff7ebba8d in PyEval_EvalFrameEx (f=f@entry=0x7fffa40cb050, throwflag=throwflag@entry=0) at Python/ceval.c:3013
#25 0x00007ffff7ebe278 in PyEval_EvalCodeEx
    (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0, args=args@entry=0x7ffff6ec77b8, argcount=<optimized out>, kws=kws@entry=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3608
#26 0x00007ffff7e3a07b in function_call (func=0x7fffeacde320, arg=0x7ffff6ec77a0, kw=0x0) at Objects/funcobject.c:523
#27 0x00007ffff7e0d4a3 in PyObject_Call (func=func@entry=0x7fffeacde320, arg=arg@entry=0x7ffff6ec77a0, kw=kw@entry=0x0) at Objects/abstract.c:2544
#28 0x00007ffff7e1c4cc in instancemethod_call (func=0x7fffeacde320, arg=0x7ffff6ec77a0, kw=0x0) at Objects/classobject.c:2600
#29 0x00007ffff7e0d4a3 in PyObject_Call (func=func@entry=0x7ffff2b146e0, arg=arg@entry=0x7fffeacdc450, kw=0x0) at Objects/abstract.c:2544
#30 0x00007ffff7eb3d68 in PyEval_CallObjectWithKeywords (func=func@entry=0x7ffff2b146e0, arg=arg@entry=0x7fffeacdc450, kw=kw@entry=0x0) at Python/ceval.c:4245
#31 0x00007ffff62ab357 in wxPyCallback::EventThunker(wxEvent&) (this=<optimized out>, event=...) at ../../../../sip/cpp/sip_corewxEvtHandler.cpp:71
#32 0x00007ffff569906e in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) ()
    at python/lib/python2.7/site-packages/wx/libwx_baseu-3.0.so.0

Ever seen anything like this?

cztomczak commented 5 years ago

@dee42 No, first time seeing such error in CEF Python. Feel free to create a new issue for this error. Test with original wxpython.py example.

cztomczak commented 4 years ago

This is fixed in upstream CEF in v78+.

jorikdima commented 4 years ago

This is fixed in upstream CEF in v78+.

Czarek, I created a thread a year ago. Seems like now it's fixed in CEF. But when can we expect a new release of CEF python? If not soon what is my options? Should I rebuild existing CEF python against new CEF? But here you mentioned that versions should match, so 66 only as for today. Should I follow #264 like mentioned in the Notes? Otherwise I still can't use CEFpython with wxPython on Linux GTK3 Thank you