<div dir="ltr">Hi Uli,<div><br></div><div>Many thanks for the response.</div><div><br></div><div>As of today I'm using cairo-image + xcb-shm and the bug seems to be gone.</div><div><br></div><div>Regards,</div><div>Alexandre</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 16, 2017 at 10:46 AM, Uli Schlachter <span dir="ltr"><<a href="mailto:psychon@znc.in" target="_blank">psychon@znc.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On 12.12.2017 14:47, Alexandre Bique wrote:<br>
> I'm improving the Linux port of the u-he plugins (<a href="http://www.u-he.com" rel="noreferrer" target="_blank">www.u-he.com</a>) and I was<br>
> using Xlib before but I've switched to xcb now, and I'm using cairo-xcb<br>
> instead of cairo-xlib for the painting.<br>
><br>
> While using the cairo-xcb backend I've come across the following assertion:<br>
><br>
> cairo-xcb-screen.c:219: _get_screen_index: Assertion `!"reached"' failed.<br>
><br>
> I've looked at the source code and I was surprised to see that the<br>
> cairo-xcb backend has global variables (mutex, list of<br>
> cairo_xcb_connection, ...), and I wonder if this is the issue in my case.<br>
<br>
</span>cairo-xlib has such global data as well. When you create two cairo<br>
surfaces for the same XCB connection, you want cairo to initialise<br>
"everything" just once.<br>
<span class=""><br>
> The application I'm working on is a software synthesizer plugin (VST2/VST3)<br>
> which a Digital Audio Workstation like Bitwig Studio (<a href="http://www.bitwig.com" rel="noreferrer" target="_blank">www.bitwig.com</a>) can<br>
> use and display.<br>
><br>
> The DAW loads the plugins, can show the plugin window (using XEmbed), hide<br>
> or close the plugin window. In case the plugin window is closed I close my<br>
> xcb connection, free my FT library handle and destroy my cairo xcb surface.<br>
><br>
> So if the window is shown/closed/shown/closed/... it will initialize and<br>
> destroy xcb+FT+cairo_xcb_surface for each of them.<br>
><br>
> And I wonder if this is the issue: cairo_xcb seems to not work properly in<br>
> such scenario.<br>
><br>
> Do you have any experience or ideas to share?<br>
<br>
</span>When you have a cairo surface using your xcb_connection*, do the following:<br>
<br>
 cairo_device_t *device = cairo_device_reference(<br>
        cairo_surface_get_device(<wbr>surface));<br>
<br>
Then, *before* you do xcb_disconnect(connection), do:<br>
<br>
 cairo_device_finish(device);<br>
 cairo_device_destroy(device);<br>
<br>
The above should happen automatically when the last cairo-xcb surface is<br>
finished. Thus, it might be that you have a leak somewhere? (Not<br>
necessarily, there are non-leak cases where the above can happen)<br>
<br>
cairo-xlib does some (IMO) bad hacks so that the above is not necessary:<br>
It registers itself as an X11 extension with libX11. That way it gets a<br>
callback when you do XCloseDisplay(), but since unregistering an X11<br>
extension is not possible, this has some other downsides (e.g. the above<br>
"dance" is still necessary if cairo ends up being unloaded before the<br>
X11 connection is closed).<br>
<br>
Cheers,<br>
Uli<br>
<span class="HOEnZb"><font color="#888888">--<br>
- Captain, I think I should tell you I've never<br>
  actually landed a starship before.<br>
- That's all right, Lieutenant, neither have I.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Alexandre Bique</div>
</div>