[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    Re: [cairo] Concerns regarding cairo-xcb backend
From:       Alexandre Bique <bique.alexandre () gmail ! com>
Date:       2017-12-16 21:39:56
Message-ID: CAP737oKCiaafvV3SJj1rZzm6gvr0VKRreaqTF_ZpA3v54nF+PQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Uli,

Many thanks for the response.

As of today I'm using cairo-image + xcb-shm and the bug seems to be gone.

Regards,
Alexandre

On Sat, Dec 16, 2017 at 10:46 AM, Uli Schlachter <psychon@znc.in> wrote:

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



-- 
Alexandre Bique

[Attachment #5 (text/html)]

<div dir="ltr">Hi Uli,<div><br></div><div>Many thanks for the \
response.</div><div><br></div><div>As of today I&#39;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">&lt;<a href="mailto:psychon@znc.in" \
target="_blank">psychon@znc.in</a>&gt;</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>
&gt; I&#39;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> &gt; using Xlib before but I&#39;ve switched to xcb now, and I&#39;m using \
cairo-xcb<br> &gt; instead of cairo-xlib for the painting.<br>
&gt;<br>
&gt; While using the cairo-xcb backend I&#39;ve come across the following \
assertion:<br> &gt;<br>
&gt; cairo-xcb-screen.c:219: _get_screen_index: Assertion `!&quot;reached&quot;&#39; \
failed.<br> &gt;<br>
&gt; I&#39;ve looked at the source code and I was surprised to see that the<br>
&gt; cairo-xcb backend has global variables (mutex, list of<br>
&gt; 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>
&quot;everything&quot; just once.<br>
<span class=""><br>
&gt; The application I&#39;m working on is a software synthesizer plugin \
(VST2/VST3)<br> &gt; which a Digital Audio Workstation like Bitwig Studio (<a \
href="http://www.bitwig.com" rel="noreferrer" target="_blank">www.bitwig.com</a>) \
can<br> &gt; use and display.<br>
&gt;<br>
&gt; The DAW loads the plugins, can show the plugin window (using XEmbed), hide<br>
&gt; or close the plugin window. In case the plugin window is closed I close my<br>
&gt; xcb connection, free my FT library handle and destroy my cairo xcb surface.<br>
&gt;<br>
&gt; So if the window is shown/closed/shown/closed/... it will initialize and<br>
&gt; destroy xcb+FT+cairo_xcb_surface for each of them.<br>
&gt;<br>
&gt; And I wonder if this is the issue: cairo_xcb seems to not work properly in<br>
&gt; such scenario.<br>
&gt;<br>
&gt; 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>
&quot;dance&quot; 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&#39;ve never<br>
   actually landed a starship before.<br>
- That&#39;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>


[Attachment #6 (text/plain)]

-- 
cairo mailing list
cairo@cairographics.org
https://lists.cairographics.org/mailman/listinfo/cairo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic