App Very Slow With On-Device Testing With Instruments

Discussion in 'iOS Programming' started by Darkroom, Jul 24, 2009.

  1. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    when i test my app on-device using instruments, it's very slow, and sometimes takes seconds to register a tap, or for a view to display. i'm also seeing small leak spikes and it seems to lazily load views that are suppose to simply load at launch.

    i can't help but feel it's related to this message i always receive in the console when the app is booting up from xcode on-device.

    [Session started at 2009-07-24 17:01:47 -0400.]
    GNU gdb 6.3.50-20050815 (Apple version gdb-1119) (Thu May 14 05:35:37 UTC 2009)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
    Loading program into debugger…
    sharedlibrary apply-load-rules all
    Program loaded.
    target remote-mobile /tmp/.XcodeGDBRemote-82068-78
    Switching to remote-macosx protocol
    mem 0x1000 0x3fffffff cache
    mem 0x40000000 0xffffffff none
    mem 0x00000000 0x0fff none
    [Switching to thread 10755]
    [Switching to thread 10755]
    (gdb) continue
    [COLOR="Red"]warning: Unable to read symbols for ""/Users/me/Desktop/App Name/build/Release-iphoneos"/App Name" (file not found).
    warning: Unable to read symbols for ""/Users/me/Desktop/App Name/build/Release-iphoneos"/App Name" (file not found).[/COLOR]
    [COLOR="Green"]//then later i stop the app[/COLOR]
    Debugger stopped.
    Program exited with status value:0.
    i've checked the package contents for "App" and there does exist the App Name unix executable file, so i don't know why xCode is saying it's not there.

    i recall testing on-device before i received this warning and it wasn't slow. but ever since last week i always receive this warning, and on-device testing with instruments lags and seems buggy. on-device testing without instruments running is fine, as is simulator-testing with instruments running or not.


    [EDIT] could all this simply be on the count of the USB cable being too slow? it seems that the only Instruments mode that lags very hard is Object Allocations / Leaks, while the others are fine. attached below is a picture demoing Instruments running in Simulator (top) versus Instruments running On-Device (bottom). on-device testing running with Object Alloc / Leakes in Instruments often crashes the app after i press a "Back" button, which dismisses a model view (without animation) to return to the main NIB / main menu. however, before dismissing the model view the app does write a default and stop an animation. this combo seems lethal, but it shouldn't be.

    perhaps it's just buggy 3.0 software that Instruments has trouble with? i really don't think there is anything terribly wrong with my code.

    Attached Files:

  2. Darkroom thread starter Guest


    Dec 15, 2006
    Montréal, Canada
    so apparently the warning i was receiving was because 3.0 has issues with spaces in folders and file names, but it doesn't mean anything and no harm is caused... apparently...

    but i'm still having a difficult time finding the source of the crash when it happens. it doesn't always happen, which is what makes finding the source difficult, and it doesn't only happen when using instruments, but it does only ever happen on device (never simulator). additionally, when it does crash, nothing is written in the console about the crash. the program just ends as if i pressed stop, but it doesn't even say exited with 0.

    any ideas?
  3. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    I think I suggested that to you a week ago.

    Have you looked at the device console?

    What is the memory footprint of your app when it crashes?

    Look at the apple debugger magic tech note. Turn on zombies. I think you can turn on malloc debugging.
  4. Darkroom thread starter Guest


    Dec 15, 2006
    Montréal, Canada
    on device my app will continuously climb with objectAlloc, which doesn't seem right. in the simulator it will objectAlloc a max of around 850kb.

    i've noticed this specific crash happens all the time when music from iPod is also playing, so it seems like a memory issue? but the crash also happens if the app has just started, so maybe it's not memory?

    my crash log from the device:
    Incident Identifier: D341AAAB-66E8-427F-9B2D-5A30003FD78C
    CrashReporter Key:   0f79e2da3a4a6c489dfc8621ba608176f4e7b257
    Process:         App Name [4856]
    Path:            /var/mobile/Applications/2D5BE103-9A69-40A4-8091-CF016E15AA86/App Name
    Identifier:      App Name
    Version:         ??? (???)
    Code Type:       ARM (Native)
    Parent Process:  launchd [1]
    Date/Time:       2009-07-26 14:37:22.829 -0400
    OS Version:      iPhone OS 3.0 (7A341)
    Report Version:  104
    Exception Type:  EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000b
    Crashed Thread:  0
    Thread 0 Crashed:
    0   libobjc.A.dylib               	0x30011940 objc_msgSend + 20
    1   App Name                    	0x00005d6c -[App_NameApplicationMode actionButtonsTopToolBar:] (App_NameApplicationMode.m:578)
    2   CoreFoundation                	0x30256dd4 -[NSObject performSelector:withObject:withObject:] + 20
    3   UIKit                         	0x3096e0d0 -[UIApplication sendAction:to:from:forEvent:] + 128
    4   UIKit                         	0x3096e038 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
    5   UIKit                         	0x3096e000 -[UIControl sendAction:to:forEvent:] + 44
    6   UIKit                         	0x3096dc58 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 528
    7   UIKit                         	0x309a6e9c -[UIControl touchesEnded:withEvent:] + 452
    8   UIKit                         	0x309a60d4 -[UIWindow _sendTouchesForEvent:] + 520
    9   UIKit                         	0x309a5464 -[UIWindow sendEvent:] + 108
    10  UIKit                         	0x30936e3c -[UIApplication sendEvent:] + 400
    11  UIKit                         	0x30936874 _UIApplicationHandleEvent + 4336
    12  GraphicsServices              	0x32046964 PurpleEventCallback + 1028
    13  CoreFoundation                	0x30254a70 CFRunLoopRunSpecific + 2296
    14  CoreFoundation                	0x30254164 CFRunLoopRunInMode + 44
    15  GraphicsServices              	0x3204529c GSEventRunModal + 188
    16  UIKit                         	0x308f0374 -[UIApplication _run] + 552
    17  UIKit                         	0x308eea8c UIApplicationMain + 960
    18  App Name                    	0x00002090 main (main.m:14)
    19  App Name                    	0x0000202c start + 44
    Thread 1:
    0   libSystem.B.dylib             	0x31d47158 mach_msg_trap + 20
    1   libSystem.B.dylib             	0x31d49ed8 mach_msg + 60
    2   CoreFoundation                	0x3025454e CFRunLoopRunSpecific + 982
    3   CoreFoundation                	0x30254164 CFRunLoopRunInMode + 44
    4   WebCore                       	0x3588dbc8 __ZL12RunWebThreadPv + 412
    5   libSystem.B.dylib             	0x31d705a0 _pthread_body + 20
    Thread 0 crashed with ARM Thread State:
        r0: 0x00130420    r1: 0x0000aac0      r2: 0x00000000      r3: 0x0001023c
        r4: 0x00000003    r5: 0x00126690      r6: 0x0012ecb0      r7: 0x2fffed20
        r8: 0x00126d20    r9: 0x3029d17c     r10: 0x0012ecb0     r11: 0x00000003
        ip: 0x0000e05c    sp: 0x2fffed0c      lr: 0x00005d73      pc: 0x30011940
      cpsr: 0x20000010
    Binary Images:
        0x1000 -     0xdfff +App Name armv6  <67f6f36e530ca1febeb98b42845ce840> /var/mobile/Applications/2D5BE103-9A69-40A4-8091-CF016E15AA86/App Name
       0xf7000 -    0xf8fff armv6  <7943354b648b9518f46a835d5359e45a> /usr/lib/info/
    0x2fe00000 - 0x2fe26fff  dyld armv6  <384bf84ebe2b822c3cb75fce3e8647d6> /usr/lib/dyld
    0x30000000 - 0x30008fff  libgcc_s.1.dylib armv6  <b404b5f84fa4293f0dd35a469b8b6894> /usr/lib/libgcc_s.1.dylib
    0x3000c000 - 0x3015bfff  libobjc.A.dylib armv6  <92636cf8b8e8f3c10721667c48ca182b> /usr/lib/libobjc.A.dylib
    0x301ca000 - 0x301d8fff  libz.1.dylib armv6  <bb2c65d59f36ea2ffdf39aa4d8e49430> /usr/lib/libz.1.dylib
    0x301fd000 - 0x302a8fff  CoreFoundation armv6  <3e02f5628a56bce4c9eb1c5e49c863d4> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
    0x30501000 - 0x305f5fff  Foundation armv6  <c4fc557994aee708dd4fb14ed4fd875f> /System/Library/Frameworks/Foundation.framework/Foundation
    0x3071d000 - 0x30729fff  CoreVideo armv6  <5404da375ad190f3e1404e5e8a70f764> /System/Library/PrivateFrameworks/CoreVideo.framework/CoreVideo
    0x3073a000 - 0x30760fff  AppSupport armv6  <1baa1e22eb94eb405d724a2f6b219f53> /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport
    0x30778000 - 0x3077dfff  liblockdown.dylib armv6  <e4f0b16194fac3bd426e679a3c35c38b> /usr/lib/liblockdown.dylib
    0x308ed000 - 0x31521fff  UIKit armv6  <73cf70d65e1afef2a6ae94fb81bf2fe4> /System/Library/Frameworks/UIKit.framework/UIKit
    0x31885000 - 0x318d1fff  IOKit armv6  <56ba629c062ac21a045914430412c5f4> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x318e9000 - 0x31aa2fff  CoreGraphics armv6  <80bccae4ab17a49f7fc3a66bb2def894> /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
    0x31af1000 - 0x31b58fff  CFNetwork armv6  <863076d9b768c76272e3f0f686ca355d> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
    0x31bb2000 - 0x31bc8fff  OpenGLES armv6  <2c30348868df45d3b8e0e398e0e4f727> /System/Library/Frameworks/OpenGLES.framework/OpenGLES
    0x31bcf000 - 0x31cccfff  JavaScriptCore armv6  <619918c7282aa5b53ac3ad32c320b7a5> /System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
    0x31d46000 - 0x31e69fff  libSystem.B.dylib armv6  <f8d95df9776974bbe640911fee96c59d> /usr/lib/libSystem.B.dylib
    0x31ea9000 - 0x31feffff  AudioToolbox armv6  <cd7d22e01299f0d589878c2417c7ff18> /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
    0x32041000 - 0x3204bfff  GraphicsServices armv6  <99b0baa68c257ca5d2fed21bd409ea20> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
    0x3209b000 - 0x320cefff  Security armv6  <34c21a865d91e9a13477e9395c516f8c> /System/Library/Frameworks/Security.framework/Security
    0x320e8000 - 0x32194fff  ImageIO armv6  <44921d26b2b796c2c707c87c68026b16> /System/Library/PrivateFrameworks/ImageIO.framework/ImageIO
    0x32369000 - 0x3239cfff  SystemConfiguration armv6  <c295ae48e7c85c02ae396f3dae1901df> /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration
    0x324c6000 - 0x32521fff  CoreAudio armv6  <a3189b3cffe9fdb8007e8a4fd54b28e2> /System/Library/Frameworks/CoreAudio.framework/CoreAudio
    0x325b2000 - 0x325cefff  AddressBook armv6  <3023a336aec321324b5a310ee66687f1> /System/Library/Frameworks/AddressBook.framework/AddressBook
    0x3291c000 - 0x329c4fff  QuartzCore armv6  <1cf2a12e661e1a49f90553b013283b29> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
    0x32a16000 - 0x32a16fff  CoreSurface armv6  <2c60135f696b1a787443c4a68e1aced2> /System/Library/PrivateFrameworks/CoreSurface.framework/CoreSurface
    0x32a1b000 - 0x32a1cfff  IOMobileFramebuffer armv6  <05aa0565d0f6813003dc5dc175af6048> /System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer
    0x32e0c000 - 0x32f0dfff  libicucore.A.dylib armv6  <3f78cbbe6b5b7d3b4c5753627fcebdee> /usr/lib/libicucore.A.dylib
    0x3311e000 - 0x33213fff  libxml2.2.dylib armv6  <3398aecf5ef07d7bbe6673fc9ab570fb> /usr/lib/libxml2.2.dylib
    0x332c9000 - 0x33372fff  WebKit armv6  <d5aabd50737ee994787181afaf83c81e> /System/Library/PrivateFrameworks/WebKit.framework/WebKit
    0x33851000 - 0x3388efff  libCGFreetype.A.dylib armv6  <5ff3f70d08b55ca7417766d4a6ba2fc2> /System/Library/Frameworks/CoreGraphics.framework/Resources/libCGFreetype.A.dylib
    0x3412b000 - 0x3414dfff  libRIP.A.dylib armv6  <bd577e4e309c7270149cc7765aac1625> /System/Library/Frameworks/CoreGraphics.framework/Resources/libRIP.A.dylib
    0x3415c000 - 0x34165fff  SpringBoardServices armv6  <4997adf422af4a9eecf25aa9bcaf8fc9> /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices
    0x347f5000 - 0x34812fff  libresolv.9.dylib armv6  <7e34a4dd5c5b0400d10b01e998d5b2de> /usr/lib/libresolv.9.dylib
    0x34c0e000 - 0x34c14fff  MBX2D armv6  <6815ceba8853af0095f160b6d3c88937> /System/Library/PrivateFrameworks/MBX2D.framework/MBX2D
    0x3553e000 - 0x3557bfff  CoreText armv6  <c584fae4a8877461b1fc27879ac762bc> /System/Library/PrivateFrameworks/CoreText.framework/CoreText
    0x355c8000 - 0x355ccfff  IOSurface armv6  <d2585af66f593d95adf6d1fab0181b1a> /System/Library/PrivateFrameworks/IOSurface.framework/IOSurface
    0x3580b000 - 0x35f5afff  WebCore armv6  <98f065e46e4c230bf091abaf6da60c16> /System/Library/PrivateFrameworks/WebCore.framework/WebCore
    0x36422000 - 0x3647cfff  libsqlite3.dylib armv6  <456f75f502443d281147f36f6ed4c3d3> /usr/lib/libsqlite3.dylib
    0x3648a000 - 0x36493fff  libkxld.dylib armv6  <2528ee7a4fd041090850f1845c393b84> /usr/lib/system/libkxld.dylib
    0x36496000 - 0x364a6fff  libbsm.0.dylib armv6  <44ee6b2c59cd5aa70d59f7d0d0d3b0b2> /usr/lib/libbsm.0.dylib
    0x37124000 - 0x3712efff  MobileCoreServices armv6  <9adf227705e932c47e703f73ca1d87c2> /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
    0x3748a000 - 0x374f3fff  libstdc++.6.dylib armv6  <44d54be7409eedbf35157cc538ea660b> /usr/lib/libstdc++.6.dylib
    0x37c74000 - 0x37c74fff  Accelerate armv6  <e3325738fdc407edc125d921d2a90839> /System/Library/PrivateFrameworks/Accelerate.framework/Accelerate
    0x37cc8000 - 0x37d0bfff  libvDSP.dylib armv6  <5632d3e7799c5c90540157938bce4b95> /System/Library/PrivateFrameworks/Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib
    0x37d12000 - 0x37d12fff  vecLib armv6  <eb68bab288e9f047d876848490b162fc> /System/Library/PrivateFrameworks/Accelerate.framework/Frameworks/vecLib.framework/vecLib
    App Name
  5. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    The usual cause of a crash in objc_msgSend is that memory has been trashed. I assume that this method [App_NameApplicationMode actionButtonsTopToolBar:] is in your app's code. Probably there's a bug in that method that corrupts the stack.
  6. Darkroom thread starter Guest


    Dec 15, 2006
    Montréal, Canada
    it's true, you did. but i didn't (still don't) know how to easily change the name of an app to test it, so i believed you after i read about it on another message board. now in hindsight, i suppose i could have just built an app base app and test it...

    ok, going absolutely crazy out of my mind. now the crash logs are saying this instead. not exactly sure if they are different. they might not be.

    Exception Type:  EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000c
    Crashed Thread:  0
    Thread 0 Crashed:
    0   libobjc.A.dylib               	0x30011940 objc_msgSend + 20
    1   UIKit                         	0x3096e0d0 -[UIApplication sendAction:to:from:forEvent:] + 128
    2   UIKit                         	0x3096e038 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
    3   UIKit                         	0x3096e000 -[UIControl sendAction:to:forEvent:] + 44
    4   UIKit                         	0x3096dc58 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 528
    5   UIKit                         	0x309a6e9c -[UIControl touchesEnded:withEvent:] + 452
    6   UIKit                         	0x309a60d4 -[UIWindow _sendTouchesForEvent:] + 520
    7   UIKit                         	0x309a5464 -[UIWindow sendEvent:] + 108
    8   UIKit                         	0x30936e3c -[UIApplication sendEvent:] + 400
    9   UIKit                         	0x30936874 _UIApplicationHandleEvent + 4336
    10  GraphicsServices              	0x32046964 PurpleEventCallback + 1028
    11  CoreFoundation                	0x30254a70 CFRunLoopRunSpecific + 2296
    12  CoreFoundation                	0x30254164 CFRunLoopRunInMode + 44
    13  GraphicsServices              	0x3204529c GSEventRunModal + 188
    14  UIKit                         	0x308f0374 -[UIApplication _run] + 552
    15  UIKit                         	0x308eea8c UIApplicationMain + 960
    16  App Name                    	0x00002090 main (main.m:14)
    17  App Name                    	0x0000202c start + 44App Name
    this crash ONLY ever happens when i'm playing music while trying to use the app. in fact, it only starts to happen after the music has been playing for about a 30 seconds or so. there are quite a few UIImageViews that are animating, starting and stopping when i exit from the application mode back to the main menu, which is where the app crashes.

    i've tried reproducing this crash, but i can't. i've made a watered down version of my app (also called App Name, but the above crash report doesn't reflect this build) that demos how it's built and what basically happens. this won't crash the same as my real app, but i feel that all the important elements are included here (except, of course for size and object allocations). if you could take a look at it and tell me what you seem wrong that would be great. i understand this code isn't refactored well, it was somewhat of a quick build. i would seriously appreciate it.

    i'm concerned that i should be setting up didReceiveMemoryWarning method, but i'm not really sure how that works with the case of model views, and besides, the device console types the app as Crashed, not Low Memory.

    Attached Files:

  7. Darkroom thread starter Guest


    Dec 15, 2006
    Montréal, Canada

    ok... so i found the slimy, vicious, evil, little bug, hiding in the dark recesses of an IBOutlet connection...

    you were absolutely correct! the code was trying to access something that was released. i have my own custom highlights on my buttons, and i realized that the touchUpInside connection of the exit button was connected to a method that faded out the custom highlight as well as the method to dismiss the model view. so clearly it was trying to fade the custom highlight out after the model view was dismissed / custom highlight inaccessible...

    however, it's interesting how it only seemed to happen when music was playing, and very rarely with just the app open. i imagine the device needed all of its resources / speed to actually execute thru my error.

    prime example of why one should never ever rely on only debugging in the simulator.

    i'd still be interested to have you review my project sample to get some of your feedback. especially concerning the potential dangers of continuously setting the frame of a view with dragging (perhaps it's allocation over-kill?), also about didReceiveMemoryWarning on model views (or any views really, i just don't really get that).

Share This Page