IMA SDK for iOS: IMAAdsLoader delegate methods not called after switching delegate

331 views
Skip to first unread message

Peter Schumacher

unread,
Nov 4, 2015, 8:30:09 AM11/4/15
to Interactive Media Ads SDK
Hi,

To prevent the setup Time of 1-2 seconds of the IMAAdsLoader, i made it a singleton for my App.
The First use of it works as intended and as long as the Delegate does not change i can request as many ads as i want (always destroying the AdsManager and calling contendComplete on AdsLoader of course).
But if i dismiss the VideoView (the delegate of the AdsLoader) and create a new one (of course resetting the AdsLoader and setting the new delegate) the AdsLoader doesn't call any delegate methods.

Would be happy about a little help.

Tyler Sidell (IMA SDK Team)

unread,
Nov 4, 2015, 2:27:06 PM11/4/15
to Interactive Media Ads SDK
Hi Peter,

If the issue is to speed up the time of the IMAAdsLoader setup, you may want to take a look at our Best Practices.  I would also suggest that you use our sample examples to see if you are experiencing the same issues.  You can also supply us with your application or some relevant code snippets to that we can take a look.  

If you could elaborate on your specific use case of needing more than one AdsLoader, we can help assist.  I would suggest reusing the AdsLoader throughout your multiple sessions (i.e., not deallocating it), and instantiate a new AdsManager for each ad request.  You have to make sure that you destroy the AdsManager once you're done with the request.

Thanks,
Tyler Sidell
IMA SDK Team

Peter Schumacher

unread,
Nov 10, 2015, 10:51:29 AM11/10/15
to Interactive Media Ads SDK
Hi,

i could finally pinpoint the problem and reproduce it in your Advanced Example.
To reproduce the Problem you just have to switch the
-(void)viewWillDisappeaar:(BOOL)animated

method of the VideoViewController with the following:

- (void)viewDidDisappear:(BOOL)animated


{


    [self.contentPlayer pause];


    if (self.adsManager) {


        [self.adsManager destroy];


        self.adsManager = nil;


    }


    self.contentPlayer = nil;


   


    [super viewDidDisappear:animated];


}


Now when you start the first preroll, go back while its playing and then start it again, the AdsLoader dosen't receive an Ad.

I need to destroy the adsManager in viewDidDisappear because of an interactive Transition.
During this Transition the viewWillDisappear method gets called but the Transition still can get aborted which means the Preroll should continue and not get destroyed.
Only on the viewDidDisappear it is clear that the ViewController is getting dismissed and the adsManager has to be destroyed.

I realise that this is actually a completely different problem than the Title of this thread says, should i open a new thread?

Thanks

Peter

Tyler Sidell (IMA SDK Team)

unread,
Nov 10, 2015, 4:49:06 PM11/10/15
to Interactive Media Ads SDK
Hi Peter,

Thanks for supplying that code snippet. The SDK does not do any special behavior on viewWillDisappear. I would suggest that you try not destroying the adsManager to see if the preroll still stops. You can also add a navigationController.topViewController in order to check if the transition was cancelled.

Cheers,

Tyler Sidell
IMA SDK Team

Peter Schumacher

unread,
Nov 12, 2015, 5:24:52 AM11/12/15
to Interactive Media Ads SDK
I feel like you are not really understanding my Problem.
In your Advanced example there is also an interactive Transition.
If you start the first example with the Preroll and then drag from outside the screen from left to right you can go back to the MainViewController. But you can also cancel this transition and stay on the VideoViewController.
But in your current Version if you do that, the Preroll will stop.
If you apply my Code Snippet the Preroll will only stop once it is clear the VideoViewController will get dismissed. (Which is my desired Behaviour, with a pause and resume on the appropriate places)
But then it seems the next time the adsLoader tries to get your example VAST it doesn't succeed, with different LogOutputs
For Example: 
   Error loading ads: Unable to request ads from server due to network error,
  or  Error loading ads: The VAST response document is empty.

Also in you advanced Example the VideoViewController seems to never get deallocated. If You also add

- (void)dealloc

{

   NSLog(@"VideoViewController Dealloc");

}

to your VideoViewController, you will see that this will nether be printed. You can also see during debugging that the Memory footprint will grow each time you open another VideoViewController.

Tyler Sidell (IMA SDK Team)

unread,
Nov 12, 2015, 4:45:55 PM11/12/15
to Interactive Media Ads SDK
Hi Peter,

The error messages that you are receiving such as "The VAST response document is empty" can occur when making multiple requests to the same ad tag.  In order to make multiple requests to the same ad tag I would suggest that you check out the steps here.  You'll need to destroy your AdsManager instance, and then call contentComplete() on your AdsLoader.  This lets the SDK know that you want to make a new, unique request.

The app compiler should know when to automatically dealloc for you. You shouldn't have to worry about dealloc as the memory should eventually be stabilized. Can you supply a leak trace that shows that the memory is increasing? We will investigate this on our end.


Thanks,
Tyler Sidell
IMA SDK Team

Peter Schumacher

unread,
Nov 13, 2015, 6:38:03 AM11/13/15
to Interactive Media Ads SDK

I know that i need to destroy the adsManager and call contentComplete to make a new Request.

My Problem is that it doesn't work, when i call this in the viewDidDisappear Callback, which is the only place i can, as described before.

I implemented a workaround where i create a new adsLoader everytime i leave a VideoView, but i still think that it is a bug on your side.


Regarding the Memory leak.

My code Snipped doesn't make a call to dealloc it only also prints something to console when the object gets deallocated.

Its a handy thing if you have a hunch wich class won't get deallocated.

 

You can find a trace of the allocations here: https://dl.dropboxusercontent.com/u/16539706/IMAAdvancedExampleRun.trace.zip


Tyler Sidell (IMA SDK Team)

unread,
Nov 13, 2015, 4:49:56 PM11/13/15
to Interactive Media Ads SDK
Hi Peter,

Thank you for supplying the workaround.  We have not been able to reproduce the issue/error messages that you are receiving but we will continue to investigate.

Dealloc is only for non-ARC and will deallocate automatically so there may not be much we can do on that end but we'll take a look as well.

Cheers,
Tyler Sidell
IMA SDK Team

Peter Schumacher

unread,
Nov 16, 2015, 4:37:13 AM11/16/15
to Interactive Media Ads SDK
Even with ARC you can still override the dealloc method, mostly used to remove Notification Observers. It doesn't mean you have to call it yourself, thats what ARC does.
Reply all
Reply to author
Forward
0 new messages