Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGContextSetBaseCTM invalid context 0x0

Tags:

java

macos

I'm currently developing a Java application.
And as I don't own a OSX computer I've enlisted the help of some people from the forum/community this app is for.
But there is this error that occurs when the application is launched on the OSX.

Oct 5 15:26:58 ###-macbook-pro.local java[2384] <Error>: CGContextGetCTM: invalid context 0x0   
Oct 5 15:26:58 ###-macbook-pro.local java[2384] <Error>: CGContextSetBaseCTM: invalid context 0x0   
Oct 5 15:26:58 ###-macbook-pro.local java[2384] <Error>: CGContextGetCTM: invalid context 0x0   
Oct 5 15:26:58 ###-macbook-pro.local java[2384] <Error>: CGContextSetBaseCTM:      invalid context 0x0    
2012-10-05 15:26:59.590 java[2384:11517] Make pbuffer: 0 x 0   
2012-10-05 15:26:59.657 java[2384:2007] invalid drawable  

Obviously as I don't own a OSX computer it makes it very hard to debug issues like this, So I was hoping one of you intelligent individuals could insight me into what this issue is caused by so as I can go about fixing it. If there is any other info you may need let me know and I can try and get the person with the OSX computer to get it.

like image 753
tomass1996 Avatar asked Oct 06 '12 10:10

tomass1996


2 Answers

This error occurs on OSX Lion >=10.7.4 (not on <=10.7.3) when invoking JFrame.setIconImage(Image) on:

OSX 10.7.5 with Java 1.6.0_65-b14-462-11M4509

and also (as discussed on the Apple Mac OS X v10.7 Lion Support Community and java-dev list) on:

OSX 10.7.4 with Java 1.6.0_51-b11-457-11A459

OSX 10.7.4 with Java 1.6.0_31

OSX 10.7.4 with Java 1.7.0_04

It does not happen on:

OSX 10.8.4 with Java 1.6.0_51-b11-457-11M4509

Given the above information, this error is a bug in the native window implementation of OSX >=10.7.4 and <10.8, and is not a bug in Java.

I attempted to work around this issue by adjusting the timing of setting the JFrame icon, but it doesn't matter when the method is invoked, the error appears to be unavoidable if using JFrame.setIconImage.

like image 66
vallismortis Avatar answered Oct 16 '22 16:10

vallismortis


You don't give much information on where this happen in your code. On Mac, when you see this it's usually because you are trying to draw into a graphic context when you don't have one.

In Java I think this could happen when drawing something in a JPanel or other JComponent. For example, when adding an image to it.

As far as I know, Java JDK on OS X is provided by Apple. For what I've read this is a known issue not yet fixed by Apple.

like image 1
iDev Avatar answered Oct 16 '22 16:10

iDev