All exception break point is stopping for no reason on simulator
Asked Answered
O

7

61

This is very annoying, every time I'm trying to debug on the simulator with "all exception break point", app stops for no reason on this line:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([STAppDelegate class]));

Did any one else found him self struggling with this issue?

Thanks!

EDIT

Back trace on first throw:

 thread #1: tid = 0x1d96b, 0x36fbf540 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 3.2
    frame #0: 0x36fbf540 libc++abi.dylib`__cxa_throw
    frame #1: 0x306975cc libFontParser.dylib`TFileDescriptorContext::TFileDescriptorContext(char const*) + 112
    frame #2: 0x306973d8 libFontParser.dylib`TFileDataReference::TFileDataReference(char const*) + 164
    frame #3: 0x306971fc libFontParser.dylib`TFileDataSurrogate::TFileDataSurrogate(char const*, bool) + 188
    frame #4: 0x3069555a libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, TSimpleArray<TFont*>&, bool, short, char const*) + 1402
    frame #5: 0x30694a80 libFontParser.dylib`FPFontCreateFontsWithPath + 224
    frame #6: 0x2a5032bc libCGXType.A.dylib`create_private_data_with_path + 12
    frame #7: 0x2a3ca3c4 CoreGraphics`CGFontCreateFontsWithPath + 24
    frame #8: 0x2a4855d6 CoreGraphics`CGFontCreateFontsWithURL + 310
    frame #9: 0x313dfee4 GraphicsServices`AddFontsFromURLOrPath + 68
    frame #10: 0x313e39de GraphicsServices`__Initialize_block_invoke + 934
    frame #11: 0x0121fabe libdispatch.dylib`_dispatch_client_callout + 22
    frame #12: 0x01220750 libdispatch.dylib`dispatch_once_f + 100
    frame #13: 0x313df72c GraphicsServices`Initialize + 196
    frame #14: 0x377944c4 libobjc.A.dylib`_class_initialize + 536
    frame #15: 0x3779a046 libobjc.A.dylib`lookUpImpOrForward + 254
    frame #16: 0x37799f3e libobjc.A.dylib`_class_lookupMethodAndLoadCache3 + 34
    frame #17: 0x377a01f8 libobjc.A.dylib`_objc_msgSend_uncached + 24
    frame #18: 0x2d673b6e UIKit`-[UIStatusBarNewUIForegroundStyleAttributes makeTextFontForStyle:] + 78
    frame #19: 0x2d634d94 UIKit`-[UIStatusBarForegroundStyleAttributes textFontForStyle:] + 104
    frame #20: 0x2d5e767e UIKit`-[UIStatusBarServiceItemView updateForContentType:serviceString:serviceCrossfadeString:maxWidth:actions:] + 390
    frame #21: 0x2d5e74ee UIKit`-[UIStatusBarServiceItemView updateForNewData:actions:] + 186
    frame #22: 0x2d6428d0 UIKit`-[UIStatusBarItemView initWithItem:data:actions:style:] + 324
    frame #23: 0x2d642568 UIKit`-[UIStatusBarLayoutManager _createViewForItem:withData:actions:] + 108
    frame #24: 0x2d5e6f74 UIKit`-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:] + 264
    frame #25: 0x2d5e6e22 UIKit`-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:] + 74
    frame #26: 0x2d5e6c72 UIKit`-[UIStatusBarForegroundView _setStatusBarData:actions:animated:] + 162
    frame #27: 0x2d5e6b96 UIKit`-[UIStatusBarForegroundView setStatusBarData:actions:animated:] + 710
    frame #28: 0x2d671ebe UIKit`__44-[UIStatusBar _prepareToSetStyle:animation:]_block_invoke + 358
    frame #29: 0x2d5fc230 UIKit`+[UIView(Animation) performWithoutAnimation:] + 72
    frame #30: 0x2d66fcf4 UIKit`-[UIStatusBar _prepareToSetStyle:animation:] + 688
    frame #31: 0x2d6579ca UIKit`-[UIStatusBar _requestStyleAttributes:animationParameters:] + 290
    frame #32: 0x2d65696e UIKit`-[UIStatusBar requestStyle:animated:] + 86
    frame #33: 0x2d65559a UIKit`-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:] + 406
    frame #34: 0x2d85122a UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 970
    frame #35: 0x2d85bc68 UIKit`__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 36
    frame #36: 0x2d84fc5a UIKit`-[UIApplication workspaceDidEndTransaction:] + 130
    frame #37: 0x3086c0e0 FrontBoardServices`__31-[FBSSerialQueue performAsync:]_block_invoke + 12
    frame #38: 0x2a13782c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #39: 0x2a136af0 CoreFoundation`__CFRunLoopDoBlocks + 216
    frame #40: 0x2a13564a CoreFoundation`__CFRunLoopRun + 1714
    frame #41: 0x2a082db0 CoreFoundation`CFRunLoopRunSpecific + 476
    frame #42: 0x2a082bc2 CoreFoundation`CFRunLoopRunInMode + 106
    frame #43: 0x2d653c36 UIKit`-[UIApplication _run] + 558
    frame #44: 0x2d64ea30 UIKit`UIApplicationMain + 1440
  * frame #45: 0x003b4ec2 Stox`main(argc=1, argv=0x01200b08) + 178 at main.m:17

Third:

 thread #1: tid = 0x1d96b, 0x36fbf540 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 3.2
    frame #0: 0x36fbf540 libc++abi.dylib`__cxa_throw
    frame #1: 0x30798c22 libTrueTypeScaler.dylib`ScalerNewBlock(memoryContext*, long, long, void*, unsigned char, unsigned char) + 430
    frame #2: 0x3077e172 libTrueTypeScaler.dylib`OutlineToPath(memoryContext*, fnt_ElementType const*) + 178
    frame #3: 0x3079502a libTrueTypeScaler.dylib`ObtainDesiredOutline(memoryContext*, fnt_ElementType const*, unsigned long, void**) + 10
    frame #4: 0x3077e07c libTrueTypeScaler.dylib`RenderPath(fsg_SplineKey*, memoryContext*, scalerGlyph const*) + 36
    frame #5: 0x3077c980 libTrueTypeScaler.dylib`TTRenderGlyphs + 436
    frame #6: 0x306c5722 libFontParser.dylib`TConcreteFontScaler::CopyGlyphPath(unsigned short, CGAffineTransform const*) const + 378
    frame #7: 0x306a0ce6 libFontParser.dylib`FPFontCopyGlyphPath + 494
    frame #8: 0x2a3abb4a CoreGraphics`CGFontCreateGlyphPath + 30
    frame #9: 0x2a3aba56 CoreGraphics`CGFontCreateGlyphBitmap + 266
    frame #10: 0x2a3b3c1a CoreGraphics`CGGlyphBuilder::create_missing_bitmaps(CGGlyphIdentifier const*, unsigned long, CGGlyphBitmap const**) + 82
    frame #11: 0x2a6fd4dc libRIP.A.dylib`render_glyphs + 172
    frame #12: 0x2a6fcaca libRIP.A.dylib`draw_glyph_bitmaps + 906
    frame #13: 0x2a6fc430 libRIP.A.dylib`ripc_DrawGlyphs + 1108
    frame #14: 0x2a3a1002 CoreGraphics`draw_glyphs + 274
    frame #15: 0x2aaae268 CoreText`DrawSbixGlyphsAtPositions(TFont const*, CGFont*, TCFRef<__CFData const*> const&, unsigned short const*, CGPoint const*, unsigned long, CGContext*, CGAffineTransform, CGAffineTransform) + 1880
    frame #16: 0x2aa6bcce CoreText`CTFontDrawGlyphsWithAdvances + 470
    frame #17: 0x349eba1a UIFoundation`__NSStringDrawingEngine + 6710
    frame #18: 0x349efa64 UIFoundation`-[NSAttributedString(NSExtendedStringDrawing) drawWithRect:options:context:] + 532
    frame #19: 0x2d603370 UIKit`-[UILabel _drawTextInRect:baselineCalculationOnly:] + 4440
    frame #20: 0x2d668ed4 UIKit`-[UILabel drawTextInRect:] + 488
    frame #21: 0x2d668ce8 UIKit`-[UILabel drawRect:] + 84
    frame #22: 0x2d668c70 UIKit`-[UIView(CALayerDelegate) drawLayer:inContext:] + 400
    frame #23: 0x2d045910 QuartzCore`-[CALayer drawInContext:] + 228
    frame #24: 0x2d02f350 QuartzCore`CABackingStoreUpdate_ + 2068
    frame #25: 0x2d110b6c QuartzCore`___ZN2CA5Layer8display_Ev_block_invoke + 52
    frame #26: 0x2d02eb34 QuartzCore`x_blame_allocations + 88
    frame #27: 0x2d02e7e4 QuartzCore`CA::Layer::display_() + 1156
    frame #28: 0x2d012d9c QuartzCore`CA::Layer::display_if_needed(CA::Transaction*) + 200
    frame #29: 0x2d012a60 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
    frame #30: 0x2d012446 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 222
    frame #31: 0x2d012250 QuartzCore`CA::Transaction::commit() + 324
    frame #32: 0x2d5e51c8 UIKit`_afterCACommitHandler + 132
    frame #33: 0x2a137844 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
    frame #34: 0x2a134f28 CoreFoundation`__CFRunLoopDoObservers + 276
    frame #35: 0x2a13532a CoreFoundation`__CFRunLoopRun + 914
    frame #36: 0x2a082db0 CoreFoundation`CFRunLoopRunSpecific + 476
    frame #37: 0x2a082bc2 CoreFoundation`CFRunLoopRunInMode + 106
    frame #38: 0x313e7050 GraphicsServices`GSEventRunModal + 136
    frame #39: 0x2d64ea30 UIKit`UIApplicationMain + 1440
  * frame #40: 0x003b4ec2 Stox`main(argc=1, argv=0x01200b08) + 178 at main.m:17
Ornis answered 9/12, 2014 at 9:38 Comment(8)
You have an exception in your code. Disable the exceptions momentarily, continue execution and read the console logs.Ulibarri
I continue after the exception, and after about 3 continue presses (Each time is stops again at the same point), I get a log "void CGPathAddLineToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat): no current point." And the app continues NORMELLY! So strange..Ornis
Are you doing any custom drawing? That error usually occurs when you call CGContextAddLineToPoint was called before CGContextMoveToPoint.Ulibarri
Yeah, the exception is probably caught by something and handled.Oxime
@Ulibarri I use the is manny places at my app.. So its a-bit hard to trace... But the strange thing is as I sad, it only appears at the log after two times i press continue! Plus the app doesn't crush! Is this common?Ornis
As @JeremyHuddlestonSequoia said, the exception is probably caught and handled. Have you checked your drawing code to see if you have any calls to CGContextAddLineToPoint before CGContextMoveToPoint?Ulibarri
@Ulibarri Yah, I literally went through every place in my code with "CGContextMoveToPoint" and tried to comment it out, No help there :/Ornis
show the thread's backtrace when the exception is thrown.Oxime
T
81

I was just experiencing the same exact problem and tracked down the issue.

Make sure that all fonts that you specify in your Info.plist under Fonts provided by this application are actually in your application bundle.

Tufted answered 23/1, 2015 at 18:6 Comment(17)
after pulling lots of hair and trying all possibilities I could, I found your suggestion and it worked for meVlf
You sir are a hero, a mistyped font was my issue as well.Vassal
Had the same problem (was missing one of my fonts from the plist). Thanks!Colman
I had a legacy font in one of my .xib files. Changing it to system font fixed the issue. Thanks!Dialectologist
@Dialectologist - You are a legend. I had an old font hiding in my storyboard :)Marauding
How did you find your old font? @MatthewCawleyIams
It was a bit of trial an error. Based on where the crash was happening, I knew roughly which screen in my storyboard was causing the issue. I just checked each label to see if there was any wrong fonts selected. Once I found the wrong font, I was able to look in the XML for the font to see how it was being referenced (Family Name). I then did a search for that font's family name and that highlighted any incorrect fonts in my storyboards.Marauding
I had the same legacy font problem. Here is, how I found it: find . -name "*.xib" -or -name "*.storyboard" -exec grep -i font {} \; | grep family Searching the project then for the name revealed the ui element. (I am no expert on shell)Monkhood
I really thank you! Was looking for this issue for some time.Cobbett
I've had this happen for when the font was renamed, but storyboard had old name. So even though all worked and right font was shown the exception was thrown. Open and save storyboard and that's fixed.Catenate
I am using the system built-in Avenir Next Condensed font (selected from Storyboards). Setting this to System font resolves the issue. How can I keep using this font? Do I have to declare using system fonts in the Info.plist somehow too?Equities
@Equities Wait, the system font is a font automatically selected by the system, the default font so to speak. In most (if not all) cases that will be the San Francisco typeface. All other fonts are custom by definition, even if selectable in IB and already provided as one of the default fonts.Vehicle
Of course. I mean System font does not throw the exception, but using Avenir does. Avenir is a custom font, but provided by the system.Equities
@Equities did you fix this issue? I am having the same problem with my Avenir font (should be included by the system).Secularity
No. I have changed the symbolic breakpoint to Objective C-only.Equities
Improving on @Monkhood regex: find . -name "*.xib" -or -name "*.storyboard" -exec bash -c 'echo "{}"; grep -i font "{}"' \; | grep -E 'family|^\.' This will also print the filename containing the match.Radborne
Just a heads up: the command line search above did not find all the problematic fonts for me. I had to search for "customFont". This brought up results in two legacy xibs even though the UI elements in the xibs did not actually use that font.Makassar
R
50

There's a more accurate way of tracking down the suspect font in your app using the debugger and the fact that it's conveniently stopped at the call.

Step 1: Reproduce the __cxa_throw breakpoint

Usually this happens when instantiating one of (or possibly the first) UIView object in your app. You'll see your debugger has broken and you'll have a stack such as this:

Stack Trace of exception loading font

Step 2: Select the entry in the stack trace with the symbol FPFontCreateFontsWithPath

In my case, this entry was line 7 in the stack.

Selected Stack Entry

If you take a look at the disassembly, you'll notice the function signature of this entry:

Stack Entry showing function signature symbols

Ah, cool! Looks like it takes some C strings. I betcha one of those is a filepath too!

Step 3: Locate that string in the app memory

I'm running this in a (x86_64) simulator, which on my computer stores the function arguments in some of the registers beginning with r. More details on registers here.

General Purpose Registers

Either press Shift+Command+M or select the "Debug > Debug Workflow > View Memory" option from the menu.

At the bottom of this view, go through the registers one by one and enter the addresses. In my case, r14 contained the path of the file.

Memory location of filepath

Alright, so now I know the font that's messed up. It's looking for HelveticaNeue.ttc. Let's find the reference to that in the project.

Open a terminal, navigate to your project and run:

$ ~/W/X/project> grep -R "HelveticaNeue" ./
.//MyProject/Main.Storyboard:        <array key="HelveticaNeue.ttc">
.//MyProject/Main.Storyboard:            <string>HelveticaNeue</string>
.//MyProject/Main.Storyboard:                                <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="18"/>

Awesome, now either switch those to system by replacing name="HelveticaNeue" family="Helvetica Neue" with type="system", open the storyboard and manually edit them or add a reference to the missing font to your app (info.plist and target).

Step 4: Celebrate 🎉 🎊 🍾 🍻

Radborne answered 19/1, 2018 at 18:40 Comment(6)
Awesome tip, thank you so much! In my case, the [View memory of "r15"] was not revealing the font name, but right-clicking on the register and choosing [Print description of "r15"] showed it in the Console.Levalloisian
Thanks a lot! There are reasons to celebrate after a battle won against the fonts! Just a couple of notes that can be useful to someone: * you can add files as .ttc (standard mac format) * In the .plist file add the whole filename (with extension): ie helveticaneue.ttcOquendo
Didn't figure out how to het step 3, but we can select in stack trace penultimate function and check register in console "register read r14" and view the resulting memory address in View Memory tools (pointed above)Purple
Super useful advice, my debugging powers just got a +1Offal
Please explain more to hit step 3, I was not able to locate register.Braxton
Extra info for step 3: The debugger's variable view has a toggle in the bottom left corner with three options: 1. Auto (default), 2. Local Variables, and 3. All Variables, Registers, Globals and Statics. Select option 3 to show the registers.Cush
E
39

As the backtrace shows, the app didn't stop for no reason. It stopped because an exception was thrown, and it looks like a C++ exception.

Unlike Objective-C, where exceptions should only be thrown as the result of programming errors and therefore are very rare, there is a lot of C++ code around that throws and catches lots of exceptions. In that situation, probably best to only set a breakpoint on Objective-C exceptions, not all exceptions.

Eigenfunction answered 10/12, 2014 at 18:58 Comment(1)
If anyone needs to do this just right click on the breakpoint, edit and switch from "all" to "objective-c"Idoux
S
4

If you didn't find a problem in .plist file maybe the problem is in your .storyboard file.. Open it as source code from Xcode or in textView from Finder - search for <customFonts key="customFonts"> I had there some old irrelevant array/font inside...:) just deleted it and it stopped

Shantay answered 27/12, 2017 at 15:39 Comment(1)
Your answer totally solved it for me! I searched my storyboards and .xib files for "customFont" and found it in two of them. When I hacked that section out of both files, the problem was solved! It was just referencing a system font HelveticaNeue-Bold anyhow. (I don't name any fonts in my app's .plist so the main solution in this SO wasn't helpful for me).Unman
H
2

In my case the reference was inside xcuserdata :

user$ grep -R "HelveticaNeue" ./
Binary file .//MyProject.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate matches
Handspring answered 17/2, 2018 at 13:2 Comment(0)
S
0

An exception is being thrown, but the caller (e.g. in libFontParser and libTrueTypeScaler) is handling it and it is not reaching your program.

Unless you see other evidence of a problem (such as a log message) or the exception reaches your program, assume that the implementation is handling it. You can continue past these instances in the debugger without worry.

Sumpter answered 10/12, 2014 at 17:49 Comment(2)
Thanks for the answer, But i'm looking for a way to avoid these exceptions because its very enjoying having to press "Continue" three times. every time i run the app.Ornis
You can't avoid the exception. You can change the "Exceptions" breakpoint in Xcode.Eigenfunction
I
0

I solved this issue by combining nmock's answer with DaNLtR's answer.

So at first i looked for <customFonts key="customFonts"> and there was Montserrat-Light present in it.
But it wasn't neither present in info.plist nor was it added to the project.

The problem vanished once i bundled Montserrat-Light.ttf into the project and added an entry for this font under Fonts provided by this application in info.plist.

So following is the summary of above mentioned solution:

  1. Look for your Storyboard or Xib files for any Custom Fonts.
    You'll find them in <customFonts key="customFonts">
  2. If there is Actually a Custom Font mentioned, then follow steps 3 and 4
  3. Add the font to your Xcode Project.
  4. Add an entry to info.plist under Fonts provided by this application.
    This entry should be name of the font file followed by its extension.
  5. In case if <customFonts key="customFonts"> doesn't contain any Custom Font (e.g: Helvetica-Neue etc), then try deleting the <customFonts key="customFonts"> entry in Stroyboard or Xib file as stated in DaNLtR's answer

I know its very late to answer but hope this helps someone.

Illstarred answered 7/2, 2019 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.