Bug 14260 - grid.cap() needs to flush the graphic device for quartz()
grid.cap() needs to flush the graphic device for quartz()
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Mac GUI / Mac specific
R 2.11.0
ix86 (32-bit) Mac OS X v10.5
: P5 normal
Assigned To: Simon Urbanek
https://stat.ethz.ch/pipermail/r-deve...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-18 12:24 UTC by baptiste Auguié
Modified: 2010-10-11 16:36 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 baptiste Auguié 2010-04-18 12:24:21 UTC
Under some circumstances, grid.cap() fails to capture the graphical output of the quartz() device. The problem occurs when the device has not yet performed the actual drawing (waiting for possible additional user input). The following code returns an almost entirely blank window,

library(grid)

quartz()
grid.circle(gp=gpar(fill="black"))
gg <- grid.cap()
dev.new()
grid.raster(gg) # completely blank 
## (except for resize mark at the bottom-right corner)

It seems that a call to grid.cap should trigger a flush of the current device (force the drawing).

sessionInfo()
R version 2.11.0 RC (2010-04-16 r51754) 
i386-apple-darwin9.8.0 

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base
Comment 1 Brian Ripley 2010-04-18 14:46:26 UTC
Mac-only ....
Comment 2 Brian Ripley 2010-10-02 14:45:41 UTC
A less confused explanation is

library(grid)
quartz()
grid.circle(gp=gpar(fill="black"))
Sys.sleep(0.1)
table(grid.cap())
# almost entirely white without the Sys.sleep call.

Still seen in 2.12.0 beta.  (So it is not waiting for further input -- it is simply some asynchronous aspect of Quartz.)
Comment 3 Simon Urbanek 2010-10-07 17:57:25 UTC
Fixed.