I am using GoogleAds-IMA-iOS-SDK 3.0.beta.13.
- (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)];
}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);
}