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,
gg <- grid.cap()
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).
R version 2.11.0 RC (2010-04-16 r51754)
attached base packages:
 grid stats graphics grDevices utils datasets methods base
A less confused explanation is
# 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.)