Calling FBSession.activeSession as instructed to in tutorial, results in NSException - iphone

I am trying to enable Facebook login in my iphone app.
I am following the instructions on this page:
https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/#step4
I have followed the instructions in Step #4 (Logging in to Facebook), but my code crashes when I run it.
This is my method that is causing the crash:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
// We need to properly handle activation of the application with regards to Facebook Login
// (e.g., returning from iOS 6.0 Login Dialog or from fast app switching).
NSLog(#"here 1");
NSLog(#"active session: %#",FBSession.activeSession);
[FBSession.activeSession handleDidBecomeActive];
NSLog(#"here 2");
}
And here is my stack trace at the time of the crash (app name replaced with XXX):
2013-02-11 17:31:17.956 TRIO[9426:907] here 1
* thread #1: tid = 0x2503, 0x324d9960 libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 1.1
frame #0: 0x324d9960 libobjc.A.dylib`objc_exception_throw
frame #1: 0x3161af98 CoreFoundation`-[NSException raise] + 8
frame #2: 0x0009f7cc XXX`-[FBSession initWithAppID:permissions:defaultAudience:urlSchemeSuffix:tokenCacheStrategy:] + 240 at FBSession.m:236
frame #3: 0x0009f6d6 XXX`-[FBSession initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:] + 46 at FBSession.m:208
frame #4: 0x0009f680 XXX`-[FBSession init] + 32 at FBSession.m:191
frame #5: 0x000a061a XXX`+[FBSession activeSession] + 62 at FBSession.m:568
frame #6: 0x00073c4e XXX`-[AppDelegate applicationDidBecomeActive:] + 66 at AppDelegate.m:118
frame #7: 0x38e3bae2 UIKit`-[UIApplication _stopDeactivatingForReason:] + 342
frame #8: 0x38e219b8 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 1072
frame #9: 0x38dc9c38 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1004
frame #10: 0x38dc96cc UIKit`-[UIApplication sendEvent:] + 72
frame #11: 0x38dc911a UIKit`_UIApplicationHandleEvent + 6154
frame #12: 0x393605a2 GraphicsServices`_PurpleEventCallback + 590
frame #13: 0x393601d2 GraphicsServices`PurpleEventCallback + 34
frame #14: 0x315f0172 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #15: 0x315f0116 CoreFoundation`__CFRunLoopDoSource1 + 138
frame #16: 0x315eef98 CoreFoundation`__CFRunLoopRun + 1384
frame #17: 0x31561ebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #18: 0x31561d48 CoreFoundation`CFRunLoopRunInMode + 104
frame #19: 0x38e2047c UIKit`-[UIApplication _run] + 668
frame #20: 0x38e1d2f8 UIKit`UIApplicationMain + 1120
frame #21: 0x00073748 XXX`main + 96 at main.m:16
When I run the Facebook sample code, they work fine, and I believe I've added all the required frameworks.
Thanks.

I had the same error as above and it was because I did not add my own FacebookAppID along with the "URL types" key to my project's info.plist

Related

Webrtc Swift - Thread 1: EXC_BAD_ACCESS (code=1, address=0xd000000000000040)

I am using Janus videoroom with Webrtc. Everything working fine. But when i go for ending call. And dismiss the current view controller - App Crashed.
I am unable to get the point of crashing so i can resolve.
the current view disappeared fine also. Logs shows this:
callDropButton Clicked
Videoroom viewDidDisappear
Videoroom screen dismissed completely
I am getting the crash at this 1st line of Appdelegate:
class AppDelegate: UIResponder, UIApplicationDelegate {
I am also attaching backtrace logs for more info. But this is not making any sence to me:
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xd000000000000040)
frame #0: 0x00000001012e0024 WebRTC`___lldb_unnamed_symbol6199$$WebRTC + 120
frame #1: 0x00000001013c70f0 WebRTC`___lldb_unnamed_symbol12553$$WebRTC + 44
frame #2: 0x00000001013c7078 WebRTC`___lldb_unnamed_symbol12551$$WebRTC + 128
frame #3: 0x00000001013c6964 WebRTC`___lldb_unnamed_symbol12523$$WebRTC + 12
frame #4: 0x00000001013c6944 WebRTC`___lldb_unnamed_symbol12521$$WebRTC + 52
frame #5: 0x00000001012e16b0 WebRTC`___lldb_unnamed_symbol6278$$WebRTC + 36
frame #6: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #7: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #8: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #9: 0x00000001012f343c WebRTC`___lldb_unnamed_symbol6908$$WebRTC + 328
frame #10: 0x000000010050c8b0 Interpret`outlined destroy of RTCVideoTrack? at <compiler-generated>:0
frame #11: 0x00000001005346ec Interpret`#objc ConnectionViewController.__ivar_destroyer(self=0x0000000154016800) at ConnectionViewController.swift:0
frame #12: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #13: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #14: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #15: 0x00000001d04a5de8 UIKitCore`-[UIResponder dealloc] + 152
frame #16: 0x00000001cfeced0c UIKitCore`-[UIViewController dealloc] + 1748
frame #17: 0x00000001cfe07594 UIKitCore`-[UIPresentationController .cxx_destruct] + 372
frame #18: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #19: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #20: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #21: 0x00000001cfe030fc UIKitCore`-[UIPresentationController dealloc] + 60
frame #22: 0x00000001cfe08d5c UIKitCore`-[_UIFullscreenPresentationController dealloc] + 60
frame #23: 0x00000001a3ff7a44 libsystem_blocks.dylib`_Block_release + 152
frame #24: 0x00000001cfefbaf8 UIKitCore`-[_UIViewControllerTransitionContext .cxx_destruct] + 116
frame #25: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #26: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #27: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #28: 0x00000001cfefa3f8 UIKitCore`-[_UIViewControllerTransitionContext dealloc] + 60
frame #29: 0x00000001cfefbbb0 UIKitCore`-[_UIViewControllerOneToOneTransitionContext dealloc] + 84
frame #30: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #31: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #32: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #33: 0x00000001a3ff7a44 libsystem_blocks.dylib`_Block_release + 152
frame #34: 0x00000001a444ca38 CoreFoundation`-[__NSSingleObjectArrayI dealloc] + 44
frame #35: 0x00000001d04870e8 UIKitCore`_runAfterCACommitDeferredBlocks + 356
frame #36: 0x00000001d0475bfc UIKitCore`_cleanUpAfterCAFlushAndRunDeferredBlocks + 352
frame #37: 0x00000001d04a2a6c UIKitCore`_afterCACommitHandler + 116
frame #38: 0x00000001a44ef4fc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
frame #39: 0x00000001a44ea224 CoreFoundation`__CFRunLoopDoObservers + 412
frame #40: 0x00000001a44ea7a0 CoreFoundation`__CFRunLoopRun + 1228
frame #41: 0x00000001a44e9fb4 CoreFoundation`CFRunLoopRunSpecific + 436
frame #42: 0x00000001a66eb79c GraphicsServices`GSEventRunModal + 104
frame #43: 0x00000001d047bc38 UIKitCore`UIApplicationMain + 212
* frame #44: 0x0000000100522d7c Interpret`main at AppDelegate.swift:13:7
frame #45: 0x00000001a3fad8e0 libdyld.dylib`start + 4
Make sure you have something like this in your deinit ("screen dismissed completely"?):
rtcAudioSession.remove(self)
peerConnection.close()
[localAudioTrack,
localVideoTrack,
remoteAudioTrack,
remoteVideoTrack,
].forEach { track in
track.isEnabled = false
}
Check on every WebRTC object you've created, if the class have something like close(), isEnabled = false, etc, you should call it in deinit.
According to your crashlog, the problem is in one of RTCVideoTrack objects. Try commenting out all the code that creates any of the RTCVideoTrack and see if that helps. If it helps, uncomment them out one by one to determine which one is causing the problem.

How to debug with breakpoint when crash line is the App Delegate?

Ever since upgrading to the latest Xcode, I've experienced random/intermittent crashes on app launch that I can only reproduce by launching the app n times and waiting for it to return. The line that the app crashes on is the top of the App Delegate:
class AppDelegate: UIResponder, UIApplicationDelegate {
I don't know how I'd set a breakpoint here and what I could gather from it. The reported cause of the crash is an NSException error on Thread 1:
[_NSTaggedDate countByEnumeratingWithState:objects:count]: unrecognized selector sent to instance 0x8000000000000000
Backtrace:
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x000000019b7c6d88 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x000000019b6df1e8 libsystem_pthread.dylib`pthread_kill$VARIANT$mp + 136
frame #2: 0x000000019b632934 libsystem_c.dylib`abort + 100
frame #3: 0x000000019b79acc0 libc++abi.dylib`abort_message + 128
frame #4: 0x000000019b78ce10 libc++abi.dylib`demangling_terminate_handler() + 296
frame #5: 0x000000019b6f3e80 libobjc.A.dylib`_objc_terminate() + 124
frame #6: 0x000000019b79a14c libc++abi.dylib`std::__terminate(void (*)()) + 16
frame #7: 0x000000019b79a0e4 libc++abi.dylib`std::terminate() + 44
frame #8: 0x000000019b6f3e04 libobjc.A.dylib`objc_terminate + 12
frame #9: 0x0000000105e2b744 libdispatch.dylib`_dispatch_client_callout + 36
frame #10: 0x0000000105e39710 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 976
frame #11: 0x000000019b94f7fc CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
frame #12: 0x000000019b94a6d0 CoreFoundation`__CFRunLoopRun + 1724
frame #13: 0x000000019b949ce8 CoreFoundation`CFRunLoopRunSpecific + 424
frame #14: 0x00000001a5a9438c GraphicsServices`GSEventRunModal + 160
frame #15: 0x000000019fa78444 UIKitCore`UIApplicationMain + 1932
frame #16: 0x0000000100fc866c FXTracker`main at AppDelegate.swift:8:7
frame #17: 0x000000019b7d18f0 libdyld.dylib`start + 4
In the debug navigator window, it's opened to Thread 1 and there is a drop-down called Original Exception Backtrace which looks like this:
0 _exceptionPreprocess
9 Sequence<>.contains(_:)
10 closure #3 in closure #1 in closure #2 in FXEditorViewController.loadBadges()
19 UIApplicationMain
20 main
21 start
Is it safe to say that the crash is caused by closure #3 in closure #1 in closure #2 in loadBadges()?
In this case you can set exception breakpoints
here
and then here (in Exceptions -> All)

How to "Take Priority" of Audio Playback?

I have an audio-playback app that crashes when returning from another audio-playing app when the user attempts to re-start playback. My app works great on it's own and will handle background playback, etc; however when returning from Spotify-like apps it crashes when it starts it's own playback.
I'm guessing there's some sort of "priority" of audio that I should be handling? And taking that priority "back" from whatever audio app previously had it? Just looking for a direction to start looking....thanks!
Backtrace:
thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001be4fdec4 libsystem_kernel.dylib__pthread_kill + 8
frame #1: 0x00000001be41d724 libsystem_pthread.dylibpthread_kill$VARIANT$armv81 + 216
frame #2: 0x00000001be36d844 libsystem_c.dylibabort + 100
frame #3: 0x00000001be4c67d4 libc++abi.dylibabort_message + 128
frame #4: 0x00000001be4c69c4 libc++abi.dylibdemangling_terminate_handler() + 296
frame #5: 0x00000001be42e258 libobjc.A.dylib_objc_terminate() + 124
frame #6: 0x00000001be4d3304 libc++abi.dylibstd::__terminate(void (*)()) + 16
frame #7: 0x00000001be4d2ed8 libc++abi.dylib__cxa_rethrow + 144
frame #8: 0x00000001be42e158 libobjc.A.dylibobjc_exception_rethrow + 40
frame #9: 0x00000001be67eb4c CoreFoundationCFRunLoopRunSpecific + 576
frame #10: 0x00000001c861f328 GraphicsServicesGSEventRunModal + 104
frame #11: 0x00000001c278c63c UIKitCoreUIApplicationMain + 1936
frame #12: 0x00000001047c0e78 Sequencer`main at AppDelegate.swift:23:7
frame #13: 0x00000001be508360 libdyld.dylib`start + 4

Crash when save a photo

I have a strange crash when I save a UIImage into camera roll.
I Use this code:
UIImageWriteToSavedPhotosAlbum (_originalImage, self, #selector(photoSaved:didFinishSavingWithError:contextInfo:), nil);
-(void)photoSaved:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo {
if(!error){
NSLog(#"Photo saved to library!");
} else{
NSLog(#"Saving failed :(");
}
}
This is the Log:
2012-11-10 20:43:29.868 MyApp[5012:1a303] Photo saved to library!
This is the BT:
(lldb) bt
* thread #1: tid = 0x1f03, 0x024e509b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=1, address=0x3094a576)
frame #0: 0x024e509b libobjc.A.dylib`objc_msgSend + 15
frame #1: 0x01b84a8b PhotoLibrary`-[PLUILibraryViewController updateNavigationItemButtons] + 216
frame #2: 0x01b6f054 PhotoLibrary`-[PLLibraryViewController(OverridePoints) updateInterfaceForHasContentChange] + 867
frame #3: 0x01c3c228 PhotoLibrary`-[PLAbstractLibraryViewController _updateHasContent] + 295
frame #4: 0x01c3c7d0 PhotoLibrary`-[PLAbstractLibraryViewController _updateAlbumsWithNotification:] + 681
frame #5: 0x01c3b870 PhotoLibrary`-[PLAbstractLibraryViewController albumListDidChange:] + 272
frame #6: 0x01b84c5b PhotoLibrary`-[PLUILibraryViewController albumListDidChange:] + 236
frame #7: 0x01525a29 Foundation`__57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 40
frame #8: 0x0267d855 CoreFoundation`___CFXNotificationPost_block_invoke_0 + 85
frame #9: 0x0267d778 CoreFoundation`_CFXNotificationPost + 1976
frame #10: 0x0146a234 Foundation`-[NSNotificationCenter postNotification:] + 121
frame #11: 0x02d217a4 PhotoLibraryServices`-[PLChangeNotificationCenter _postEnqueuedNotifications] + 425
frame #12: 0x02d1f771 PhotoLibraryServices`-[PLChangeNotificationCenter _sendNotificationsForSplitChanges] + 307
frame #13: 0x02d23614 PhotoLibraryServices`-[PLChangeNotificationCenter managedObjectContext:didProcessRemoteContextSave:usingObjectIDs:] + 56
frame #14: 0x02d017cc PhotoLibraryServices`-[PLSharedManagedObjectContext _mergeChangesFromDidSaveDictionary:usingObjectIDs:] + 229
frame #15: 0x03edfd2f CoreData`__+[NSManagedObjectContext(_NSCoreDataSPI) _mergeChangesFromRemoteContextSave:intoContexts:]_block_invoke_4 + 159
frame #16: 0x03e67d03 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 99
frame #17: 0x01af18d9 libdispatch.dylib`_dispatch_barrier_sync_f_slow_invoke + 93
frame #18: 0x01af2509 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 353
frame #19: 0x025e9803 CoreFoundation`__CFRunLoopRun + 2003
frame #20: 0x025e8d84 CoreFoundation`CFRunLoopRunSpecific + 212
frame #21: 0x025e8c9b CoreFoundation`CFRunLoopRunInMode + 123
frame #22: 0x02a2d7d8 GraphicsServices`GSEventRunModal + 190
frame #23: 0x02a2d88a GraphicsServices`GSEventRun + 103
frame #24: 0x00b63626 UIKit`UIApplicationMain + 1163
frame #25: 0x000026ca MyApp`main + 170 at main.m:16
Full disclosure: I hope this makes sense as I'm pretty new to Objective-C, but I recently had a similar problem. I found out that my image was not being retained when I called the didFinishSavingWithError:contextInfo: method after selecting an image from the Camera Roll. What worked for me was adding the withObject: argument to my method call, as shown here:
[self performSelector:#selector(image:didFinishSavingWithError:contextInfo:) withObject:_originalImage];
This way, the image was retained when the didFinishSavgngWithError:contextInfo: method was called where previously it was not. Again, I'm new to Objective-C but I hope that helps...or at least points you in the right direction. What would also be helpful is if you could tell me at what point your app crashes (i.e. when you call the imagePicker, when you select an image from the camera roll, etc.).

What is differance between the UIAlertView's from IOS 5 to IOS 6. In My IOS 6 all server side validation messages are not working

What is differance between the UIAlertView's from IOS 5 to IOS 6. In My IOS 6 all server side validation messages are not working..if We click on the Alert Button App is crash. I need Help On this.
(lldb) bt:(after bt got this log)
* thread #1: tid = 0x1c03, 0x0294209b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=1, address=0x80000008)
frame #0: 0x0294209b libobjc.A.dylib`objc_msgSend + 15
frame #1: 0x01fc9020 UIKit`-[UIAlertView(Private) _buttonClicked:] + 294
frame #2: 0x02944705 libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 77
frame #3: 0x01bd9920 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96
frame #4: 0x01bd98b8 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
frame #5: 0x01c9a671 UIKit`-[UIControl sendAction:to:forEvent:] + 66
frame #6: 0x01c9abcf UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
frame #7: 0x01c99d38 UIKit`-[UIControl touchesEnded:withEvent:] + 546
frame #8: 0x01c0933f UIKit`-[UIWindow _sendTouchesForEvent:] + 846
frame #9: 0x01c09552 UIKit`-[UIWindow sendEvent:] + 273
frame #10: 0x01be73aa UIKit`-[UIApplication sendEvent:] + 436
frame #11: 0x01bd8cf8 UIKit`_UIApplicationHandleEvent + 9874
frame #12: 0x035fedf9 GraphicsServices`_PurpleEventCallback + 339
frame #13: 0x035fead0 GraphicsServices`PurpleEventCallback + 46
frame #14: 0x02e89bf5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #15: 0x02e89962 CoreFoundation`__CFRunLoopDoSource1 + 146
frame #16: 0x02ebabb6 CoreFoundation`__CFRunLoopRun + 2118
frame #17: 0x02eb9f44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #18: 0x02eb9e1b CoreFoundation`CFRunLoopRunInMode + 123
frame #19: 0x035fd7e3 GraphicsServices`GSEventRunModal + 88
frame #20: 0x035fd668 GraphicsServices`GSEventRun + 104
frame #21: 0x01bd665c UIKit`UIApplicationMain + 1211
frame #22: 0x0000255d mobiletummy`main + 125 at main.m:14
frame #23: 0x00002495 mobiletummy`start + 53
Have got the same problem. Throwing UIAlert on main thread resolved the thing for me. But on ur log stack it seems that you are already one the main thread.