larsacus / LARSAdController

Lightweight ad mediation for iOS to properly manage multiple ad networks dynamically including iAd and Google ads.
http://theonlylars.com/blog/2013/01/10/stupid-easy-ads-with-larsadcontroller-3-dot-0/
MIT License
269 stars 60 forks source link

iAd crash #83

Closed haifengkao closed 9 years ago

haifengkao commented 10 years ago

My app was running on simulator for 20 mins, then it crashed.

2014-05-15 18:14:14.945 MyApp[11000:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ADBannerView must be part of a view hierarchy managed by a UIViewController'
*** First throw call stack:
(
    0   CoreFoundation                      0x053a81e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x055fd8e5 objc_exception_throw + 44
    2   iAd                                 0x04da7265 -[ADBannerView presentStoryboardForVideoAd] + 0
    3   UIKit                               0x03ef9478 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1642
    4   UIKit                               0x03ef096f __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 158
    5   Foundation                          0x02d2e68c -[NSISEngine withBehaviors:performModifications:] + 107
    6   Foundation                          0x02bbe3c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
    7   UIKit                               0x03ef0830 -[UIView(Hierarchy) _postMovedFromSuperview:] + 313
    8   UIKit                               0x03efbdd4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1875
    9   UIKit                               0x03eeedba -[UIView(Hierarchy) addSubview:] + 56
    10  MyApp                               0x0043dff1 -[LARSAdController startAdNetworkAdapterClass:] + 2961
    11  MyApp                               0x0043d41b -[LARSAdController startAdNetworkAdapterClassAtIndex:] + 539
    12  MyApp                               0x0043aed2 -[LARSAdController adFailedForNetworkAdapterClass:] + 418
    13  MyApp                               0x00440a18 -[TOLAdAdapterGoogleAds adView:didFailToReceiveAdWithError:] + 264
    14  MyApp                               0x0035278c __50-[GADDelegateManager didFailToReceiveAdWithError:]_block_invoke + 91
    15  MyApp                               0x0035205c GADDelegateManagerDispatchSynchronouslyOnMainThreadWithBlock + 50
    16  MyApp                               0x003526d5 -[GADDelegateManager didFailToReceiveAdWithError:] + 422
    17  MyApp                               0x0034efbf -[GADSlot showAd:withBaseURL:] + 376
    18  MyApp                               0x0035079a -[GADSlot handleAdResponse:withBaseURL:] + 79
    19  MyApp                               0x003603c3 __40-[GADAdFetcher didCompleteURLConnection]_block_invoke + 552
    20  libdispatch.dylib                   0x058eb4d0 _dispatch_client_callout + 14
    21  libdispatch.dylib                   0x058dae12 dispatch_once_f + 184
    22  libdispatch.dylib                   0x058dad55 dispatch_once + 31
    23  MyApp                               0x00360173 -[GADAdFetcher didCompleteURLConnection] + 210
    24  MyApp                               0x00360e42 -[GADAdFetcher connection:loadDidFinish:baseURL:] + 374
    25  MyApp                               0x0036294c -[GADURLConnection connectionDidFinishLoading:] + 224
    26  Foundation                          0x02d44e49 ___NSURLConnectionDidFinishLoading_block_invoke + 40
    27  Foundation                          0x02cdb7e1 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 62
    28  Foundation                          0x02b63f5e -[NSURLConnectionInternalConnection invokeForDelegate:] + 119
    29  Foundation                          0x02b63ec6 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 208
    30  Foundation                          0x02b63dd8 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76
    31  Foundation                          0x02b64188 _NSURLConnectionDidFinishLoading + 43
    32  CFNetwork                           0x01c3b69f ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 111
    33  CFNetwork                           0x01c393de ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 104
    34  CoreFoundation                      0x05349c69 CFArrayApplyFunction + 57
    35  CFNetwork                           0x01ba2441 _ZN19RunloopBlockContext7performEv + 155
    36  CFNetwork                           0x01c843f4 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20
    37  CFNetwork                           0x01ba2257 _ZN17MultiplexerSource7performEv + 299
    38  CFNetwork                           0x01ba206c _ZN17MultiplexerSource8_performEPv + 76
    39  CoreFoundation                      0x0533177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    40  CoreFoundation                      0x0533110b __CFRunLoopDoSources0 + 235
    41  CoreFoundation                      0x0534e1ae __CFRunLoopRun + 910
    42  CoreFoundation                      0x0534d9d3 CFRunLoopRunSpecific + 467
    43  CoreFoundation                      0x0534d7eb CFRunLoopRunInMode + 123
    44  GraphicsServices                    0x067ec5ee GSEventRunModal + 192
    45  GraphicsServices                    0x067ec42b GSEventRun + 104
    46  UIKit                               0x03e8ff9b UIApplicationMain + 1225
    47  MyApp                               0x000036d0 main + 592
    48  libdyld.dylib                       0x05b20701 start + 1
    49  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
larsacus commented 10 years ago

Without having more information about the view in frame 7, it's difficult to say what happened. If you are getting this crash a lot, make sure that the view that the ad controller is being added to is managed by a view controller. This appears to be pretty important to iAd.

haifengkao commented 10 years ago

It just happened again. The view is managed by root controller. How do I get more information about frame 7?

larsacus commented 10 years ago

If you can reproduce this crash while attached to the debugger, that would be the preferred approach to figuring out what view that iAd is complaining does not have a view controller. You need to figure out why the order in which you are adding the ad controller makes the system think that the ad container's superview does not have an associated view controller.