setObjectForKey: object cannot be nil (key: adTagUrl)' error in IMA iOS SDK

756 views
Skip to first unread message

Abraham Diaz

unread,
Apr 27, 2015, 6:20:44 AM4/27/15
to ima...@googlegroups.com
Hi guys,

We have a problem in our App. We have the following trace 

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: adTagUrl)'
__exceptionPreprocess + 127
objc_exception_throw + 36
-[__NSDictionaryM setObject:forKey:] + 858
+[IMAMessage deepCopyDictionary:] + 316
+[IMAMessage deepCopyObject:] + 188
-[IMAMessage initWithChannelName:sessionId:messageType:messageData:] + 222
+[IMAJavascriptDispatcher messageWithChannelName:data:] + 300
-[IMAJavascriptDispatcher processNewMessageWithChannelName:data:] + 66
-[IMAJavascriptBridge userContentController:didReceiveScriptMessage:] + 146
ScriptMessageHandlerDelegate::didPostMessage(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebCore::SerializedScriptValue&) + 46
WebKit::WebUserContentControllerProxy::didPostMessage(IPC::Connection*, unsigned long long, unsigned long long, unsigned long long, IPC

This error occurs in our production App for several users (15K crashes in the last two weeks, we are unable to reproduce it).
We check that the adTagUrl is not nil when we create IMAAdsRequest therefore we don't understand why this bug occurs. The VAST url works fine in another platforms.

Can you help us with a possible fix please?

Thanks

Shawn Busolits (IMA SDK Team)

unread,
Apr 27, 2015, 10:09:46 AM4/27/15
to ima...@googlegroups.com
Hi Abraham,

Are you able to replicate this in our sample app? Could you send us the ad tag with which you're testing?

Thanks,
Shawn Busolits
IMA SDK Team 

Jarrold Ong

unread,
May 5, 2015, 2:05:18 AM5/5/15
to ima...@googlegroups.com
Hi Shawn,

We are also experiencing this crash, it only happens on iOS8.

Regards,
Jarrold

Chris G.

unread,
May 5, 2015, 11:25:08 AM5/5/15
to ima...@googlegroups.com
Hi Shawn, I could reproduce this crash when a user stops and starts a new video with a preroll Ad. The App tears down the video player and Ad's objets from the previous video and recreates those objects for the new video. Throughout the lifecycle of the App, the App will instantiate a new video player and associated IMA Ad object many times. This involves removing the video player from the super layer.

I am using GoogleAds-IMA-iOS-SDK 3.0.beta.13.

I've published a variation of the Sample App that highlights this use case. On the iPhone, there is a "Play" and "Close" button. The crash occurs when the user touches Play, then Close, then Play again (Keep toggling between these two buttons and you should eventually get the App to crash. The speed when toggling between these two button does not need to be very fast.) Also, the crash only seems to happen with one of our adTagUrls. I've been unable to reproduce the crash with the one of Google's sample adTagUrls.


However, I've been unable to reproduce this crash when I set self.adsLoader to nil. (Initially, we only destroyed the adsManager).


- (void)destroyAd {

 
[self.contentPlayer pause];

 
if (self.adsManager) {

   
[self.adsManager destroy];

   
self.adsManager = nil;
 
}

// Uncomment to prevent "setObjectForKey: object cannot be nil" crash

// self.adsLoader.delegate = nil;

// self.adsLoader = nil;

 
self.contentPlayer = nil;

 
[self.videoView.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];

}

I am not sure if setting self.adsLoader = nil is the proper solution or if there is indeed a bug in the IMA SDK. Either way, I hope the above information helps.

Also, when stopping an Ad are there any other IMA objects that I should clean up (IMAAdDisplayContainer, IMAAVPlayerContentPlayhead, etc.)? Do you recommend only creating one AdsLoader (like the Advance Sample App) and reuse it? 

Shawn Busolits (IMA SDK Team)

unread,
May 5, 2015, 4:45:33 PM5/5/15
to ima...@googlegroups.com
Hi Chris,

Thanks for the sample code. Are there specific devices and version on which you're seeing this issue? Also, are you able to replicate in the simulator or only on a physical device? I tested your code on an iPhone 6 simulator (which was the default for the project) and tapped play and close about 25 times but never saw the crash.

Thanks,
Shawn Busolits
IMA SDK Team

Chris G.

unread,
May 5, 2015, 6:32:43 PM5/5/15
to ima...@googlegroups.com
Thanks for taking a look Shawn. I can reproduce the crash both on a physical device (iPhone 6 w/ iOS 8.3) and on the iPhone 6 simulator running iOS 8.2 or 8.3

The crash does not happen on iOS 7 (I tested with iOS 7.1 using iPhone 6 simulator).  On iOS 7, instead of a crash I see a message logged to the console: 

2015-05-05 18:01:43.803 BasicExample[80576:607] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> *** setObjectForKey: object cannot be nil (key: adTagUrl)

Reproducing the crash is tough. I am pausing just a little bit between my button touches. Below is a UI Automation script that typically crashes before the 5th iteration for me. (I feel like that Ad isn't finished being fetched before the previous Ad has been destroyed.).



UIALogger.logStart("Crash Test");

var target = UIATarget.localTarget();

target
.tap({x:253.50, y:51.00});

for (var i = 0; i < 100; i++) {

UIALogger.logMessage("--" + i + "---");

 target
.frontMostApp().mainWindow().buttons()["Play"].tap();

 
UIATarget.localTarget().delay(1.0);

 target
.frontMostApp().mainWindow().buttons()["Close"].tap();

 
UIATarget.localTarget().delay(1.2);

 target
.frontMostApp().mainWindow().buttons()["Play"].tap();

 
UIATarget.localTarget().delay(1.2);

}

Shawn Busolits (IMA SDK Team)

unread,
May 6, 2015, 4:44:42 PM5/6/15
to ima...@googlegroups.com, cgol...@gmail.com
Hey Chris,

Thanks for the additional info. I'm able to replicate the crash with your automated script, but I still can't replicate it manually. This will be tough to debug since we can't work the same way through instruments that we could if we were just running the test manually. I'll let the rest of the team know about this issue and we'll see if there's anything we can do.

Thanks,
Shawn Busolits
IMA SDK Team

Reply all
Reply to author
Forward
0 new messages