CGContextSetBaseCTM invalid context 0x0

JavaMacos

Java Problem Overview


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.

Java Solutions


Solution 1 - Java

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.

Solution 2 - Java

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.

Solution 3 - Java

When I look at the output, the words "context", "buffer", and "drawable", and also the various things that start with CG (meaning Core Graphics), bells go off indicating that it must have something to the with the fact that your program uses a GUI. Your program seems to be crashing when it tries to ask the Mac OS to display the GUI.

Are you actually on the computer, not using it through a network? If so, are you starting the program from the Terminal? If you are, make sure that you didn't log in as anyone else. There are a million other problems that can cause this, and I've only scratched the surface. Not being an expert in the Mac OS frameworks, I only have one more suggestion: try to get a Java update.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiontomass1996View Question on Stackoverflow
Solution 1 - JavavallismortisView Answer on Stackoverflow
Solution 2 - JavaiDevView Answer on Stackoverflow
Solution 3 - JavatbodtView Answer on Stackoverflow