Re: CGContextSelectFont spinlock
Re: CGContextSelectFont spinlock
- Subject: Re: CGContextSelectFont spinlock
- From: Aki Inoue <email@hidden>
- Date: Wed, 15 Sep 2010 17:14:01 -0700
Since I didn't see the actual backtrace, I cannot comment on what could be causing a spin lock deadlock.
One glaring point I'm concerned with this example is that the font name being passed to CGContextSelectFont is incorrect.
All of our font APIs, both on Mac OS X and iOS, are expecting the postscript name.
The font subsystem is optimized to query fonts via the postscript name efficiently.
In this case, the postscript name is "ComicSansMS-Bold". "Comic Sans MS Bold" is a fullname (a version of user visible name).
We're allowing queries with non-postscript name for API flexibility, but it costs in both CPU and memory (we need to bring in more data from the font files).
I recommend using the postscript name to see if the issue goes away.
Aki
On 15.9.2010, at 16:44, Stevo Brock wrote:
> Hi Vince,
>
> The details of the parameters to the function aren't important. The specific example I gave has been reduced down from some other code. In the end I'm not using Comic Sans, but it will come from an NSString.
>
> The point is that calling CGContextSelectFont() before doing some other undocumented something results in a spin lock.
>
> -Stevo
>
>
> On Sep 15, 2010, at 4:33 PM, Vince DeMarco wrote:
>
>>
>> On Sep 15, 2010, at 4:11 PM, Stevo Brock wrote:
>>
>>> Apparently the "font system" was not initialized before this call. Putting a "[UIFont familyNames]" somewhere previous causes things to roll just fine.
>>>
>>> I should mention that this is an OpenGL based app with minimal other system UI.
>>>
>>> -Stevo Brock
>>> Head of Development
>>> Monkey Tools, LLC
>>> www.monkey-tools.com
>>>
>>>
>>
>> This doesn't really matter but why are you doing this
>>
>> CGContextSelectFont(context, [@"Comic Sans MS Bold" UTF8String], 24.0, kCGEncodingMacRoman);
>>
>> Why not just
>>
>> CGContextSelectFont(context, "Comic Sans MS Bold", 24.0, kCGEncodingAscii);
>>
>> I changed the encoding from MacRoman to Ascii since it is actually ascii.
>>
>> You are creating a Constant NSString with the @"" then turning around and asking it for the UTF8 representation of that, which is the same as what i just typed above.
>>
>> Vince
>>
>>>
>>>
>>> On Sep 15, 2010, at 1:49 PM, Stevo Brock wrote:
>>>
>>>> I'm trying to add some custom font support to an iPad app and I keep running into a spinlock from CGContextSelectFont.
>>>>
>>>> Happens on SDK 4.0 Simulator and Device running 3.2.2. I've narrowed down the code to:
>>>>
>>>> CGContextRef context = CGBitmapContextCreate(&data, 1, 1, 8, 4, CGColorSpaceCreateDeviceRGB(),
>>>> kCGImageAlphaPremultipliedLast);
>>>> CGContextSelectFont(context, [@"Comic Sans MS Bold" UTF8String], 24.0, kCGEncodingMacRoman);
>>>> CGContextRelease(context);
>>>>
>>>> Depending on where I put this code, sometimes it runs through just fine and sometimes it spinlocks. The stack trace is just:
>>>>
>>>> 0: __spin_lock
>>>> 1: ??
>>>>
>>>> Where is it legal to call this function and why would it spin lock elsewhere? Help!
>>>>
>>>> -Stevo Brock
>>>> Head of Development
>>>> Monkey Tools, LLC
>>>> www.monkey-tools.com
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>>
>>>> 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
>>>
>>> _______________________________________________
>>>
>>> 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
>>
>
> _______________________________________________
>
> 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
_______________________________________________
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