__NSGetTransformedIdealAdvances crash
__NSGetTransformedIdealAdvances crash
- Subject: __NSGetTransformedIdealAdvances crash
- From: Mark Alldritt <email@hidden>
- Date: Sat, 13 Dec 2008 08:09:11 -0800
Hello All,
I'm experiencing an extremely intermittent crash, and I'm not able to
figure out what I'm doing to cause it. I have not been able to work
up a test case for it. It just seems to happen, and when it happens
it happens a few times (1-3) in a row and then simply stops
happening. When I bring in the Xcode debugger to try and isolate a
cause, it stops happening. Here's the stack trace:
Thread 0 Crashed:
0 com.apple.AppKit 0x0157b2a5
__NSGetTransformedIdealAdvances + 543
1 com.apple.AppKit 0x0160af9d -
[NSLayoutManager(NSTextViewSupport)
showPackedGlyphs:length:glyphRange:atPoint:font:color:printingAdjustment
:] + 447
2 com.apple.AppKit 0x01609a1f -
[NSLayoutManager(NSPrivate)
_drawGlyphsForGlyphRange:atPoint:parameters:] + 9206
3 com.apple.AppKit 0x01607623 -
[NSLayoutManager(NSTextViewSupport) drawGlyphsForGlyphRange:atPoint:]
+ 70
4 com.latenightsw.ScriptDebugger 0x000f42ed -[LNSTextLayoutManager
drawGlyphsForGlyphRange:atPoint:] + 80141
5 com.apple.AppKit 0x01603c13 -[NSTextView drawRect:]
+ 1435
6 com.latenightsw.ScriptDebugger 0x001a88c2 -[SDOSAScriptTextView
drawRect:] + 22626
7 com.apple.AppKit 0x0160351b -[NSTextView
_drawRect:clip:] + 2579
8 com.apple.AppKit 0x0159c0d5 -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 1819
9 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
10 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
11 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
12 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
13 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
14 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
15 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
16 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
17 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
18 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
19 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
20 com.apple.AppKit 0x0159cb0b -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 4433
21 com.apple.AppKit 0x0159b5f3 -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] + 306
22 com.apple.AppKit 0x01598117 -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] +
3090
23 com.apple.AppKit 0x014d8b77 -[NSView
displayIfNeeded] + 933
24 com.apple.AppKit 0x014d8725 -[NSWindow
displayIfNeeded] + 189
25 com.apple.AppKit 0x014d8548
_handleWindowNeedsDisplay + 436
26 com.apple.CoreFoundation 0x012dc9c2 __CFRunLoopDoObservers +
466
27 com.apple.CoreFoundation 0x012ddd1c CFRunLoopRunSpecific + 844
28 com.apple.CoreFoundation 0x012decf8 CFRunLoopRunInMode + 88
29 com.apple.HIToolbox 0x029ad480
RunCurrentEventLoopInMode + 283
30 com.apple.HIToolbox 0x029ad1d2 ReceiveNextEventCommon +
175
31 com.apple.HIToolbox 0x029ad10d
BlockUntilNextEventMatchingListInMode + 106
32 com.apple.AppKit 0x014d63ed _DPSNextEvent + 657
33 com.apple.AppKit 0x014d5ca0 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
34 com.apple.AppKit 0x014cecdb -[NSApplication run] + 795
35 com.omnigroup.OmniAppKit 0x00591f76 -[OAApplication run] + 406
36 com.apple.AppKit 0x0149bf14 NSApplicationMain + 574
37 com.latenightsw.ScriptDebugger 0x00025a0a main() + 138
38 com.latenightsw.ScriptDebugger 0x00002cfc 0x1000 + 7420
39 com.latenightsw.ScriptDebugger 0x00002c29 0x1000 + 7209
Searching Google, I see this crash site appearing in many other crash
reports, but its not clear what the cause is. I'm guessing that I'm
corrupting something in advance of -[NSTextView drawRect:] being
called, but what? Does anyone have any suggestions about how to
isolate what I might be doing to cause NSTextView (and friends) to
become unstable?
-[LNSTextLayoutManager drawGlyphsForGlyphRange:atPoint:] looks like
this:
- (void) drawGlyphsForGlyphRange:(NSRange) glyphRange atPoint:
(NSPoint) containerOrigin
{
BOOL showInvisibles = [mEditor showInvisibles];
if (showInvisibles)
{
if (!sSpaceImage)
sSpaceImage = [[NSImage imageNamed:@"Space"] retain];
if (!sTabImage)
sTabImage = [[NSImage imageNamed:@"Tab"] retain];
if (!sCRImage)
sCRImage = [[NSImage imageNamed:@"CarrageReturn"] retain];
if (!sLFImage)
sLFImage = [[NSImage imageNamed:@"LineFeed"] retain];
if (!sFFImage)
sFFImage = [[NSImage imageNamed:@"FormFeed"] retain];
if (!sUnicodeParaImage)
sUnicodeParaImage = [[NSImage imageNamed:@"UnicodeParagraph"]
retain];
if (!sControlImage)
sControlImage = [[NSImage imageNamed:@"Control"] retain];
// figure out what invisibles to draw
NSRange charRange = [self characterRangeForGlyphRange:glyphRange
actualGlyphRange:NULL];
NSString* characters = [[self textStorage] string];
BOOL showSpaces = [mEditor showSpaces];
for (unsigned i = charRange.location; i < charRange.location +
charRange.length; i++)
{
unichar c = [characters characterAtIndex:i];
NSImage* img = nil;
if (showSpaces && c == ' ') // "real" space
img = sSpaceImage;
else if (c == '\t') // "correct" indentation
img = sTabImage;
else if (c == 0x21e4 || c == 0x21e5) // not "correct"
indentation (leftward tab, rightward tab)
img = sTabImage;
else if (c == 0x0d) // cr
img = sCRImage;
else if (c == 0x0a) // line feed
img = sLFImage;
else if (c == NSFormFeedCharacter)
img = sFFImage;
else if (c == kUnicodeParagraphSeparator) // Unicode paragraph
seperator
img = sUnicodeParaImage;
else if (c < 0x20 ||
c == 0xa0/* option-space */ ||
(0x007f <= c && c <= 0x009f) ||
[[NSCharacterSet illegalCharacterSet] characterIsMember:
c]) // some other mystery control character
img = sControlImage;
else
{
NSRange glyphRange = [self
glyphRangeForCharacterRange:NSMakeRange(i, 1)
actualCharacterRange:NULL];
if (glyphRange.length == 0)
// something that doesn't show up as a glpyh
img = sControlImage;
}
if (img)
{
NSSize imgSize = [img size];
NSRange glyphRange = [self
glyphRangeForCharacterRange:NSMakeRange(i,1) actualCharacterRange:NULL];
NSPoint where = [self locationForGlyphAtIndex: glyphRange.location];
NSRect fragment = [self lineFragmentRectForGlyphAtIndex:
glyphRange.location effectiveRange: NULL];
where.x += fragment.origin.x + containerOrigin.x;
if (where.y == fragment.size.height)
{
NSDictionary* attributes = [[self textStorage] attributesAtIndex:
i effectiveRange: NULL];
NSFont* font = [attributes objectForKey:NSFontAttributeName];
where.y += floor([font descender] + 0.5);
}
where.y += fragment.origin.y + containerOrigin.y;
where.y -= imgSize.height;
[img setFlipped:YES];
[img drawAtPoint:where
fromRect:NSMakeRect(0.0, 0.0, imgSize.width, imgSize.height)
operation:NSCompositeSourceOver
fraction:1.0];
}
}
}
[super drawGlyphsForGlyphRange: glyphRange atPoint:
containerOrigin];
}
-[SDOSAScriptTextView drawRect:] looks like this:
- (void) drawRect:(NSRect) area
{
[super drawRect:area];
if ([mScriptModel showCurrentParagraphHighlight])
{
long currPara = [mScriptModel currentParagraph];
LineState paraState = [mScriptModel paragraphState:currPara];
if (currPara >= 0 &&
(paraState == kLineCurrent ||
paraState == kLineRunTimeError ||
paraState == kLineCompileError))
{
NSSize inset = [self textContainerInset];
NSTextStorage* ts = [self textStorage];
NSLayoutManager* lm = [self layoutManager];
NSTextContainer* tc = [self textContainer];
NSRange currParaRange = [mScriptModel
statementRangeAtParagraph:currPara lookingBackward:YES];
if (NSMaxRange(currParaRange) >= [ts length])
{
unichar ch = [ts length] > 0 ? [[ts string]
characterAtIndex:NSMaxRange(currParaRange) - 1] : 0;
switch (ch)
{
case '\n':
case '\r':
case kUnicodeParagraphSeparator:
--currParaRange.length;
break;
}
}
NSParameterAssert([[mScriptModel textStorage] editedRange].location
== 0x7fffffffUL);
NSRange glyphRange = [lm glyphRangeForCharacterRange:currParaRange
actualCharacterRange:nil];
NSRect currParaArea = [lm boundingRectForGlyphRange:glyphRange
inTextContainer:tc];
currParaArea = NSInsetRect(NSOffsetRect(currParaArea, inset.width,
inset.height), 0.0, -1.0);
if (NSIntersectsRect(area, currParaArea))
{
NSRect f = [self frame];
currParaArea.origin.x = NSMinX(f) + inset.width;
currParaArea.size.width = NSWidth(f) - inset.width * 2.0;
if (currParaArea.origin.y < inset.height)
{
float delta = inset.height - currParaArea.origin.y;
currParaArea.origin.y += delta;
currParaArea.size.height -= delta;
}
switch (paraState)
{
case kLineRunTimeError:
case kLineCompileError:
[[NSColor colorWithCalibratedRed:1.0 green:0.0 blue:0.0 alpha:
0.4] set];
break;
case kLineCurrent:
[[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:
0.4] set];
break;
default:
assert(false);
break;
}
NSFrameRectWithWidthUsingOperation(NSInsetRect(currParaArea, 1.0,
0.0), 1.0, NSCompositeSourceOver);
switch (paraState)
{
case kLineRunTimeError:
case kLineCompileError:
[[NSColor colorWithCalibratedRed:1.0 green:0.0 blue:0.0 alpha:
0.2] set];
break;
case kLineCurrent:
[[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:
0.2] set];
break;
default:
assert(false);
break;
}
NSRectFillUsingOperation(NSInsetRect(currParaArea, 2.0, 1.0),
NSCompositeSourceOver);
}
}
}
if (mDropLocation >= 0)
{
NSRect r = [self rangeArea:NSMakeRange(mDropLocation, 0)];
r.size.width = 1.0;
assert(NSHeight(r) > 0);
[self drawInsertionPointInRect:r
color:[self insertionPointColor]
turnedOn:YES];
}
}
Thanks
-Mark
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden