Bug 59085 - Buffer not flushed when drawing R plots
Summary: Buffer not flushed when drawing R plots
Alias: None
Product: cairo
Classification: Unclassified
Component: xlib backend (show other bugs)
Version: 1.12.8
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Chris Wilson
QA Contact: cairo-bugs mailing list
Depends on:
Reported: 2013-01-06 17:50 UTC by Milan Bouchet-Valat
Modified: 2013-01-19 11:06 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Milan Bouchet-Valat 2013-01-06 17:50:22 UTC
This bug appeared somewhere between Cairo 1.10.2 and 1.12.4, as I could check by downgrading my packages. It has been experienced on Fedora [1] and Arch [2], at least.

Using the R statistical framework, plots are not drawn until one resizes the plot window. Disabling buffered rendering using X11.options(type="nbcairo") fixes the problem. If you are interested in reproducing the bug, calling plot(1:10) is enough.

The problem has been reported by people with Intel GPUs (i915 driver) and with ATI GPUs (Catalyst driver). So it seems to be a Cairo bug, or at least a change in Cairo unveiled a bug in these drivers.

If you have any suspicion of the commit that may have introduced this, I can test that version.

1: https://bugzilla.redhat.com/show_bug.cgi?id=891983
2: https://bugs.archlinux.org/task/32597
Comment 1 Uli Schlachter 2013-01-06 18:26:27 UTC
Broad guess: R is not calling cairo_surface_flush() when it should. Before this function is called, the content of the drawable used is undefined.
Cairo 1.12 makes more use of this requirement (which has been there since forever). I would be very surprised if this were actually a bug in cairo.
Comment 2 Uli Schlachter 2013-01-06 19:48:34 UTC
Ok, I went and checked R's source code:

R-2.15.2/src/modules/X11/devX11.c, function handleEvent(), line 750. This is the handling of Expose events and it just does a cairo_paint(xd->xcc). This also needs cairo_surface_flush(xd->xcs).
Comment 3 Milan Bouchet-Valat 2013-01-07 10:17:24 UTC
Thanks for looking at the code, but your suggestion does not make any difference in my tests. The problem is, the Expose event is never triggered by X so that code is not run.

I also tried adding cairo_surface_flush() calls in many other places, with no result. So I sent a mail to R-devel, let's see what they say:

Comment 4 Milan Bouchet-Valat 2013-01-16 14:41:08 UTC
Sorry for reopening, but somebody downstream told me the bug does not happen using the Nouveau driver - so it would be an Intel specific bug. Does that help you identifying where the bug might be? Is it still possible that it is an R bug? I guess you're in the best position to tell me who I should complain to. ;-)

Comment 5 Milan Bouchet-Valat 2013-01-16 17:36:31 UTC
Actually, the bug happens with ATI's Catalyst proprietary driver, but not with NVidia's. To me, this sounds like the NVidia driver forces a draw/flush/something, while the others do not. Is that of any help?
Comment 6 Milan Bouchet-Valat 2013-01-16 19:18:33 UTC
Damn, I was wrong again. Let me restate the situation: Intel and ATI Catalyst drivers suffer from the bug; Nouveau (*not* NVidia proprietary) does not suffer from it.
Comment 7 Milan Bouchet-Valat 2013-01-19 11:06:35 UTC
OK, R developers have found how to use cairo_surface_flush() to fix the bug (where I failed), so you were right.

But they complained that cairo_surface_flush() documentation "does not support this usage". Do you think this could be improved?

Thanks for your help so far!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.