Home
Posted By: artie505 CGContextClosePath: no current point. - 08/20/13 07:23 AM
I frequently find messages such as these in Console/Console Messages:

8/17/13 7:55:35 PM [0x0-0x6fe6fe].com.apple.Safari[72821] Sat Aug 17 19:55:35 Artie-Schlesingers-MacBook-Pro.local WebProcess[72822] <Error>: CGContextClosePath: no current point.

(3,094 messages in 13 seconds)

8/17/13 9:38:32 PM [0x0-0x754754].com.apple.Preview[88399] Sat Aug 17 21:38:32 Artie-Schlesingers-MacBook-Pro.local Preview[88399] <Error>: CGContextClosePath: no current point.

(624messages in 4 minutes 30 seconds)

8/17/13 9:34:04 PM com.apple.Finder[57392] Sat Aug 17 21:34:04 Artie-Schlesingers-MacBook-Pro.local Finder[57392] <Error>: CGContextClosePath: no current point.

(32 messages in 4 seconds)

"CGContextClosePath: no current point" messages have been a regular thing for long enough that I can't remember when they began appearing, and although I haven't particularly paid attention to which apps have generated them in the past (Safari and Preview seem familiar, but Finder doesn't ring a bell.), I'm sure I've never seen anything like that Safari barrage .

I've searched and haven't found another instance of this behavior other than as respects programming except for one thread in which a kext left over from Tiger bollixed up AirPort cards in Leopard.

Anybody got any ideas?

Thanks.
Posted By: joemikeb Re: CGContextClosePath: no current point. - 08/20/13 04:17 PM
CG — Computer graphics (specifically 2D Quartz rendering)

The full reference manual for iOS is found here. According to that manual the message you are seeing means…
Originally Posted By: CG Context Reference Manual

CGContextClosePath
Closes and terminates the current path’s subpath.

void CGContextClosePath (
CGContextRef c
);
Parameters
c
A graphics context.

Discussion
Appends a line from the current point to the starting point of the current subpath and ends the subpath.

After closing the subpath, your application can begin a new subpath without first calling CGContextMoveToPoint. In this case, a new subpath is implicitly created with a starting and current point equal to the previous subpath’s starting point.

If the current path is empty or the current subpath is already closed, this function does nothing.

Availability
Available in iOS 2.0 and later.


I suspect this is the result of iOS code embedded in a web site or image for compatibility with iOS devices (iPads and iPhones) in addition to OS X devices. When I searched my logs the only CGContext message I found is CGContextClipToRect
Posted By: ganbustein Re: CGContextClosePath: no current point. - 08/20/13 08:38 PM
Core Graphics is not just in iOS. It's also defined in OS X. (This is a perpetual source of confusion in the developer forums. iOS and OS X are very nearly identical, with APIs that have a vast number of features in common. A developer will ask a question with one OS in mind, and get answers relating to the other. The trouble is that "nearly identical" does not mean "identical", and the differences can be subtle but significant. Each OS has its own complete set of documentation, and when you search for something you'll find results from both sets intermingled. You have to filter the results based on which OS is pertinent at the time.)

The documentation for CGContextClosePath in OS X can be found here. You will notice that it's word-for-word identical to the documentation for CGContextClosePath in iOS, except the final line says "Available in OS X v10.0 and later".

Since all the error messages reflect OS X apps (Safari, Preview, Finder, etc.), it's probably safe to say the messages relate to the OS X version, not the iOS version. All of which is a minor point, that I go into only so that readers will not be left wondering how iOS code might have found its way into OS X apps.

What is probably happening has to do with the distinction between bitmap graphics and vector graphics. If you want to embed an image in a document, you (by which I mean "a program that you write") can either render it yourself and include the resulting pixels (possibly compressed), or you can capture the drawing commands in a form that lets them be carried out on the viewer's computer. The former method (bitmap graphics) tends to produce bigger files with lower resolution. The latter method (vector graphics) tends to produce smaller documents that nevertheless utilize all of the available resolution. Except for images that are either very small or are basically photographs, vector graphics are to be preferred.

But if you're capturing drawing commands, one of the commands being captured might be "CGContextClosePath". That command may have been thrown into the mix because the programmer generating the image wasn't sure whether it would be needed (there might be multiple paths through the code, some of which started a path and some of which didn't), and took to heart the comment in the documentation that said:
Quote:
If the current path is empty or the current subpath is already closed, this function does nothing.
and figured it would be harmless to close the path whether it needed to be closed or not.

But apparently the documentation is not quite accurate. It should probably have said " ... this function does nothing except log a message." Which the image will do any time it's drawn in any application.

The fix would be to replace the image with a more carefully constructed equivalent image. Trouble is, whoever constructed the image in the first place probably never noticed the log messages, and probably will not feel motivated to re-construct and re-deploy the image even if the messages are pointed out. Or get Apple to stop logging the message, or at least lower its log priority so it won't appear unless you've set the log priority to include debugging messages. But Apple probably isn't highly motivated to stop displaying a message that everyone is going to ignore anyway.
Posted By: joemikeb Re: CGContextClosePath: no current point. - 08/20/13 08:42 PM
Glad to have the OS X link. My Google search only found the iOS version.
Posted By: artie505 Re: CGContextClosePath: no current point. - 08/20/13 10:39 PM
Thanks for clarifying the OS X/iOS thing; joemike had me confused, because I haven't got any iOS devices.

OK, I more or less understand your explanation of why I'm seeing those messages, but I don't understand why there's not a-single-nother mention of them on the Internet; surely I can't be unique in experiencing them.

Is it possible I'm running some weird configuration that's at fault?
Posted By: dkmarsh Re: CGContextClosePath: no current point. - 08/21/13 03:30 AM

Quote:
...why there's not a-single-nother mention of them on the Internet...

Actually, there are plenty; googling the string CGContextClosePath: no current point Console gives me 915 results, roughly half of which seem to be related to user rather than programmer experiences.
© FineTunedMac