0

I have inherited an iOS app which uses the Irrlicht engine for most of its functionality, and have come across a rather annoying problem.

We are using Facebook Connect to log in and register, due to what I can only assume are other memory issues I am using the FB app on iPhones and the dialog window on iPads.

However on an iPod Touch 4th gen the app crashes as soon as the login dialog appears. It works on the other devices - with a catch. If the iPad 1 is plugged into the Mac then that will also crash when the Facebook Dialog appears, regardless of whether I am actually running it through xcode or not. The 3GS seems to work no matter what, and I believe the iPad 3 works reliably as well. The iPad 3 and the problematic iPod are not on site so I am unable to test them as thoroughly.

Is there any reason why the iPod version would be crashing so readily, given that the 3GS version has no problems. They are both currently using the same set of assets, so if that was the problem I would expect them to both crash.

Any suggestions?

Edit: Here is the console output on the affected device.

May 30 23:16:23 unknown kernel[0] <Debug>: launchd[1298] Builtin profile: container (sandbox)

May 30 23:16:23 unknown kernel[0] <Debug>: launchd[1298] Container: /private/var/mobile/Applications/87B7926A-AA91-48BA-B7EE-73BCDBACCC17 [69] (sandbox)

May 30 23:16:23 unknown Golman[1298] <Warning>: Unknown class AdMobView in Interface Builder file.

May 30 23:16:37 unknown MobileMail[1245] <Warning>: Received memory warning.

May 30 23:16:38 unknown Golman[1298] <Warning>: Received memory warning.

May 30 23:16:38 unknown Golman[1298] <Warning>: Warning: Libinfo call to mDNSResponder on main thread

May 30 23:16:38 unknown SpringBoard[51] <Warning>: Received memory warning.

May 30 23:16:42 unknown Golman[1298] <Warning>: enter login page

May 30 23:16:53 unknown Golman[1298] <Warning>: leave login page

May 30 23:16:53 unknown Golman[1298] <Warning>: enter login page

May 30 23:17:00 unknown Golman[1298] <Warning>: leave login page

May 30 23:17:00 unknown Golman[1298] <Warning>: enter login page

May 30 23:17:18 unknown Golman[1298] <Warning>: leave login page

May 30 23:17:18 unknown Golman[1298] <Warning>: enter login page

May 30 23:17:21 unknown Golman[1298] <Warning>: leave login page

May 30 23:17:21 unknown Golman[1298] <Warning>: enter login page

May 30 23:17:24 unknown Golman[1298] <Warning>: leave login page

May 30 23:17:24 unknown Golman[1298] <Warning>: enter login page

May 30 23:17:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.plantpot.golman[0xaf95]) Exited: Killed: 9

May 30 23:17:38 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created

May 30 23:17:39 unknown SpringBoard[51] <Warning>: Unable to send deactivation event to <SBApplication: 0xfda12e0> com.plantpot.golman userLaunch statusBarWindowContextId = 1325144038 statusBarOrientation = 3  activate:  deactivate: animate animationStart = 36566.94129066667 animationScale = 0.001 animationDuration = 0.4 : (ipc/send) invalid destination port

May 30 23:17:39 unknown SpringBoard[51] <Warning>: Application 'Golman' exited abnormally with signal 9: Killed: 9

May 30 23:17:40 unknown kernel[0] <Debug>: launchd[1304] Builtin profile: container (sandbox)

May 30 23:17:40 unknown kernel[0] <Debug>: launchd[1304] Container: /private/var/mobile/Applications/8FF2FEC5-D24D-4DBB-BC6B-782F89051CFC [69] (sandbox)

May 30 23:17:41 unknown ReportCrash[1303] <Notice>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-05-30-231741.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0

May 30 23:17:46 unknown UIKitApplication:com.facebook.Facebook[0x4c2b][1304] <Notice>: wait_fences: failed to receive reply: 10004003

May 30 23:17:50 unknown Golman[1308] <Warning>: Unknown class AdMobView in Interface Builder file.

May 30 23:17:50 unknown kernel[0] <Debug>: launchd[1308] Builtin profile: container (sandbox)

May 30 23:17:50 unknown kernel[0] <Debug>: launchd[1308] Container: /private/var/mobile/Applications/87B7926A-AA91-48BA-B7EE-73BCDBACCC17 [69] (sandbox)

May 30 23:17:51 unknown Golman[1308] <Warning>: Logged into facebook

May 30 23:18:01 unknown MobileMail[1245] <Warning>: Received memory warning.

May 30 23:18:02 unknown SpringBoard[51] <Warning>: Received memory warning.

May 30 23:18:03 unknown Golman[1308] <Warning>: void SendDelegateMessage(NSInvocation*): delegate (webView:didCommitLoadForFrame:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

May 30 23:18:05 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilemail[0x6fdf]) Exited: Killed: 9

May 30 23:18:05 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created

May 30 23:18:05 unknown SpringBoard[51] <Warning>: pid_suspend failed for [1304]: Unknown error: -1, Unknown error: -1

May 30 23:18:05 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.facebook.Facebook[0x4c2b]) Exited: Killed: 9

May 30 23:18:05 unknown SpringBoard[51] <Warning>: Application 'Mail' exited abnormally with signal 9: Killed: 9

May 30 23:18:06 unknown SpringBoard[51] <Warning>: Application 'Facebook' exited abnormally with signal 9: Killed: 9

May 30 23:18:06 unknown Golman[1308] <Warning>: Received memory warning.

May 30 23:18:07 unknown Golman[1308] <Warning>: Warning: Libinfo call to mDNSResponder on main thread

May 30 23:18:08 unknown ReportCrash[1310] <Notice>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-05-30-231808.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0

May 30 23:18:09 unknown Golman[1308] <Warning>: (friends list received)

May 30 23:18:11 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.plantpot.golman[0x8c4]) Exited: Killed: 9

May 30 23:18:11 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created

May 30 23:18:11 unknown SpringBoard[51] <Warning>: Application 'Golman' exited abnormally with signal 9: Killed: 9

May 30 23:18:12 unknown SpringBoard[51] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=0

May 30 23:18:12 unknown SpringBoard[51] <Notice>: MultitouchHID: detection mode: 0->255

May 30 23:18:12 unknown UserEventAgent[12] <Warning>: DEBUG: Changing screen blanked state: 1

May 30 23:18:12 unknown UserEventAgent[12] <Warning>: DEBUG: We could backup; waking backupd to decide

May 30 23:18:12 unknown UserEventAgent[12] <Warning>: TRACE: <MBManagerClient: 0x1402d0> establishing connection with daemon...

May 30 23:18:13 unknown UserEventAgent[12] <Warning>: TRACE: <MBConnection: 0x155340> sending {
    command = kMBMessageWakeUp;
}

May 30 23:18:14 unknown backupd[1313] <Warning>: INFO: Scheduling next backup at 5/31/12 11:01:35 PM

May 30 23:18:17 unknown ReportCrash[1314] <Notice>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-05-30-231817.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0

Edit 2: I have just used the Allocations Instrument on the screen where this happens. The live bytes in the 'All Allocation' field only goes up to 34 / 35 MB at this point. That doesn't seem like it would be enough to be causing the memory issues. Also, the memory warnings start to appear before that point, when it is loading the textures into the game. The app uses the Irrlicht library if that sheds any light on the matter. Just about all of the images, animations, sounds etc are loaded at the very start but the app never crashes when that is happening. It is almost always when a webview of some kind is opened, such as the FB dialog. As mentioned in a comment, this project originally belonged to someone else. Unfortunately it was not completely stable when they had finished with it.

Edit 3: Have now tried with Memory Monitor. First time it crashed while loading textures and showed me it was using ~80MB real and ~200MB virtual memory. After that I stopped it from loading any of the textures, and it still crashed this time showing 69MB and 179MB. Removed audio and an animated 'dummy' which is initialized at the start and crashed at 38MB/147MB.

No idea how it could be using up so much memory so quickly without even loading textures.

Popeye
  • 11,356
  • 9
  • 56
  • 88
TheBestBigAl
  • 1,191
  • 1
  • 14
  • 42
  • 1
    All we can do is guess at the cause without you sharing the crash information. What is logged to the console when it crashes? What is the stack trace in the crash log? Any time you ask about a crash, this information is critical to solving the problem and needs to be supplied. – Brad Larson May 30 '12 at 17:38
  • Apologies, I have now added the console output to the original question. No crash log is generated, which is also the case on iPads - even though they crash when used with the FB app rather than the Fb dialog box. – TheBestBigAl May 30 '12 at 22:45
  • 1
    Best way to get yourself a call stack is to plug the device into your Mac and debug the app as it's running. – Shaggy Frog May 30 '12 at 22:55
  • 2
    Well, it's pretty clear from the console log that you're being killed due to excessive memory usage. It might be time to take a look at what the Memory Monitor instrument is telling you when you run your application, because I bet you're either accumulating memory or hitting a spike during the times when this crashes on those devices. – Brad Larson May 30 '12 at 22:56
  • 1
    In addition this line is also important: `May 30 23:18:03 unknown Golman[1308] : void SendDelegateMessage(NSInvocation*): delegate (webView:didCommitLoadForFrame:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode ` The app blocks for more than 10 seconds in the main thread, which causes the watchdog to kill the app. But the memory issues also seem very severe. – Kerni May 30 '12 at 22:58
  • Shaggy: I would do but unfortunately I do not have the device. a 3rd party is testing it for me. Brad: I had a feeling this would be the case, I'm going to take another look at the memory monitor and see what it says. – TheBestBigAl May 30 '12 at 23:00
  • Kerni: Could this be happening _because_ of the memory issues? I've inherited this project from someone else, I've never had a project with quite so many problems... – TheBestBigAl May 30 '12 at 23:13
  • I have further edited the question regarding the memory allocator tool. – TheBestBigAl May 30 '12 at 23:25
  • 1
    Allocations is not a good way to look at your application's actual memory usage, because it [does not show all of the memory being used by your application](http://stackoverflow.com/questions/5518918/instruments-with-ios-why-does-memory-monitor-disagree-with-allocations). That's what Memory Monitor is good for, and why I mentioned it by name. If you're hitting 35 MB in what Allocations sees, I bet your application is actually using 70+ MB of memory when you look at it in Memory Monitor. That's way too much for these devices. – Brad Larson May 31 '12 at 01:20
  • Ah ok, at first I assumed you meant Activity Monitor which didn't help, and couldn't see Memory Monitor. I thought maybe it had been repackaged as Allocations/Leaks etc. Part of the problem I have is that when the device is attached to the Mac, it almost always crashes. Presumably it's down to differences between how Xcode and springboard handle the app. Anyway, after running for a very short time the app crashed while loading textures. It shows "Real Memory" as 88.43MB and "Virtual Memory" as 200.64MB. Given your last comment, I'm thinking it's safe to say these are way too high? – TheBestBigAl May 31 '12 at 09:31
  • Fixed now. Removed lots and lots of images etc which were loaded at the very start of the app, and now load them as they're needed - and more importantly freeing them up when we're finished with them. Why the original developer hadn't done that in the first place I'll never know. Thanks to all that helped, particularly Brad Larson. Brad, if you'd like to add a quick answer about excessive memory usage and using the Memory Monitor then I'll happily mark it as correct - you deserve to get something for your troubles. Thanks again. – TheBestBigAl May 31 '12 at 23:08

0 Answers0