请帮助调试 UILabel 上的崩溃 (evict_glyph_entry_from_cache)

发布于 2024-10-06 15:02:18 字数 3202 浏览 8 评论 0原文

我在“UILabel”中遇到了奇怪的崩溃。崩溃是从 UILabel 或 CCLabelTTF 的drawRect 发起的。 (我已经花了很多时间谷歌搜索这个问题。)什么可能导致以下代码崩溃?

我正在使用 XCode SDK 4.0 和/或 4.1,cocos2d 版本 0.99.4、0.99.5

代码:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(200,100,185,110)];
[label setTextAlignment:UITextAlignmentLeft];
[label setFont:[UIFont fontWithName:@"Marker Felt" size:14]];

[label setLineBreakMode:UILineBreakModeWordWrap];
[label setAdjustsFontSizeToFitWidth:YES];
[label setNumberOfLines:50];
label.text = message;
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor colorWithRed:0 green:81.0/255 blue:100.0/255 alpha:1]];

[self addSubview:label];
[label release]; label = nil;

崩溃:

Assertion failed: (cache->size >= g->size), function evict_glyph_entry_from_cache, file Fonts/CGFontCache.c, line 836.
Program received signal:  “SIGABRT”.

#0  0x316b698c in __kill ()
#1  0x316b6982 in kill ()
#2  0x316b6974 in raise ()
#3  0x316cb620 in abort ()
#4  0x316b8f16 in __assert_rtn ()
#5  0x30f10d9e in evict_glyph_entry_from_cache ()
#6  0x30ed54e8 in expire_glyphs_nl ()
#7  0x30ed5494 in CGFontCacheUnlock ()
#8  0x30ed5008 in CGGlyphLockUnlock ()
#9  0x31e3a5e4 in ripc_RenderGlyphs ()
#10 0x31e42a66 in ripc_DrawGlyphs ()
#11 0x30ed0714 in CGContextDelegateDrawGlyphs ()
#12 0x30ed06c8 in draw_glyphs ()
#13 0x30ed025a in CGContextShowGlyphsWithAdvances ()
#14 0x311381f0 in WebCore::Font::drawGlyphs ()
#15 0x31137e42 in WebCore::Font::drawGlyphBuffer ()
#16 0x31137c76 in WebCore::Font::drawSimpleText ()
#17 0x31137ad2 in WebCore::Font::drawText ()
#18 0x31137a5e in drawAtPoint ()
#19 0x3117fdd4 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:measureOnly:] ()
#20 0x31180c50 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:] ()
#21 0x325ca46c in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:lineSpacing:includeEmoji:] ()
#22 0x325ca40a in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:lineSpacing:] ()
#23 0x325cb414 in -[UILabel _drawTextInRect:baselineCalculationOnly:] ()
#24 0x325cadf2 in -[UILabel drawTextInRect:] ()
#25 0x325cadaa in -[UILabel drawRect:] ()
#26 0x325c98e8 in -[UIView(CALayerDelegate) drawLayer:inContext:] ()
#27 0x30c6b308 in -[CALayer drawInContext:] ()
#28 0x30c6b190 in backing_callback ()
#29 0x30c6acb6 in CABackingStoreUpdate ()
#30 0x30c6a47e in -[CALayer _display] ()
#31 0x30c6a1ce in -[CALayer display] ()
#32 0x30c6a14a in CALayerDisplayIfNeeded ()
#33 0x30c6994a in CA::Context::commit_transaction ()
#34 0x30c696a8 in CA::Transaction::commit ()
#35 0x30c6f030 in CA::Transaction::observer_callback ()
#36 0x33519b56 in __CFRunLoopDoObservers ()
#37 0x33560a38 in CFRunLoopRunSpecific ()
#38 0x3356035c in CFRunLoopRunInMode ()
#39 0x30248b32 in GSEventRunModal ()
#40 0x30248bde in GSEventRun ()
#41 0x3259776e in -[UIApplication _run] ()
#42 0x32596472 in UIApplicationMain ()
#43 0x0000288e in main (argc=1, argv=0x2ffff618) at /Users/ahsan/Public/Drop Box/today1/main.m:13

I am facing a weird crash in "UILabel".The crash is initiated from drawRect of UILabel or CCLabelTTF). (I've already spent much time Googling this problem.) What could be causing th following code to crash?

I am using XCode SDK 4.0 and/or 4.1, cocos2d version 0.99.4, 0.99.5

CODE:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(200,100,185,110)];
[label setTextAlignment:UITextAlignmentLeft];
[label setFont:[UIFont fontWithName:@"Marker Felt" size:14]];

[label setLineBreakMode:UILineBreakModeWordWrap];
[label setAdjustsFontSizeToFitWidth:YES];
[label setNumberOfLines:50];
label.text = message;
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor colorWithRed:0 green:81.0/255 blue:100.0/255 alpha:1]];

[self addSubview:label];
[label release]; label = nil;

CRASH:

Assertion failed: (cache->size >= g->size), function evict_glyph_entry_from_cache, file Fonts/CGFontCache.c, line 836.
Program received signal:  “SIGABRT”.

#0  0x316b698c in __kill ()
#1  0x316b6982 in kill ()
#2  0x316b6974 in raise ()
#3  0x316cb620 in abort ()
#4  0x316b8f16 in __assert_rtn ()
#5  0x30f10d9e in evict_glyph_entry_from_cache ()
#6  0x30ed54e8 in expire_glyphs_nl ()
#7  0x30ed5494 in CGFontCacheUnlock ()
#8  0x30ed5008 in CGGlyphLockUnlock ()
#9  0x31e3a5e4 in ripc_RenderGlyphs ()
#10 0x31e42a66 in ripc_DrawGlyphs ()
#11 0x30ed0714 in CGContextDelegateDrawGlyphs ()
#12 0x30ed06c8 in draw_glyphs ()
#13 0x30ed025a in CGContextShowGlyphsWithAdvances ()
#14 0x311381f0 in WebCore::Font::drawGlyphs ()
#15 0x31137e42 in WebCore::Font::drawGlyphBuffer ()
#16 0x31137c76 in WebCore::Font::drawSimpleText ()
#17 0x31137ad2 in WebCore::Font::drawText ()
#18 0x31137a5e in drawAtPoint ()
#19 0x3117fdd4 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:measureOnly:] ()
#20 0x31180c50 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:] ()
#21 0x325ca46c in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:lineSpacing:includeEmoji:] ()
#22 0x325ca40a in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:lineSpacing:] ()
#23 0x325cb414 in -[UILabel _drawTextInRect:baselineCalculationOnly:] ()
#24 0x325cadf2 in -[UILabel drawTextInRect:] ()
#25 0x325cadaa in -[UILabel drawRect:] ()
#26 0x325c98e8 in -[UIView(CALayerDelegate) drawLayer:inContext:] ()
#27 0x30c6b308 in -[CALayer drawInContext:] ()
#28 0x30c6b190 in backing_callback ()
#29 0x30c6acb6 in CABackingStoreUpdate ()
#30 0x30c6a47e in -[CALayer _display] ()
#31 0x30c6a1ce in -[CALayer display] ()
#32 0x30c6a14a in CALayerDisplayIfNeeded ()
#33 0x30c6994a in CA::Context::commit_transaction ()
#34 0x30c696a8 in CA::Transaction::commit ()
#35 0x30c6f030 in CA::Transaction::observer_callback ()
#36 0x33519b56 in __CFRunLoopDoObservers ()
#37 0x33560a38 in CFRunLoopRunSpecific ()
#38 0x3356035c in CFRunLoopRunInMode ()
#39 0x30248b32 in GSEventRunModal ()
#40 0x30248bde in GSEventRun ()
#41 0x3259776e in -[UIApplication _run] ()
#42 0x32596472 in UIApplicationMain ()
#43 0x0000288e in main (argc=1, argv=0x2ffff618) at /Users/ahsan/Public/Drop Box/today1/main.m:13

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

征棹 2024-10-13 15:02:18

我相信字体名称是@"MarkerFelt-Thin"。尝试一下。

编辑:还有一个@"MarkerFelt-Wide"

I believe the font name is @"MarkerFelt-Thin". Try that.

Edit: There is also a @"MarkerFelt-Wide".

狠疯拽 2024-10-13 15:02:18

它会崩溃,因为你需要输入正确的字体名称,否则 UIKit 将尝试加载不存在的字体。因此,您应该检查您的字体名称。尝试使用 @"MarkerFelt" (无空格,而不是带有空格的 @"Marker Felt")。

如果您不确定该值应该是什么,应用程序商店中有几个应用程序可以为您获取当前可用字体的列表。您还可以使用此代码片段来记录控制台的字体名称:

   // Get all the fonts on the system
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
    printf( "Family: %s \n", [familyName UTF8String] );
    NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
    for( NSString *fontName in fontNames ){
        printf( "\tFont: %s \n", [fontName UTF8String] );
    }
}

编辑:

您还可以查看这篇文章 看看它是否对您有帮助。

It is crashing because you need to enter the correct font name, or else UIKit will try to load non-existent fonts. So, you should check your font name. Try using @"MarkerFelt" (no space instead of @"Marker Felt", with the space).

If you are not sure of what the value should be, there are several apps on the app store that can get the list of currently available fonts for you. You can also use this code snippet to log the font names to the console:

   // Get all the fonts on the system
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
    printf( "Family: %s \n", [familyName UTF8String] );
    NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
    for( NSString *fontName in fontNames ){
        printf( "\tFont: %s \n", [fontName UTF8String] );
    }
}

EDIT:

You can also have a look at this post and see if it helps you.

稚气少女 2024-10-13 15:02:18

值得一提的是,该应用程序进行繁重的处理

这也是我的观察!重负载使我的应用程序崩溃。目前我认为这个问题是框架错误,应该报告。 https://bugreport.apple.com

我在更新 CCLabelTTF (Cocos2D 0.99.5) 时崩溃,

Assertion failed: (cache->size >= g->size), function evict_glyph_entry_from_cache, file Fonts/CGFontCache.c, line 836.

Program received signal: “SIGABRT”.

This is the trace:

#0  0x304a0b2c in __kill ()
#1  0x304a0b20 in kill ()
#2  0x304a0b14 in raise ()
#3  0x304b7e3a in abort ()
#4  0x304a42f2 in __assert_rtn ()
#5  0x30f33648 in evict_glyph_entry_from_cache ()
#6  0x30ee5fc0 in expire_glyphs_nl ()
#7  0x30ee5f50 in CGFontCacheUnlock ()
#8  0x30ee5868 in CGGlyphLockUnlock ()
#9  0x33191ce0 in ripc_RenderGlyphs ()
#10 0x3319c9e0 in ripc_DrawGlyphs ()
#11 0x30edf7b0 in draw_glyphs ()
#12 0x30edf25c in CGContextShowGlyphsWithAdvances ()
#13 0x3109e010 in WebCore::Font::drawGlyphs ()
#14 0x3109dabc in WebCore::Font::drawGlyphBuffer ()
#15 0x3109d76c in WebCore::Font::drawSimpleText ()
#16 0x3109d5c8 in WebCore::Font::drawText ()
#17 0x3109d504 in drawAtPoint ()
#18 0x31101bd4 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:measureOnly:] ()
#19 0x31103a78 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:] ()
#20 0x331fcb60 in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:lineSpacing:includeEmoji:] ()
#21 0x332f5184 in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:] ()

#22 0x002f04a4 in -[CCTexture2D(Text) initWithString:dimensions:alignment:font:] (self=0x64e240, _cmd=0x455973, string=0x677040, dimensions={width = 28, height = 24}, alignment=UITextAlignmentCenter, uifont=0x649690) at /Users/SG/Documents/code/AlgWin/libs/cocos2d/CCTexture2D.m:405
#23 0x002f07a4 in -[CCTexture2D(Text) initWithString:fontName:fontSize:] (self=0x64e240, _cmd=0x44d3f4, string=0x677040, name=0x668990, size=20) at /Users/SG/Documents/code/AlgWin/libs/cocos2d/CCTexture2D.m:505
#24 0x002a8988 in -[CCLabelTTF setString:] (self=0x649490, _cmd=0x33f490cc, str=0x677040) at /Users/SG/Documents/code/AlgWin/libs/cocos2d/CCLabelTTF.m:91

观察 22 行与你的相同。

我将尝试提供代码来重现崩溃。也许只是一个无限循环就足够了。

One thing worth mentioning is that the application does heavy processing

This is also my observation! Heavy load crashes my app. At this moment I believe that this problem is the framework bug and should be reported. https://bugreport.apple.com

My crash comes when updating CCLabelTTF (Cocos2D 0.99.5)

Assertion failed: (cache->size >= g->size), function evict_glyph_entry_from_cache, file Fonts/CGFontCache.c, line 836.

Program received signal: “SIGABRT”.

This is the trace:

#0  0x304a0b2c in __kill ()
#1  0x304a0b20 in kill ()
#2  0x304a0b14 in raise ()
#3  0x304b7e3a in abort ()
#4  0x304a42f2 in __assert_rtn ()
#5  0x30f33648 in evict_glyph_entry_from_cache ()
#6  0x30ee5fc0 in expire_glyphs_nl ()
#7  0x30ee5f50 in CGFontCacheUnlock ()
#8  0x30ee5868 in CGGlyphLockUnlock ()
#9  0x33191ce0 in ripc_RenderGlyphs ()
#10 0x3319c9e0 in ripc_DrawGlyphs ()
#11 0x30edf7b0 in draw_glyphs ()
#12 0x30edf25c in CGContextShowGlyphsWithAdvances ()
#13 0x3109e010 in WebCore::Font::drawGlyphs ()
#14 0x3109dabc in WebCore::Font::drawGlyphBuffer ()
#15 0x3109d76c in WebCore::Font::drawSimpleText ()
#16 0x3109d5c8 in WebCore::Font::drawText ()
#17 0x3109d504 in drawAtPoint ()
#18 0x31101bd4 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:measureOnly:] ()
#19 0x31103a78 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:] ()
#20 0x331fcb60 in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:lineSpacing:includeEmoji:] ()
#21 0x332f5184 in -[NSString(UIStringDrawing) drawInRect:withFont:lineBreakMode:alignment:] ()

#22 0x002f04a4 in -[CCTexture2D(Text) initWithString:dimensions:alignment:font:] (self=0x64e240, _cmd=0x455973, string=0x677040, dimensions={width = 28, height = 24}, alignment=UITextAlignmentCenter, uifont=0x649690) at /Users/SG/Documents/code/AlgWin/libs/cocos2d/CCTexture2D.m:405
#23 0x002f07a4 in -[CCTexture2D(Text) initWithString:fontName:fontSize:] (self=0x64e240, _cmd=0x44d3f4, string=0x677040, name=0x668990, size=20) at /Users/SG/Documents/code/AlgWin/libs/cocos2d/CCTexture2D.m:505
#24 0x002a8988 in -[CCLabelTTF setString:] (self=0x649490, _cmd=0x33f490cc, str=0x677040) at /Users/SG/Documents/code/AlgWin/libs/cocos2d/CCLabelTTF.m:91

Observe that 22 lines are identical to yours.

I will try to come with the code to reproduce the crash. Maybe just an infinite loop will be enough.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文