Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkOnMainThreadException when destroying MediationBannerAdUnit #678

Closed
linean opened this issue Sep 1, 2023 · 0 comments · Fixed by #704 or #734
Closed

NetworkOnMainThreadException when destroying MediationBannerAdUnit #678

linean opened this issue Sep 1, 2023 · 0 comments · Fixed by #704 or #734
Assignees

Comments

@linean
Copy link
Contributor

linean commented Sep 1, 2023

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)

@ChrisHuie ChrisHuie moved this from Triage to Ready for Dev in Prebid Mobile Prioritization Sep 18, 2023
@jsligh jsligh self-assigned this Sep 19, 2023
@jsligh jsligh moved this from Ready for Dev to In Progress in Prebid Mobile Prioritization Sep 19, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Prebid Mobile Prioritization Nov 3, 2023
@alexsavelyev alexsavelyev moved this from Triage to Ready for Dev in Prebid Mobile Prioritization Jan 11, 2024
@jsligh jsligh moved this from Ready for Dev to In Progress in Prebid Mobile Prioritization Jan 18, 2024
@jsligh jsligh added the bug label Jan 25, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Prebid Mobile Prioritization Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment