Bug 15168 - Plots not drawn with buffered Cairo 1.12
Plots not drawn with buffered Cairo 1.12
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Graphics
R 2.15.2
x86_64/x64/amd64 (64-bit) Linux
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-12 17:52 UTC by Milan Bouchet-Valat
Modified: 2013-01-19 12:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Bouchet-Valat 2013-01-12 17:52:15 UTC
(I first tried to get some help via a mail to R-devel, but maybe this is the right way of doing things...)

On Fedora 18 [1] and Arch Linux [2], using R 2.15.2, X11 plots are not
drawn (i.e. the window stays blank) when using X11.options(type="cairo")
and X11.options(type="dbcairo"). They are correctly drawn when using
X11.options(type="nbcairo") and X11.options(type="xlib"), or after
resizing the X11 window. When maximizing the X11 window, the plot is also drawn, but at a scale corresponding to the original window size; when the window is restored, the plot is drawn again, but at a scale corresponding to the maximized window.

The bug happens with Cairo 1.12.4 and above, but not with 1.10.2 (I have
not tested versions between these two). I've filed a bug against Cairo
[3], and developers replied that R was probably not calling
cairo_surface_flush() when it should, as Cairo relies on this and this
assumption is relied on in more places in recent releases.

I gave a try to that idea but so far I've not been able to fix the bug
by adding cairo_surface_flush() calls in the src/modules/X11/devX11.c
code.

I've also discovered that the code in X11_Mode() is never really run
when drawing a simple plot like 'plot(1:10)'. What happens is that
xd->holdlevel is always 1 when X11_Mode() is called, so the function
returns. And when xd->holdlevel is set back to 0, no call to X11_Mode is
done. On the contrary, if I resize the window, the blocks for mode==0
and mode==1 are run several times. Is this behavior expected?

This also happens with Cairo 1.10.2, when the plot is correctly drawn,
so this is not the cause of the problem. But I find this puzzling, since
a comment says:

/********************************************************/
/* device_Mode is called whenever the graphics engine   */
/* starts drawing (mode=1) or stops drawing mode=0)     */
/* the device is not required to do anything            */
/********************************************************/

According to what I'm seeing, the "starts drawing" part never happens.
So the comments sounds a bit misleading to me, if not completely wrong.

I would be glad to go on debugging if you can give me some hints, as I am pretty lost at the moment. Thanks.


1: https://bugzilla.redhat.com/show_bug.cgi?id=891983
2: https://bugs.archlinux.org/task/32597
3: https://bugs.freedesktop.org/show_bug.cgi?id=59085
Comment 1 Brian Ripley 2013-01-19 08:49:51 UTC
The description of cairo_surface_flush() inn the current cairographics documentation does not support this usage, so this seems a bug in their documentation,

I've added that works with cairo 1.12.10 and 1.12.4 to R-devel and R-patched.
Comment 2 Milan Bouchet-Valat 2013-01-19 12:07:38 UTC
Thanks, I can confirm this fixes the issue here.

I've told Cairo upstream that you thought the docs were not explicit about this usage, but you would probably argue this better than I did.