[R-SIG-Mac] png error message problem, and potential crash

Richard M. Heiberger rmh at temple.edu
Thu Jun 22 18:28:07 CEST 2017


bash-3.2$ R --vanilla

R version 3.4.0 Patched (2017-04-28 r72639) -- "You Stupid Darkness"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> png("abcd.png", height=.22, width=2)
Jun 22 12:13:08  R[59491] <Error>: CGContextTranslateCTM: invalid
context 0x0. If you want to see the backtrace, please set
CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 22 12:13:08  R[59491] <Error>: CGContextScaleCTM: invalid context
0x0. If you want to see the backtrace, please set
CG_CONTEXT_SHOW_BACKTRACE environmental variable.
> png("abcd.png", height=.22, width=2, units="in", res=300)
> dev.cur()
quartz_off_screen
                3
> dev.off()
quartz_off_screen
                2
> dev.off()
null device
          1
> version
               _
platform       x86_64-apple-darwin15.6.0
arch           x86_64
os             darwin15.6.0
system         x86_64, darwin15.6.0
status         Patched
major          3
minor          4.0
year           2017
month          04
day            28
svn rev        72639
language       R
version.string R version 3.4.0 Patched (2017-04-28 r72639)
nickname       You Stupid Darkness
> q()
bash-3.2$

Deep inside a function with png() inside a loop,
after about 70 of the CGContextTranslateCTM messages,
I got the crash message
Jun 22 11:40:48  R[59174] <Error>: CGBitmapContextCreateImage: invalid
context 0x0. If you want to see the backtrace, please set
CG_CONTEXT_SHOW_BACKTRACE environmental variable.

Process R trace/BPT trap: 5 at Thu Jun 22 11:40:48 2017


For comparison, on Windows
R version 3.4.0 Patched (2017-04-28 r72638) -- "You Stupid Darkness"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

I get an appropriate error message

> png("abcd.png", height=.22, width=2)
Warning message:
In png("abcd.png", height = 0.22, width = 2) :
  'width=2, height=0' are unlikely values in pixels
>

For completeness, the repair, shown above, is to use the units and res
arguments.



More information about the R-SIG-Mac mailing list