CGGStackRestore: gstack underflow

  • I'm getting  a ton of console messages:

    Tue Aug  5 16:34:13 Macintosh-5.local RTP[2209] <Error>: CGGStackRestore:
    gstack underflow.

    What should I be looking for to find the problem?
  • On Tue, Aug 5, 2008 at 5:44 PM, Gordon Apple <ga...> wrote:
    > What should I be looking for to find the problem?

    I'm not a CoreGraphics expert, but my first instinct is too many calls
    to -[NSGraphicsContext restoreGraphicsState].

    --Kyle Sluder
  • It does not appear to come from anything in my drawing code.  It only
    happens when I use layers.  The view in a scroller.  Moving the scroll bars
    or resizing the window results in a flood of such console messages. The
    drawLayer:inContext: appears to be balanced:

        NSGraphicsContext *nsGraphicsContext;
        nsGraphicsContext = [NSGraphicsContext
    graphicsContextWithGraphicsPort:ctx flipped:YES ];
        [NSGraphicsContext saveGraphicsState];
        [NSGraphicsContext setCurrentContext:nsGraphicsContext];
        ... (My drawing)
        [NSGraphicsContext restoreGraphicsState];

    This was straight out of the Core Animation Cookbook.

    On 8/5/08 5:09 PM, "Kyle Sluder" <kyle.sluder+<cocoa-dev...> wrote:

    > On Tue, Aug 5, 2008 at 5:44 PM, Gordon Apple <ga...> wrote:
    >> What should I be looking for to find the problem?
    >
    > I'm not a CoreGraphics expert, but my first instinct is too many calls
    > to -[NSGraphicsContext restoreGraphicsState].
    >
    > --Kyle Sluder
  • A shot in the dark...

    Are you manually activating the run loop using NSDefaultRunLoopMode? I
    recently encountered the same problem (using Core Animation as well),
    and eventually tracked it down to the way I was waiting for messages
    from a CFMessagePort to arrive. Specifying a custom run loop mode
    caused the problem to go away, and I'm still mystified as to why.

    If that isn't it, I'd check that you are using Core Animation
    properly. Is the NSView a layer-hosting or layer-backed view? Does it
    have any NSView subviews or CALayer sublayers? Read this if you
    haven't already:

    http://developer.apple.com/documentation/GraphicsImaging/Conceptual/Animati
    on_Overview/ChooseAnimTech/chapter_5_section_3.html#/

    /apple_ref/doc/uid/TP40004952-CH5-SW4

    Best,
    Ryan

    On Aug 5, 2008, at 10:08 PM, Gordon Apple wrote:

    > It does not appear to come from anything in my drawing code.  It only
    > happens when I use layers.  The view in a scroller.  Moving the
    > scroll bars
    > or resizing the window results in a flood of such console messages.
    > The
    > drawLayer:inContext: appears to be balanced:
    >
    > NSGraphicsContext *nsGraphicsContext;
    > nsGraphicsContext = [NSGraphicsContext
    > graphicsContextWithGraphicsPort:ctx flipped:YES ];
    > [NSGraphicsContext saveGraphicsState];
    > [NSGraphicsContext setCurrentContext:nsGraphicsContext];
    > ... (My drawing)
    > [NSGraphicsContext restoreGraphicsState];
    >
    > This was straight out of the Core Animation Cookbook.
    >
    >
    > On 8/5/08 5:09 PM, "Kyle Sluder" <kyle.sluder+<cocoa-dev...>
    > wrote:
    >
    >> On Tue, Aug 5, 2008 at 5:44 PM, Gordon Apple <ga...> wrote:
    >>> What should I be looking for to find the problem?
    >>
    >> I'm not a CoreGraphics expert, but my first instinct is too many
    >> calls
    >> to -[NSGraphicsContext restoreGraphicsState].
    >>
    >> --Kyle Sluder

    >
  • I don't know anything about NSDefaultRunLoopMode and have simply been trying
    to replace my layered list of draw lists with layers in what may or may not
    be a scrolling view.  I'm not doing anything with animation yet.  To say
    this has been problematic would be an understatement.

    Also, in spite of much reading and many comments and responses, I have to
    say that I still don't have a clue what the difference is between a layer
    backed view and a layer hosted view.  I assume the former is intended to be
    used in the same manner as a normal view and is usually implemented by
    checking the box in IB for the view, and maybe has no sublayers.  Obviously,
    I need sublayers.  My current approach is to add a base layer to the view's
    layer and then build my stack of sublayers in the base view.  When using
    live video, I add a QTCaptureLayer subLayer to the view's layer, but that is
    not involved in the current issue. (That has its own problems, on which I
    have already filed two bug reports.)

    There are many things they just don't tell you in the documentation, such as
    the fact that your content view's layer in a scroller will be a
    CATiledLayer.  I have been replacing that with my own CALayer, which could
    be the source of some of the problems.  (That was my attempt to go from
    layer-backed to layer-hosted.)

    I did once have a couple of QTCaptureViews as subviews, but not anymore.  I
    found out that that just didn't display properly because the capture view
    apparently gets overdrawn by my layer stack.  That's when I went to using a
    QTCaptureLayer with z=1000 to get it out front.  But that layer gets added
    from my A/V controller, which hasn't happened when I'm getting all those
    stack-underflow console messages.

    On 8/6/08 4:41 AM, "Ryan Brown" <ryan...> wrote:

    > A shot in the dark...
    >
    > Are you manually activating the run loop using NSDefaultRunLoopMode? I
    > recently encountered the same problem (using Core Animation as well),
    > and eventually tracked it down to the way I was waiting for messages
    > from a CFMessagePort to arrive. Specifying a custom run loop mode
    > caused the problem to go away, and I'm still mystified as to why.
    >
    > If that isn't it, I'd check that you are using Core Animation
    > properly. Is the NSView a layer-hosting or layer-backed view? Does it
    > have any NSView subviews or CALayer sublayers? Read this if you
    > haven't already:
    >
    > http://developer.apple.com/documentation/GraphicsImaging/Conceptual/Animati
    on_

    > Overview/ChooseAnimTech/chapter_5_section_3.html#/
    > /apple_ref/doc/uid/TP40004952-CH5-SW4
    >
    > Best,
    > Ryan
previous month august 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today