Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS active assertions beyond permitted time error when importing from Facebook
    primarykey
    data
    text
    <p>I was under the impression that the "active assertions beyond permitted time" error was for when an app is first loading. However, today I was testing my app, doing a batch import from Facebook using iOS 7, and the app crashed with this error.</p> <p>Specifically, I am calling:</p> <p>[NSData dataWithContentsOfURL:[NSURL URLWithString:url]];</p> <p>twice for each friend chosen from the friend selector (two different urls). The crash happened when I tried to import 10 people.</p> <p>I am confused - by this point, the app is fully launched. Why is this assertion happening here?</p> <p>Crash log portion:</p> <pre><code>Incident Identifier: 0A705B17-FE23-4585-B3EF-89E34F4A4E89 CrashReporter Key: a9ef164d188c1490dffbe7fdd3c467823e2f3c19 Hardware Model: iPhone3,1 Process: MyApp [3366] Path: /var/mobile/Applications/9CEDB552-C091-4FD7-AF1F-BE39A9D07C67/MyApp.app/MyApp Identifier: com.mycom.myApp Version: 1.5.2 (1.5.2) Code Type: ARM (Native) Parent Process: launchd [1] Date/Time: 2013-11-24 14:56:00.894 -0500 OS Version: iOS 7.0.3 (11B511) Report Version: 104 Exception Type: 00000020 Exception Codes: 0x000000008badf00d Highlighted Thread: 0 Application Specific Information: MyApp[3366] has active assertions beyond permitted time: {( &lt;BKProcessAssertion: 0x145564c0&gt; identifier: Suspending process: MyApp[3366] permittedBackgroundDuration: 10.000000 reason: suspend owner pid:28 preventSuspend preventThrottleDownCPU preventThrottleDownUI preventSuspendOnSleep )} Elapsed total CPU time (seconds): 3.010 (user 3.010, system 0.000), 49% CPU Elapsed application CPU time (seconds): 0.005, 0% CPU Thread 0: 0 libsystem_kernel.dylib 0x3a6b9adc semaphore_wait_trap + 8 1 libdispatch.dylib 0x3a603fa0 _dispatch_semaphore_wait_slow + 172 2 CFNetwork 0x2f9426e0 CFURLConnectionSendSynchronousRequest + 264 3 Foundation 0x3070a7ae +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 110 4 Foundation 0x306da8c6 -[NSData(NSData) initWithContentsOfURL:] + 182 5 Foundation 0x306da7f6 +[NSData(NSData) dataWithContentsOfURL:] + 38 6 MyApp 0x0020e1a8 +[FacebookHelper imageForObject:] (FacebookHelper.m:910) 7 MyApp 0x0021bfe4 -[PersonViewController(Facebook) importFriend:withCompletion:] (PersonViewController+Facebook.m:110) 8 MyApp 0x0021bc2a -[PersonViewController(Facebook) importFriends:] (PersonViewController+Facebook.m:70) 9 Foundation 0x30758386 __NSFireDelayedPerform + 410 10 CoreFoundation 0x2fd490dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12 11 CoreFoundation 0x2fd48cf2 __CFRunLoopDoTimer + 778 12 CoreFoundation 0x2fd4708e __CFRunLoopRun + 1206 13 CoreFoundation 0x2fcb1c22 CFRunLoopRunSpecific + 518 14 CoreFoundation 0x2fcb1a06 CFRunLoopRunInMode + 102 15 GraphicsServices 0x3499027e GSEventRunModal + 134 16 UIKit 0x32555044 UIApplicationMain + 1132 17 MyApp 0x000fc146 main (main.m:5) 18 libdyld.dylib 0x3a615ab4 start + 0 </code></pre> <p>and here is the code snippet:</p> <pre><code>+ (UIImage *)imageForObject:(NSString *)objectID { __ENTERING_METHOD__ NSString *url = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture?width=%d&amp;height=%d",objectID,IMAGE_MAXWIDTH,IMAGE_MAXHEIGHT]; UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]]; return image; } </code></pre> <p>EDIT: Would this allow me to use the returned image to save on my main thread to my app delegate managedObjectContext? In other words, is the thread-safe, or do I need to create and manage an entire new managedObjectContext and then merge it, etc.? And will making multiple closely spaced calls to this revised method, as opposed to the above, help me to avoid the "active assertions beyond permitted time" error?</p> <pre><code>+ (UIImage *)imageForObject:(NSString *)objectID { NSString *url = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture?width=%d&amp;height=%d",objectID,IMAGE_MAXWIDTH,IMAGE_MAXHEIGHT]; __block UIImage *image; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; dispatch_async(dispatch_get_main_queue(), ^{ image = [[UIImage alloc] initWithData:data]; }); }); return image; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload