Re: CGContextClipToRects: invalid context 0x0.

2015-12-21 Thread Graham Cox

> On 16 Dec 2015, at 10:12 AM, Richard Charles  wrote:
> 
> : CGContextClipToRects: invalid context 0x0. This is a serious error. 
> This application, or a library it uses, is using an invalid context and is 
> thereby contributing to an overall degradation of system stability and 
> reliability. This notice is a courtesy: please fix this problem. It will 
> become a fatal error in an upcoming update.


This has to be the Chicken Little of error messages.

Surely the first thing any CG…() function that takes a context does is to 
assert that the context isn’t nil, and if not branch to CGPostError and do 
nothing else. Therefore it’s actually completely harmless. Of course it 
indicates an error further up, but the outcome is just a no-op. The alarmist 
tone of the message is to make you do something to investigate this, and to 
that end it works, but the problem seems to be that the only sources of these 
errors now are Apple’s own code.

—Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-21 Thread Richard Charles

> On Dec 21, 2015, at 1:31 PM, Gary L. Wade  
> wrote:
> 
> I really don't see why you need to debug Apple's frameworks. When you break 
> in the debugger or get a crash report symbolicated, there are enough symbols 
> in there to see where you are—if you are in a call sequence inside Apple's 
> frameworks. If you're not seeing them, then you're not there.

In retrospect I agree, it was somewhat pointless. Like a good developer I was 
simply following instructions given in the error message written and placed 
there by Apple and also trying to improve my debugging skills.

Error under OS X El Capitan 10.11.2 which is a little different that the 
previously reported error under OS X Yosemite 10.10.5.

: Set a breakpoint at CGSLogError to catch errors as they are logged.
: CGSGetSystemWindow: Invalid window

> The time I saw your real issue was when I was trying to unravel some legacy 
> code that was forcing changes to the view hierarchy when in a drawRect: which 
> is really, really bad, and it was mixing up auto layout and manual layout—a 
> field editor and simulated combo box were involved.

I actually was able to reproduce the initial first part of the issue with a 
standard Xcode 7.2 project template application. So it is time to give up and 
move on. It appears Apple will need to fix this. I updated bug report 23955382.

--Richard Charles


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-21 Thread Gary L. Wade
I really don't see why you need to debug Apple's frameworks. When you break in 
the debugger or get a crash report symbolicated, there are enough symbols in 
there to see where you are—if you are in a call sequence inside Apple's 
frameworks. If you're not seeing them, then you're not there.

The time I saw your real issue was when I was trying to unravel some legacy 
code that was forcing changes to the view hierarchy when in a drawRect: which 
is really, really bad, and it was mixing up auto layout and manual layout—a 
field editor and simulated combo box were involved.

Look at your code for things like that and forget about your perceived issue 
with the frameworks.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Dec 15, 2015, at 3:12 PM, Richard Charles  wrote:
> 
> CGContextClipToRects

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-21 Thread Richard Charles

> On Dec 18, 2015, at 7:44 PM, Uli Kusterer  
> wrote:
> 
> On 18 Dec 2015, at 17:59, Richard Charles  wrote:
>> Debugging a linked library without symbols is difficult (bordering on 
>> impossible).
> 
> It's not easy, but far from impossible. If you can read assembly, you can 
> usually figure out quite a lot. The debugger will disassemble stack frames 
> for you when you step into them. It would be a little easier for Objective-C 
> code, where all method names are registered publicly, as are class names and 
> a good part of each object's layout.
> 
> It helps to familiarize oneself with LLDB's commands. Particularly what 
> registers 64-bit apps use to store parameters and how to print them from 
> inside a method call, and how the 'po' command works for printing objects.

The difficult thing was that the CGPostError breakpoint stopped at the 
beginning of the CGPostError function.

#0  0x7fff8e5686c7 in CGPostError ()
#1  0x7fff8e568798 in handle_invalid_context ()
#2  0x7fff8d5ad2c0 in -[NSView _drawRect:clip:] ()

At this breakpoint the registers contained passed in parameters for CGPostError 
() but what was needed was information on -[NSView _drawRect:clip:] ().

What would have helped is a conditional symbolic breakpoint after the fact. 
Break on -[NSView _drawRect:clip:] when followed by a CGPostError with the 
registers containing the parameters passed into -[NSView _drawRect:clip:]. 
There are way too many -[NSView _drawRect:clip:] calls to manually step through 
each one waiting for the one followed by CGPostError.

> But for complaints about an invalid context, it sometimes helps to verify 
> that any API you use from the library this error comes from is documented to 
> accept NULL where you pass it NULL. And in this case I'd also print the 
> current CGContext before any calls you make, and ensure that you save and 
> restore your context before and after any calls where you change it, 
> especially if you create your own contexts. And ensure that you retain any 
> contexts that you're keeping around across calls, and verifying that your 
> window is visible and not deferred if you try to draw in it. (This is all 
> assuming you're not making a basic mistake like calling drawRect: directly or 
> (even indirectly) requesting redraws from inside drawRect:

I am using an OpenGL context and have checked everything. My actual problem 
occurs when choosing Revert To > Browse All Versions.

> If none of this helps, a common occurrence of weird behaviour like this is 
> also sometimes screwing up internal state by using thread-safe API that is 
> not documented to support being used from more than one thread at once, or 
> API that's not safe to use from non-main threads at all, from several 
> threads. Any if that ring a bell?

I put the application into single threaded mode and get the same error. I 
requested technical support for this issue and was told to file a bug report so 
we shall see what happens.

Thanks for the input.

--Richard Charles


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-21 Thread Richard Charles

> On Dec 18, 2015, at 2:36 PM, Quincey Morris 
>  wrote:
> 
> On Dec 18, 2015, at 08:59 , Richard Charles  wrote:
>> 
>> Apple’s frameworks do not have symbols.
> 
> IIRC several OS X versions ago, Apple use to release versions of the system 
> frameworks that included symbols, but this wasn’t very useful because they 
> came out so much later than the OS itself. I don’t know if they’ve done that 
> for recent versions. You could look in the developer downloads to find out.

Debug symbols for Cocoa frameworks are no where to be found.

> Regarding the original problem (since no one who knew anything jumped in), I 
> think I’ve seen this complained of occasionally during the last couple of 
> years. Sometimes it indicates that internal Apple code wasn’t changed when 
> API was deprecated. It works fine, but as OS versions march on the complaints 
> from the deprecated API get more insistent.
> 
> So it may not be anything to do with your code. The best thing to do is file 
> a radar and let them tell you not to worry about it.

I requested technical support for this issue and was promptly told to file a 
bug report.

Thanks for the input.

--Richard Charles


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-18 Thread Uli Kusterer
On 18 Dec 2015, at 17:59, Richard Charles  wrote:
> Debugging a linked library without symbols is difficult (bordering on 
> impossible).

 It's not easy, but far from impossible. If you can read assembly, you can 
usually figure out quite a lot. The debugger will disassemble stack frames for 
you when you step into them. It would be a little easier for Objective-C code, 
where all method names are registered publicly, as are class names and a good 
part of each object's layout.

It helps to familiarize oneself with LLDB's commands. Particularly what 
registers 64-bit apps use to store parameters and how to print them from inside 
a method call, and how the 'po' command works for printing objects.

But for complaints about an invalid context, it sometimes helps to verify that 
any API you use from the library this error comes from is documented to accept 
NULL where you pass it NULL. And in this case I'd also print the current 
CGContext before any calls you make, and ensure that you save and restore your 
context before and after any calls where you change it, especially if you 
create your own contexts. And ensure that you retain any contexts that you're 
keeping around across calls, and verifying that your window is visible and not 
deferred if you try to draw in it. (This is all assuming you're not making a 
basic mistake like calling drawRect: directly or (even indirectly) requesting 
redraws from inside drawRect:

If none of this helps, a common occurrence of weird behaviour like this is also 
sometimes screwing up internal state by using thread-safe API that is not 
documented to support being used from more than one thread at once, or API 
that's not safe to use from non-main threads at all, from several threads. Any 
if that ring a bell?

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://stacksmith.org





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-18 Thread Quincey Morris
On Dec 18, 2015, at 08:59 , Richard Charles  wrote:
> 
> Apple’s frameworks do not have symbols.

IIRC several OS X versions ago, Apple use to release versions of the system 
frameworks that included symbols, but this wasn’t very useful because they came 
out so much later than the OS itself. I don’t know if they’ve done that for 
recent versions. You could look in the developer downloads to find out.

Regarding the original problem (since no one who knew anything jumped in), I 
think I’ve seen this complained of occasionally during the last couple of 
years. Sometimes it indicates that internal Apple code wasn’t changed when API 
was deprecated. It works fine, but as OS versions march on the complaints from 
the deprecated API get more insistent.

So it may not be anything to do with your code. The best thing to do is file a 
radar and let them tell you not to worry about it.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CGContextClipToRects: invalid context 0x0.

2015-12-18 Thread Richard Charles
After researching I found answers to my questions.


> The first thing I noticed is that there are no debug symbols in Apple’s 
> frameworks. It that normal?

Apple’s frameworks do not have symbols.


> How do you debug something with no symbols?

Debugging a linked library without symbols is difficult (bordering on 
impossible).


With regards to this specific issue I submitted bug report 23955382.

--Richard Charles


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com