Describe the bug
We recently upgraded the Prebid SDK from version 2.1.0 to 2.1.3. After this update, we encountered a new runtime crash scenario when attempting to destroy the MediationBannerAdUnit. It appears that this operation is now attempting to perform network operations synchronously, resulting in the Android system throwing a NetworkOnMainThreadException.
If MediationBannerAdUnit.destroy is not intended to be called from the main thread, I suggest adding an explicit check and update documentation to make it easier for developers to identify and prevent such calls.
To Reproduce
This issue is not easily reproducible and requires specific conditions to trigger. Our discovery of this problem was based on analysis of production logs.
Stacktrace
Caused by android.os.NetworkOnMainThreadException:
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at com.google.android.gms.org.conscrypt.Platform.blockGuardOnNetwork(:com.google.android.gms@233217015@23.32.17 (040300-560149384):5)
at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.shutdownAndFreeSslNative(:com.google.android.gms@233217015@23.32.17 (040300-560149384):1)
at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.close(:com.google.android.gms@233217015@23.32.17 (040300-560149384):79)
at com.android.okhttp.Connection.closeIfOwnedBy(Connection.java:1303)
at com.android.okhttp.OkHttpClient$1.closeIfOwnedBy(OkHttpClient.java:78)
at com.android.okhttp.internal.http.HttpConnection.closeIfOwnedBy(HttpConnection.java:137)
at com.android.okhttp.internal.http.HttpTransport.disconnect(HttpTransport.java:319)
at com.android.okhttp.internal.http.HttpEngine.disconnect(HttpEngine.java:739)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.disconnect(HttpURLConnectionImpl.java:126)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.disconnect(DelegatingHttpsURLConnection.java:93)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.disconnect(HttpsURLConnectionImpl.java:25)
at com.google.firebase.perf.network.InstrURLConnectionBase.disconnect(InstrURLConnectionBase.java:81)
at com.google.firebase.perf.network.InstrHttpsURLConnection.disconnect(InstrHttpsURLConnection.java:63)
at org.prebid.mobile.rendering.networking.BaseNetworkTask.destroy(BaseNetworkTask.java:141)
at org.prebid.mobile.rendering.networking.modelcontrollers.Requester.destroy(Requester.java:86)
at org.prebid.mobile.rendering.bidding.loader.BidLoader.destroy(BidLoader.java:180)
at org.prebid.mobile.api.mediation.MediationBaseAdUnit.destroy(MediationBaseAdUnit.java:275)
at org.prebid.mobile.api.mediation.MediationBannerAdUnit.destroy(MediationBannerAdUnit.java:60)
Describe the bug We recently upgraded the Prebid SDK from version 2.1.0 to 2.1.3. After this update, we encountered a new runtime crash scenario when attempting to destroy the
MediationBannerAdUnit
. It appears that this operation is now attempting to perform network operations synchronously, resulting in the Android system throwing aNetworkOnMainThreadException
.If
MediationBannerAdUnit.destroy
is not intended to be called from the main thread, I suggest adding an explicit check and update documentation to make it easier for developers to identify and prevent such calls.To Reproduce This issue is not easily reproducible and requires specific conditions to trigger. Our discovery of this problem was based on analysis of production logs.
Stacktrace