gtk3 example not working

176 views
Skip to first unread message

jendri...@gmail.com

unread,
May 22, 2017, 4:58:47 PM5/22/17
to CEF Python
Hi there,

I get the following output when I run "python3 gtk3.py" and no window shows up:

[gkt3.py] CEF Python 57.0
[gkt3.py] Python 3.5.2 64bit
[gkt3.py] GTK 3.18
[0522/221555.374795:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain

The same happens for Python 2:

$ python gtk3.py
[gkt3.py] CEF Python 57.0
[gkt3.py] Python 2.7.12 64bit
[gkt3.py] GTK 3.18
[0522/225629.533477:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain

OS: Ubuntu 16.04
CEF Python revision: 25166136aaa4d5404092e4c24cee8c5ac041dd72

Any ideas about what could be going wrong?

Cheers,
Jendrik

Czarek Tomczak

unread,
May 23, 2017, 1:37:19 AM5/23/17
to CEF Python
It works fine for me with GTK 3.10 and Ubuntu 14.04. Is there any segmentation fault or other error? (besides the "Request for unknown.."). Try disabling GPU and see if it makes any difference: https://github.com/cztomczak/cefpython/blob/master/docs/Knowledge-Base.md#black-or-white-browser-screen

Related issues:
- https://github.com/cztomczak/cefpython/issues/261
- https://github.com/cztomczak/cefpython/issues/353

jendri...@gmail.com

unread,
May 23, 2017, 4:52:56 AM5/23/17
to CEF Python
There is no segmentation fault or error. Using "cef.Initialize(None, {'disable-gpu-compositing': '', 'disable-gpu-compositing': ''})" the "Request for unknown..." goes away, but still no window shows up.

I tried to debug this by figuring out which lines of code are executed. It seems the line "self.browser = cef.CreateBrowserSync(window_info, url="https://www.google.com/")" is where the problem occurs. The next line in the containing function "embed_browser" is never executed. The line depends on window_info, which in turn depends on self.get_handle(). The returned handle is 20971527.

Cheers,
Jendrik

Czarek Tomczak

unread,
May 23, 2017, 5:14:46 AM5/23/17
to CEF Python
Your problem looks similar to this (GTK 2 example): https://groups.google.com/d/topic/cefpython/IKfi_yrIOmY/discussion
In that topic the solution was to show window before embedding CEF browser inside it (already fixed in gtk2 example). If that fixes the problem it please submit a pull request for gtk3 example.

jendri...@gmail.com

unread,
May 23, 2017, 12:31:01 PM5/23/17
to CEF Python
I tried to show the window before embedding the browser, added a call to time.sleep() and tried a few other things, but nothing changed anything. If I comment out the line embedding the browser, the window shows up fine. I'm out of ideas now :-)

Czarek Tomczak

unread,
May 23, 2017, 12:51:25 PM5/23/17
to CEF Python
Have you moved the `self.window.show_all()` call before embed_browser()? You say that nothing changed anything, but in your first post you say that no window appears, but if you call show_all() you should see a window, even though CEF browser embedding fails. If you don't see a window it means showing it fails. It really looks to me like the GTK 2 issue I referenced. Using time.sleep() won't help because I think that function freezes the UI thread. If the window doesn't show then it means it needs some time for it to be realized. Try embedding browser with a 1 sec delay:

threading.Timer(1.0, self.embed_browser).start()

In CEF Python v58 you will be able to call:

cef.PostDelayedTask(cef.TID_UI, 1000, self.embed_browser)

Czarek Tomczak

unread,
May 23, 2017, 12:58:10 PM5/23/17
to CEF Python
Alternatively run two scripts, one without CEF embedding and print window handle, and second one with CEF embedded and with window handle hardcoded (the one printed from the other script).

jendri...@gmail.com

unread,
May 24, 2017, 4:11:56 AM5/24/17
to CEF Python
I tried the following things:

self.window.realize()
self.window.show_all()
self.embed_browser()
=> no window

self.window.realize()
self.window.show_all()
import threading
threading.Timer(1.0, self.embed_browser).start()
=> window appears, no embedded browser, then AssertionError: cefpython.CreateBrowserSync() may only be called on the UI thread

self.window.realize()
self.window.show_all()
GObject.timeout_add_seconds(1, self.embed_browser)
=> window appears, no embedded browser, window doesn't respond

The handle is always 69206023, so retrieving it is not the problem and hardcoding it has the same effect.

Czarek Tomczak

unread,
Jun 8, 2017, 8:02:18 AM6/8/17
to CEF Python
Have you tried running on a different machine? I cannot reproduce this.

Have you tried a different version of GTK3?

flo...@111studio.jp

unread,
Aug 15, 2017, 8:35:17 AM8/15/17
to CEF Python
Hi,

I'm afraid I'm running into the same issue. I'm running Arch Linux, here is the output of the example:

[Info] CEF Python 57.0
[Info] Python 3.6.2 64bit
[Info] GTK 3.22
[0815/212757.343553:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain


Here is an output running the script with --debug : https://pastebin.com/trPa1YXw

As a workaround I will downgrade my gtk3 version

Czarek Tomczak

unread,
Aug 15, 2017, 9:42:55 AM8/15/17
to CEF Python
The logs on pastebin suggest that the window handle passed to CreateBrowserSync (via WindowInfo) is invalid. Try embedding browser with some delay eg. 200ms after GTK window was realized and window handle returns a valid int value.

For posting a delayed call see https://groups.google.com/d/msg/cefpython/BINUFxCYzAk/BX9TExZBDgAJ

flo...@111studio.jp

unread,
Aug 15, 2017, 11:28:53 AM8/15/17
to CEF Python
Thank you for the reply,

I'm trying to implement it using

import threading
args = [cef.TID_UI, cef.CreateBrowserSync]
threading.Timer(0.2, cef.PostTask, args).start()

The issue is how do I get the returned value of cef.CreateBrowserSync since cef.PostTask returns void ?

Czarek Tomczak

unread,
Aug 15, 2017, 12:28:46 PM8/15/17
to CEF Python
This is just an example code how to use timer/posttask. In your case you should put "embed_browser" func to args to call it with a delay.

flo...@111studio.jp

unread,
Aug 15, 2017, 9:37:38 PM8/15/17
to CEF Python
Hi,

Here is my implementation with timer / posttask so far:

```
def on_activate(self, *_):
108 self.window.realize()
109 args = [cef.TID_UI, self.embed_browser]
110 threading.Timer(2, cef.PostTask, args).start()
111 self.window.show_all()
112 # Must set size of the window again after it was shown,
113 # otherwise browser occupies only part of the window area.
114 self.window.resize(*self.window.get_default_size())
115
116 def embed_browser(self):
117 window_info = cef.WindowInfo()
118 # TODO: on Mac pass rect[x, y, width, height] to SetAsChild
119 window_info.SetAsChild(self.get_handle())
120 self.browser = cef.CreateBrowserSync(window_info,
121 url="https://www.google.com/")
```

The debug log shows the same output, the window appears, but the browser is not showing.

Kind regards,

Florian

Czarek Tomczak

unread,
Aug 16, 2017, 1:23:17 AM8/16/17
to CEF Python
This issue needs to be debugged, and I can't debug it, because I can't reproduce it. Like I said in one of previous posts the errors in logs suggest the X11 window handle is invalid. You need to figure out why window handle provided by GTK3 is invalid and how to fix it. I thought about the GTK window not having enough time to be realized and suggested to postpone embedding browser.

Czarek Tomczak

unread,
Aug 16, 2017, 1:25:57 AM8/16/17
to CEF Python
Take a look at this comment:

# Must set size of the window again after it was shown,
# otherwise browser occupies only part of the window area.
self.window.resize(*self.window.get_default_size())

If you postponed the call to embed_browser() then you also need to postpone this call, for example by moving this code inside the body of the embed_browser method (at the end).

You're on your own in debugging this further.

Czarek Tomczak

unread,
Aug 23, 2017, 4:30:50 AM8/23/17
to CEF Python
Just FYI, I've created Issue 393 to track this. Please keep any further discussion on the Forum.


Reply all
Reply to author
Forward
0 new messages