嘿。我有一個非常簡單的文本輸出到緩衝區系統,它會隨機崩潰。對於DAYS會很好,然後有時會在幾分鐘內崩潰幾次。調用堆棧是幾乎完全對誰使用更高級別的控制其他人一樣: http://discussions.apple.com/thread.jspa?messageID=7949746 iPhone app crashed: Assertion failed function evict_glyph_entry_from_strike, file Fonts/CGFontCache.cNSString drawAtPoint iPhone上的崩潰(NSString drawAtPoint)
它崩潰的線(以下以及在drawTextToBuffer()): [的NSString drawAtPoint:CGPointMake(0,0) withFont:clFont];
我有同樣的調用「evict_glyph_entry_from_cache」與緊接其後的中止調用。
顯然它發生在其他人身上。我可以說我的NSString *在崩潰時非常好。我可以很好地從調試器中讀取文本。
static CGColorSpaceRef curColorSpace;
static CGContextRef myContext;
static float w, h;
static int iFontSize;
static NSString* sFontName;
static UIFont* clFont;
static int iLineHeight;
unsigned long* txb; /* 256x256x4 Buffer */
void selectFont(int iSize, NSString* sFont)
{
iFontSize = iSize;
clFont = [UIFont fontWithName:sFont size:iFontSize];
iLineHeight = (int)(ceil([clFont capHeight]));
}
void initText()
{
w = 256;
h = 256;
txb = (unsigned long*)malloc_(w * h * 4);
curColorSpace = CGColorSpaceCreateDeviceRGB();
myContext = CGBitmapContextCreate(txb, w, h, 8, w * 4, curColorSpace, kCGImageAlphaPremultipliedLast);
selectFont(12, @"Helvetica");
}
void drawTextToBuffer(NSString* nsString)
{
CGContextSaveGState(myContext);
CGContextSetRGBFillColor(myContext, 1, 1, 1, 1);
UIGraphicsPushContext(myContext);
/* This line will crash. It crashes even with constant Strings.. At the time of the crash, the pointer to nsString is perfectly fine. The data looks fine! */
[nsString drawAtPoint:CGPointMake(0, 0) withFont:clFont];
UIGraphicsPopContext();
CGContextRestoreGState(myContext);
}
它會發生在其他非Unicode支持方法,如CGContextShowTextAtPoint();這個callstack也是類似的。
這是iPhone上的任何一種已知問題嗎?或者,也許,這個原因之外的東西可能會在這個特定的調用(drawAtPoint)中導致異常?
感謝您的快速回答。我會試試看! – Kyle 2010-04-02 07:52:36