iOS Extension is hanging on launch/Extension did not initialize in time - ios

I'm currently getting a weird situation. Here's how I get into it. Note that I do NOT get this problem when the first 2 steps are skipped.
I make a background NSURLSession in a Share Extension.
I start a download task.
I call exit(0).
The code looks like this:
NSString *address = #"https://googledrive.com/host/0B5zObXR9UzgmbFpob2J5eXpjNXc/file3m";
self.mySession = [self configureMySession];
NSURL *url = [NSURL URLWithString:address];
NSURLSessionTask *myTask = [self.mySession downloadTaskWithURL:url];
[myTask resume];
exit(0);
With this code the following happens. The extension continually respawns, hangs on launch, respawns, hangs on launch, ad infinitum. Here are some of the log messages.
Aug 12 10:55:16 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27082]): Extension did not
initialize in time.
Aug 12 10:55:16 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension): Service only ran for 5
seconds. Pushing respawn out by 5 seconds.
Aug 12 10:55:21 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.apple.imfoundation.IMRemoteURLConnectionAgent): The
_DirtyJetsamMemoryLimit key is not available on this platform.
Aug 12 10:55:26 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27085]): Extension is
hanging on launch. Killing.
Aug 12 10:55:26 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27085]): Extension did not
initialize in time.
Aug 12 10:55:26 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension): Service only ran for 5
seconds. Pushing respawn out by 5 seconds.
Aug 12 10:55:31 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.apple.imfoundation.IMRemoteURLConnectionAgent): The
_DirtyJetsamMemoryLimit key is not available on this platform.
Aug 12 10:55:36 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27086]): Extension is
hanging on launch. Killing.
Aug 12 10:55:37 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27086]): Extension did not
initialize in time.
Aug 12 10:55:37 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension): Service only ran for 5
seconds. Pushing respawn out by 5 seconds.
Aug 12 10:55:42 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.apple.imfoundation.IMRemoteURLConnectionAgent): The
_DirtyJetsamMemoryLimit key is not available on this platform.
Aug 12 10:55:47 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27087]): Extension is
hanging on launch. Killing.
Aug 12 10:55:47 Asperas-MacBook-Pro-2
com.apple.CoreSimulator.SimDevice.6867B1A7-8694-4D6D-8480-69FE89F39C27.launchd_sim[23018]
(com.asperasoft.faspex-app.FaspexExtension[27087]): Extension did not
initialize in time.
Anyone know what might be causing this behavior?
For the curious, I am doing this so that the application:handleEventsForBackgroundURLSession:completionHandler: method of my containing app's UIApplicationDelegate class gets called. I realize that it is a little shady, but... there aren't many ways to communicate between a share extension and its containing app, so it's what I got.
EDIT: I'm now using this workaround https://stackoverflow.com/a/24614589/3923882 (UIWebView) so this question isn't really that pressing. Still interested if anyone has an answer though.

Related

Xcode disconnecting from simulator or device when going to homescreen

I'm trying to debug an handoff issue in Xcode, but the debugger disconnects every time I go to the device homescreen. This happens on both the simulator and an actual device.
I have other apps where it works correctly; that is, it continues to debug when I go to the homescreen.
Any ideas what could be causing this? I've rebooted Xcode and my Mac with no luck.
When running on the device, the log has a message that looks like:
Jun 28 16:36:31 Mikes-iPhone com.apple.debugserver-#(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[14593] <Warning>: 1 +0.000000 sec [3901/1307]: error: ::read ( -1, 0x16e246a38, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Jun 28 16:36:31 Mikes-iPhone com.apple.debugserver-#(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[14593] <Warning>: Exiting.
Jun 28 16:36:31 Mikes-iPhone mediaserverd[14247] <Notice>: '' com.zzzzzz.appname(pid = 14594) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
I'd appreciate any ideas or suggestions....
Well this was dumb. At some point I had changed the "Application does not run in background" plist flag to YES. Simply changing to NO fixed the problem. Duh.

Forcing a saved image to sync with the iCloud Photo Stream

I have an app that takes images periodically, and I would like them to be uploaded to the iCloud Photo Stream right after the images are taken.
It appears that certain conditions need to be met in order for this to work. It only seems to work when running iOS 8, the device is connected to wireless, and by using UIImagePickerController to take pictures (rather than AVCapture) at least once. It seems that the UIImagePickerController when presented alters some system settings that allows for subsequent automatic uploading of images to the iCloud Photo Stream. If I use AVCapture only to take pictures, it will not work. I've confirmed that "Upload to My Photo Stream" is enabled in the iCloud settings, and there is an active wireless connection.
Here is the method used to save an image obtained from UIImagePickerController:
- (void)saveImage : (UIImage *)image {
// Add image to the photo library
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest =
[PHAssetChangeRequest creationRequestForAssetFromImage:image];
} completionHandler:^(BOOL success, NSError *error) {
if (!success)
NSLog(#"Error creating asset: %#", error);
}];
}
When running on my iPad with iOS 8, below are the entries that I see in the device system logs:
Oct 22 21:11:06 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Submitting 1 asset collections for publication.
Oct 22 21:11:06 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
Oct 22 21:11:10 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx uploading 1 assets...
Oct 22 21:11:11 iPad mstreamd[14409] <Notice>: (Note ) PS: Received push notification for invitations topic: com.apple.mediastream.subscription.push userInfo: {
r = xxxxxxxx;
}
Oct 22 21:11:11 iPad mstreamd[14409] <Notice>: (Note ) PS: <MSIOSMediaStreamDaemon: 0x1662ad80>: Push notification received for My Photo Stream with targetPersonID xxxxxxxx.
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1666fae0>: Plugged in to external power. Allowing file transfers.
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1666fae0>: Push received. Allowing file transfers to continue for 60.00 seconds
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) PS: MSSubscriber - xxxxxxxx Found 1 new asset collections.
Oct 22 21:11:13 iPad assetsd[11536] <Warning>: Unable to open file to save extended attributes (No such file or directory).
When running on my iPhone with iOS 9.1, I have similar log entries, except I have additional warnings/error messages about the caching server bolded:
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Submitting 1 asset collections for publication.
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
**Oct 25 22:35:28 iPhone AssetCacheLocatorService[1658] <Warning>: #df99fdd0 [I:AssetCacheLocatorService.queue] found no caching servers**
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx uploading 1 assets...
**Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Error) mmcs: __mmcs_proxy_locator_exists_block_invoke:167 might have caching server returned with error: Error Domain=NSPOSIXErrorDomain Code=60 "Operation timed out" UserInfo={com.apple.AssetCacheLocator.tag=#1963bd2d, NSLocalizedDescription=quick miss requested}**
**Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...**
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: Received push notification for invitations topic: com.apple.mediastream.subscription.push userInfo: {
r = xxxxxxxx;
}
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: <MSIOSMediaStreamDaemon: 0x157e0c530>: Push notification received for My Photo Stream with targetPersonID xxxxxxxx.
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x157e84410>: Plugged in to external power. Allowing file transfers.
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x157e84410>: Push received. Allowing file transfers to continue for 60.00 seconds
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSSubscriber - xxxxxxxx Found 1 new asset collections.
Oct 25 22:35:30 iPhone assetsd[1624] <Warning>: Unable to open file to save extended attributes (No such file or directory).
In this situation with iOS 9, the image is not uploaded when my app is active, and is uploaded only when the app goes into the background.
I suspect that the issue is due to 1. some system setting that is is activated with presentation of the UIImagePickerController only in iOS8 or 2. some issue with caching servers in iOS 9 as suggested by the log entries.
Anyone have any idea what is going on? Any ideas would be greatly appreciated! Thanks!
I think I've found a solution. It seems that if an AVCaptureSession is running, the iCloud Photo Stream will not synchronized. Calling the stopRunning method (as below) seems to do the trick:
[self.cameraSession stopRunning];

adsheet warning

can anyone explain the meaning/reason of this adsheet warning please?
Nov 23 09:24:06 unknown AdSheet[256] <Warning>: AdSheet running for 59.992 seconds with 1 clients and 1 assertions [banner:1]: info.company.app (State: Foreground Running) (Background: 0, no timer) has 1 banners: 0xee74b00:EDFD972C-2C31-45A6-A57C-F129F8D0CB97 (created 2011-11-23 17:23:44 +0000) [Visible: never] [In Window: YES]
it repeats every 20 seconds (in the log) and increments the "running for xx.xx seconds" with 20 seconds each time.
It comes up in the log with my iAd supported application and regardless whether the Test Advertisement is loaded or not.
after I kill the application it continues two or three times with:
Nov 23 09:33:06 unknown AdSheet[256] <Warning>: AdSheet running for 599.993 seconds with 0 clients and 0 assertions []:
and then it stops
thank you
I'm pretty sure the [Visible: never] has to do with the warning. Are you sure your AdSheet is visible and entirely on the screen? Did you by any chance accidently add a copy of the AdSheet to your viewController in IB that you don't know of? You should keep in mind that Ads should appear in the foreground.

Problems with iOS app quitting with no debug info and no log messages

I have an app here that could be boiled down to uiscrollviews with images that you can flick through. I'm experiencing something really strange here though.
When flicking through each image (have roughly 60 of them in total), at some point the app just quits. I'm running it in XCode 4 (GM seed 2), and I'm getting no debug info, and no messages in the console at all. Turned on NSZombieEnabled, but that didn't change anything.
I'm not even getting a crash log on the device. I've run it through instruments, and it doesn't report any leaks, and my memory usage goes between 700 and 1100KB when run on the device.
I even checked each of my "pages" (the ones you flick through) and added messages at init and dealloc, and I can confirm that they're all getting deallocated properly (only keep the current and the pages on each side loaded).
Now, this seem to mostly happen at the same point in the app when I just start at the beginning and flick through each page going right, plus or minus a few pages, all pointing toward a memory issue, I do get a memory warning from the device, but there is absolutely nothing pointing to me using a lot of memory at all, nor that there are any leaks.
I got this from the console on the device when the app quits:
Mar 8 14:13:37 unknown configd[26] : jetsam: kernel memory event (92), free: 451, active: 2894, inactive: 2267, purgeable: 0, wired: 16709
Mar 8 14:13:37 unknown configd[26] : jetsam: kernel termination snapshot being created
Mar 8 14:13:37 unknown com.apple.launchd[1] : (com.apple.AOSNotification) Exited: Killed: 9
Mar 8 14:13:37 unknown com.apple.launchd[1] : (UIKitApplication:com.apple.mobilemail[0xc2ee]) Exited: Killed: 9
Mar 8 14:13:37 unknown com.apple.launchd[1] : (UIKitApplication:no.NRC.NRCMag[0x3c6c]) Exited: Killed: 9
Mar 8 14:13:37 unknown com.apple.launchd[1] : (com.apple.dataaccess.dataaccessd) Exited: Killed: 9
Mar 8 14:13:37 unknown SpringBoard[30] : Received memory warning. Level=1
Mar 8 14:13:37 unknown SpringBoard[30] : Application 'Perspective' exited abnormally with signal 9: Killed: 9
Mar 8 14:13:38 unknown SpringBoard[30] : Application 'Mail' exited abnormally with signal 9: Killed: 9
Mar 8 14:13:38 unknown SpringBoard[30] : Memory level is not normal (60%). Delaying auto-relaunch of 'Mail' for 30 seconds.
Mar 8 14:13:38 unknown SpringBoard[30] : Received memory warning. Level=2
Mar 8 14:13:38 unknown kernel[0] : launchd[1253] Builtin profile: dataaccessd (sandbox)
Mar 8 14:13:39 unknown AOSN[1252] : AOSNotification Daemon Starting...
Mar 8 14:13:39 unknown AOSN[1252] : Device Information. Name: Calypso, BuildVersion: 8F190, Product Type: iPad1,1, Unique Device ID: f02b304ed9a62109de1f3efd3e1e23158a76b2d4
Mar 8 14:13:40 unknown ReportCrash[1254] : Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-03-08-141339.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Mar 8 14:13:40 unknown SpringBoard[30] : Received memory warning. Level=1
Mar 8 14:13:40 unknown dataaccessd[1253] : DA|Registered for wake notification
Mar 8 14:13:40 unknown AOSN[1252] : Push: Loading...
Mar 8 14:13:41 unknown profiled[1257] : profiled|Service starting...
Mar 8 14:13:41 unknown dataaccessd[1253] : EAS|EAS Protocol Manager set to ASProtocolUnknown
Mar 8 14:13:41 unknown dataaccessd[1253] : CalDAV|A refresh fired, but we're still waiting on a gatekeeper lock
Mar 8 14:13:42 unknown dataaccessd[1253] : EAS|EAS Protocol Manager set to ASProtocol12_1
Now this mentions a crash report, but how do I get a hold of this when it doesn't show up in the Organizer in XCode? And why am I getting memory warnings when Instruments (and a thorough look at my code) says that I'm not using much memory, nor leaking?
Help!
EDIT: Got 3.2.6 up and running here and the console now gives me this:
Program received signal: “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
Okay, so I figured it out here, and it's a bit silly.
I use UIImage's imageNamed method to load each image/page, and apparently this was causing the memory warnings.
There's a couple of things that bother me a bit about this.
The caching is obviously a good thing, but apparently in 4.3 GM it doesn't seem to actually empty its cache when a memory warning occurs.
The memory usage building up isn't being reported as being used by my app.

ipad app crashes on new iOS 4.1.2 but works on 3.2

I have a app in which i play a splash video and have added some custom fonts.
The app works fine on ipad 3.2 but on 4.2 etc it crashes. The log says that i release something that i dint alloc. I have checked my code a hundred times and i dont do any such thing.
Either ways it works on the simulator and on the device(both 3.2)
any ideas?
EDIT:
<Error>: df(7903,0x3e3d7898) malloc: *** error for object 0x1a11b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Wed Jan 19 20:35:38 unknown UIKitApplication:com..imagazine[0x9c7c][7903] <Notice>: def(7903,0x3e3d7898) malloc: *** error for object 0x1a11b0: pointer being freed was not allocated
Wed Jan 19 20:35:38 unknown UIKitApplication:com.imagazine[0x9c7c][7903] <Notice>: *** set a breakpoint in malloc_error_break to debug
Wed Jan 19 20:35:39 unknown ReportCrash[7905] <Notice>: Formulating crash report for process df[7903]
Wed Jan 19 20:35:39 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.imagazine[0x9c7c]) Job appears to have crashed: Abort trap
Wed Jan 19 20:35:39 unknown SpringBoard[27] <Warning>: Application 'df' exited abnormally with signal 6: Abort trap
Wed Jan 19 20:35:39 unknown ReportCrash[7905] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/df_2011-01-19-203538_Sumas-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
SOLUTION:
First of all use the NSZombies and you will catch such errors.
The Problem: I had a timer setup for every 0.2sec and it was clearing a UIView and allocating it, not every 0.2secs but maybe once every 5secs.
I did a standard check:
if(vewCustom!= nil) {
[vewCustom removeFromSuperView];
[vewCustom release];
vewCustom = nil;
}
But the strange thing was i verified the code hundreds of times and I was not over releasing and either ways it worked on iOS4.2 for iPhone.
I removed the Timer but still it was crashing and then I removed the release and now it works fine.
Strange but it would be good if someone can explain what i was doing wrong.
You could try running the app in debug with zombies enabled. This way you'll get a stack trace on the overreleased object here's a link on how to set it up.
http://iosdevelopertips.com/debugging/tracking-down-exc_bad_access-errors-with-nszombieenabled.html
Assume that the log is true. The easiest way to find it is to enable Zombies and then exercise your application throughly. See here (tip #1):
http://loufranco.com/blog/files/debugging-memory-iphone.html
Another thing to do is a Build and Analyze and look at each thing it flags. In my experience there are very few false positives.
Just noticed this while looking for something else. The reason for the crash is that removeFromSuperview causes the superview to release the view. Thus, the release that follows is redundant (over-release). Won't be an issue with ARC, but could cause some confusion in other situations

Resources