Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

[IMA SDK] ConcurrentModificationException in IMA SDK - WebView Issue

38 views
Skip to first unread message

Md Imran Choudhury

unread,
May 23, 2025, 3:33:52 AMMay 23
to Interactive Media Ads SDK

Dear Google IMA SDK Support Team,

We are encountering a ConcurrentModificationException within the IMA SDK that appears to be related to WebView handling. We are writing to report this issue and request your assistance in resolving it.

Description of the Issue:

Our application is crashing with a java.util.ConcurrentModificationException within the IMA SDK. The stack trace consistently points to the ArrayList$Itr.checkForComodification method, suggesting that a collection is being modified while it is being iterated. The crash occurs within the IMA SDK's internal code related to WebView URL handling, specifically in the shouldOverrideUrlLoading flow.

Version:
ExoPlayer 2.13.3

Devices that reproduce the issue:
Almost every device (example: Pixel 7a, 8, 9)

Android version: 
Android 9 to 14

Reproducible in the demo app?
Not tested

Reproduction steps
Click on ads

Expected result
The media plays successfully

Actual result

      Fatal Exception: java.util.ConcurrentModificationException:
       at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1111)
       at java.util.ArrayList$Itr.next(ArrayList.java:1064)
       at com.google.ads.interactivemedia.v3.internal.dn.d(IMASDK:1)
       at com.google.ads.interactivemedia.v3.internal.co.c(IMASDK:6)
       at com.google.ads.interactivemedia.v3.internal.ee.e(IMASDK:66)
       at com.google.ads.interactivemedia.v3.internal.ek.d(IMASDK:5)
       at com.google.ads.interactivemedia.v3.internal.eh.shouldOverrideUrlLoading(IMASDK:2)
       at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:91)
       at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-TrichromeWebViewGoogle6432.aab-stable-710306133:109)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:346)
       at android.os.Looper.loopOnce(Looper.java:189)
       at android.os.Looper.loop(Looper.java:317)
       at android.app.ActivityThread.main(ActivityThread.java:8860)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:968)


Thank you for your hard work. 
Best regards,
Imran
issue_c124a983ed5202f5b49435ba92a7ef88_crash_session_68299AC8015600010C2E3C96FA63B47D_DNE_8_v2_stacktrace.txt

IMA SDK

unread,
May 23, 2025, 9:57:49 AMMay 23
to mdimran....@rakuten.com, ima...@googlegroups.com
Hi Imran,

Thank you for contacting the IMA SDK support team.

Can you please confirm if you are trying to add a dummy ArrayList and manually trigger callbacks? If yes, then this is not support by the IMA SDK. If No, then can you provide us your Sample Project reproducing issue as without adding a dummy ArrayList, issue is not replicating in our samples.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=IMA+SDK&entry.460850823=500Ht00001qY3qjIAC&entry.80707362=00307893

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Thanks,
 
Google Logo IMA SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-05-23 13:57:39Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qY3qj:ref" (ADR-00307893)



Md Imran Choudhury

unread,
Jun 4, 2025, 12:34:20 PM (8 days ago) Jun 4
to Interactive Media Ads SDK

Thank you for your prompt response.

We haven't been able to reproduce the issue on our end either. However, we are frequently encountering crashes reported in Firebase specifically related to SSAI live content preroll ads when using the IMA SDK.

We are using exoplayer extension-ima version 2.13.3. To confirm, we are not using any dummy ArrayLists or manually triggering callbacks.

Before uploading the entire project, we'd like to share a few relevant code snippets that might help you identify potential issues. Please let us know if you'd like us to share specific sections of our code. 

private fun initializeAdsMediaSource(
context: Context,
mediaSource: MediaSource,
mediaDataSourceFactory: DataSource.Factory,
adsUri: Uri
): MediaSource? {
mAdsLoader ?: run {
mAdsLoader = ImaAdsLoader.Builder(context).apply {
adEventListener?.let setAdEventListener(it}
setImaSdkSettings(ImaSdkFactory.getInstance().createImaSdkSettings().also {
it.isDebugMode = BuildConfig.DEBUG
it.language "ja"
})
}.build()
}

val adMediaSourceFactory = DefaultMediaSourceFactory(mediaDataSourceFactory)
mAdsLoader?.setPlayer(mPlayer)
return mAdsLoader?.let {
AdsMediaSource(
mediaSource,
DataSpec(adsUri),
"preroll",
adMediaSourceFactory,
it,
mPlayerView!!
)
?: run null }
}

-----
fun createMediaDataSourceFactory(
context: Context,
listener: TransferListener?,
defaultHttpDataSourceFactory: HttpDataSource.Factory,
downloadCache: Cache?,
upstreamFactory: DefaultDataSourceFactory? = null
): DataSource.Factory {
val cache = downloadCache ?: return DefaultDataSourceFactory(context, listener, defaultHttpDataSourceFactory)

return CacheDataSource.Factory()
.setCache(cache)
.setUpstreamDataSourceFactory(upstreamFactory ?: DefaultDataSourceFactory(context, listener, defaultHttpDataSourceFactory))
.setCacheWriteDataSinkFactory(null)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
}

---------
fun createMediaSource(
context: Context,
playbackData: PlaybackData,
mediaDataSourceFactory: DataSource.Factory,
defaultHttpDataSourceFactory: HttpDataSource.Factory,
manifestURI: Uri,
downloadCache: Cache?,
offlineStreamKeys: List<StreamKey>,
drmSessionManagerProvider: DrmSessionManagerProvider?
): MediaSource = when (playbackData.videoDistributionType.type) {
C.TYPE_DASH ->
DashMediaSource.Factory(
DefaultDashChunkSource.Factory(mediaDataSourceFactory),
createMediaDataSourceFactory(
context,
null,
defaultHttpDataSourceFactory,
downloadCache
)
)
.setManifestParser(
FilteringManifestParser(
DashManifestParser(), offlineStreamKeys
)
)
.setDrmSessionManagerProvider(drmSessionManagerProvider)
.createMediaSource(
MediaItem.Builder().also {
it.setLiveTargetOffsetMs(playbackData.liveDelayTimeMillis)
it.setUri(manifestURI)
}.build()
)
C.TYPE_HLS ->
HlsMediaSource.Factory(
CustomHlsDataSourceFactory(defaultHttpDataSourceFactory, mediaDataSourceFactory,
mutableMapOf(
Pair("Accept-Encoding""gzip"),
Pair("Authorization""Bearer ${playbackData.apiAccessToken}"),
Pair("Access-Token", playbackData.apiAccessToken),
Pair("Cookie""RES=${playbackData.resolution};ItemId=${playbackData.itemId}")
))
)
.setPlaylistParserFactory(
DefaultHlsPlaylistParserFactory(
)
)
//.createMediaSource(manifestURI)
.setDrmSessionManagerProvider(drmSessionManagerProvider)
.createMediaSource(
MediaItem.Builder().also {
it.setUri(manifestURI)
}.build()
)
else ->
SsMediaSource.Factory(
DefaultSsChunkSource.Factory(mediaDataSourceFactory),
createMediaDataSourceFactory(
context,
null,
defaultHttpDataSourceFactory,
downloadCache
)
)
.setManifestParser(
FilteringManifestParser(
SsManifestParser(), emptyList<StreamKey>()
)
)
//.setLivePresentationDelayMs(playbackData.liveDelayTimeMillis)
//.createMediaSource(manifestURI)
.setDrmSessionManagerProvider(drmSessionManagerProvider)
.createMediaSource(
MediaItem.Builder().also {
it.setLiveTargetOffsetMs(playbackData.liveDelayTimeMillis)
it.setUri(manifestURI)
}.build()
)
}

IMA SDK

unread,
Jun 4, 2025, 6:09:18 PM (8 days ago) Jun 4
to mdimran....@rakuten.com, ima...@googlegroups.com

Hi Imran,

Thank you for confirming that you are not using any dummy ArrayLists or manually triggering callbacks.

Since the issue is not replicating on our end, as requested earlier a sample project reproducing the issue would help us in investigating this issue so that we can have the visibility of your implementation and we may provide the solution. 

You can provide the following details via reply privately to the author option or directly provide it to the link below.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=IMA+SDK&entry.460850823=500Ht00001qY3qjIAC&entry.80707362=00307893

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Thanks,
 
Google Logo IMA SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-06-04 22:09:06Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qY3qj:ref" (ADR-00307893)



IMA SDK

unread,
Jun 5, 2025, 7:05:22 AM (8 days ago) Jun 5
to ima...@googlegroups.com, mdimran....@rakuten.com

Hi,

I saw you mentioned you are using the 2.13.1 version, which looks like a very old one. I would suggest upgrading it to the latest exoplayer extension-ima version 2.19.1. It's always best to use the latest SDK versions and get back to us if this occurs again.

Thanks,
 
Google Logo IMA SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-06-05 11:05:03Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qY3qj:ref" (ADR-00307893)



Reply all
Reply to author
Forward
0 new messages