AdDisplayContainer object is not reusable in IMA SDK Android 3.21.2

236 views
Skip to first unread message

gourav...@gmail.com

unread,
Jan 13, 2021, 5:18:39 AM1/13/21
to Interactive Media Ads SDK
Hi There,

I am not able to reuse the adDisplayContainer object. I am reusing the object in changeMedia. IMA Advanced Example does not contain 'ChangeMedia' functionality so i have implemented in my fork repo.

Steps to reproduce:
1. Click on 'Pre-roll, linear not skippable'.
2. click on play button, Let the ad play and when the content start, seek to the end.
3. Let the ALL_ADS_COMPLETED event come in logs.
4. Click on 'CHANGE MEDIA' button.
5. Check the crash.

2021-01-13 15:45:55.921 29388-29388/com.google.ads.interactivemedia.v3.samples.videoplayerapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.ads.interactivemedia.v3.samples.videoplayerapp, PID: 29388
    java.lang.IllegalArgumentException: A given DisplayContainer may only be used once
        at com.google.ads.interactivemedia.v3.internal.arc.b(IMASDK:1)
        at com.google.ads.interactivemedia.v3.internal.anh.claim(IMASDK:1)
        at com.google.ads.interactivemedia.v3.internal.amw.<init>(IMASDK:13)
        at com.google.ads.interactivemedia.v3.internal.amw.<init>(IMASDK:1)
        at com.google.ads.interactivemedia.v3.api.ImaSdkFactory.createAdsLoader(IMASDK:6)
        at com.google.ads.interactivemedia.v3.samples.videoplayerapp.VideoPlayerController.createAdsLoader(VideoPlayerController.java:263)
        at com.google.ads.interactivemedia.v3.samples.videoplayerapp.VideoPlayerController.createAdDisplayContainer(VideoPlayerController.java:258)
        at com.google.ads.interactivemedia.v3.samples.videoplayerapp.VideoFragment.lambda$initUi$0$VideoFragment(VideoFragment.java:117)
        at com.google.ads.interactivemedia.v3.samples.videoplayerapp.-$$Lambda$VideoFragment$-aUALCOkbZ0heDSSWP4yW7ZTHS0.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:6600)
        at android.view.View.performClickInternal(View.java:6577)
        at android.view.View.access$3100(View.java:781)
        at android.view.View$PerformClick.run(View.java:25912)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6923)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
2021-01-13 15:45:55.952 29388-29388/com.google.ads.interactivemedia.v3.samples.videoplayerapp I/Process: Sending signal. PID: 29388 SIG: 9


Another issue: 

You can see the error message in the logs. This came after 'ALL_ADS_COMPLETED' event.

2021-01-13 15:45:51.223 29388-29388/com.google.ads.interactivemedia.v3.samples.videoplayerapp E/IMASDK: Error: Attempted to send bridge message after cleanup: JavaScriptMessage [command=adsManager, type=destroy, sid=d6f3eb7a-7434-4dfc-a1e2-de180b5d0a87, data=null]; javascript:adsense.mobileads.afmanotify.receiveMessage('adsManager', {"type":"destroy","sid":"d6f3eb7a-7434-4dfc-a1e2-de180b5d0a87"});

I had already raised an issue in this ticket.


gourav...@gmail.com

unread,
Jan 13, 2021, 5:20:00 AM1/13/21
to Interactive Media Ads SDK

Gourav Saxena

unread,
Jan 13, 2021, 5:41:21 AM1/13/21
to Interactive Media Ads SDK
FYI. The same logic with reusable AdDisplayContainer is working fine in v3.20.0

Regards,
Gourav


--
You received this message because you are subscribed to a topic in the Google Groups "Interactive Media Ads SDK" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ima-sdk/xyGgGW4_YaM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ima-sdk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ima-sdk/fdda3686-ee4b-4948-be80-e912e6387219n%40googlegroups.com.

IMA SDK

unread,
Jan 13, 2021, 11:44:18 AM1/13/21
to gourav...@gmail.com, ima...@googlegroups.com
Hi Gourav,

Thank you for sending over the information as well as the link to a sample that you modified. I was able to get the test to work and can see that in the logcat there does seem to be an issue with the view holding the ad being destroyed.

2021-01-13 11:23:16.898 19309-19309/com.google.ads.interactivemedia.v3.samples.videoplayerapp W/cr_AwContents: Application attempted to call on a destroyed WebView
    java.lang.Throwable
        at org.chromium.android_webview.AwContents.f(PG:379)
        at org.chromium.android_webview.AwContents.a(PG:353)
        at org.chromium.android_webview.AwContents.r(PG:655)
        at Bk.loadingStateChanged(PG:139)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:336)
        at android.os.Looper.loop(Looper.java:174)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Which would seem to indicate to us that this functionality is just no longer available? Or that something has changed in the SDK that makes this behave differently.

Regards,
Google Logo
William Pescherine
IMA SDK Team
 


ref:_00D1U1174p._5004Q2AzuCX:ref

Gourav Saxena

unread,
Jan 13, 2021, 1:00:33 PM1/13/21
to IMA SDK, ima...@googlegroups.com
Thanks William,

Can you please take it ahead with the team to understand the underlying cause of it ?

If this functionality is changed then do you/they have any document for it.

Regards,
Gourav

IMA SDK

unread,
Jan 13, 2021, 3:16:39 PM1/13/21
to gourav...@gmail.com, ima...@googlegroups.com
Hi Gourav,

Thank you for the response back. I will bring this to my team to look into more. To see if there has been some change to behavior that would cause this issue to happen. Once we get feedback, we will be certain to pass this along to you.

Gourav Saxena

unread,
Jan 14, 2021, 12:17:40 AM1/14/21
to IMA SDK, ima...@googlegroups.com
Thanks William,

If you can escalate it to the team, will be great because it is a blocker while upgrading the IMA version > 3.20.0 

Regards,
Gourav

gourav...@gmail.com

unread,
Jan 15, 2021, 8:03:58 AM1/15/21
to Interactive Media Ads SDK
Hi William,

Any update on this ? It is critical. 

One more update: If I pass new adDisplayContainer on the change media with new adsLoader (because after previous media playback, i released the adsLoader) then I don't see Ad's video frame, Ad UI is visible (timer and learn More).
 

gourav...@gmail.com

unread,
Jan 18, 2021, 11:05:22 AM1/18/21
to Interactive Media Ads SDK
Hi William,

Please let me know if you have any update on this issue.

IMA SDK

unread,
Jan 26, 2021, 11:24:51 AM1/26/21
to gourav...@gmail.com, ima...@googlegroups.com
Hello Gourav,

My name is Jackson and I am part of the IMA SDK DevRel team.

Starting in v3.21.0 changes were introduced to the clean-up of the IMA SDK in Android. This was done to resolve issues with memory leaks in the SDK. I do not believe reusing the adDisplayContainer was ever intentionally supported by the IMA team. Would it be possible to elaborate more on your use-case that requires reusing the adDisplayContainer?

Thank you,
Jackson
IMA SDK DevRel

ref:_00D1U1174p._5004Q2AzuCX:ref

Gourav Saxena

unread,
Jan 26, 2021, 12:21:50 PM1/26/21
to IMA SDK, Interactive Media Ads SDK
Hi Jackson,

Thanks for the update. You can take my fork branch and check the implementation. I have implemented change media in advanced example.


I am reusing the adDisplayContainer object on change media.

IMA SDK

unread,
Jan 26, 2021, 2:38:04 PM1/26/21
to gourav...@gmail.com, ima...@googlegroups.com
Hi Gourav,

Thank you for clarifying.

Would it be possible to remake the adDisplayContainer? That would be my recommendation if there is nothing preventing that in your use-case.

In addition you may want to call AdsLoader.release() when switching media as well.

Gourav Saxena

unread,
Jan 27, 2021, 2:00:26 AM1/27/21
to IMA SDK, ima...@googlegroups.com
Hi Jackson,

Thanks for the suggestion but I had tried it earlier and could not see any right outcome. 

But i will definitely try it once again; i will let you know.

Regards,
Gourav

Gourav Saxena

unread,
Jan 29, 2021, 5:56:12 AM1/29/21
to IMA SDK, ima...@googlegroups.com, Gilad Nadav
Hi Jackson,

I am sorry for my delayed response.

Actually the forked branch I shared with you, there I am creating a new AdDisplayContainer on change media and calling the AdsLoader the release on ALL_ADS_COMPLETED. Please check my pushed changes here.

You can try on my fork.

This was my original mail,

        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
2021-01-13 15:45:55.952 29388-29388/com.google.ads.interactivemedia.v3.samples.videoplayerapp I/Process: Sending signal. PID: 29388 SIG: 9


Regards,
Gourav

IMA SDK

unread,
Jan 29, 2021, 11:20:20 AM1/29/21
to gourav...@gmail.com, gilad...@kaltura.com, ima...@googlegroups.com
Hi Gourav,

This looks like expected behavior from the SDK. The changes to IMA clean up in v3.21.0 released on 10/23/2020 introduced the changes that limit the reuse of AdDisplayContainer.

My recommendation would be to change the code for createAdDisplayContainer() to always update the adDisplayContainer.

Let me know if that is possible, or explain the feature/use-case of your app that requires the reuse of AdDisplayContainer. I can then relay that the the team to see if it would be possible to change the current IMA behavior.

Gourav Saxena

unread,
Feb 1, 2021, 3:18:06 AM2/1/21
to IMA SDK, gilad...@kaltura.com, ima...@googlegroups.com
Hi Jackson,

Unfortunately, I have to do a lot in the IMA Advanced Example in order to achieve your suggestion. It will be good to see Change Media features in the future samples.

Anyways, I tried on our sample, where I am creating AdDisplayContainer every time and calling adsLoader.release on the change media. Here is the video link to see the issue. 
What I am seeing here is that the Ad Video frame is not visible and the Ad UI and audio is coming. Can you please suggest what else is required ? 

Or it is indicating some IMA's underlying bug.

Appreciate your reply.

Regards,
Gourav

Gourav Saxena

unread,
Feb 3, 2021, 7:59:19 AM2/3/21
to IMA SDK, gilad...@kaltura.com, ima...@googlegroups.com
Hi Jackson,

This ticket can be closed. We are able to resolve the issue on our end. 

Thanks to the team for the constant support.

Regards,
Gourav

Reply all
Reply to author
Forward
0 new messages