Skip to content

Network operation is being attempted on the main thread of app within the Firebase Remote Config library, specifically related to its real-time features #6935

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

Closed
ohran9 opened this issue May 5, 2025 · 2 comments

Comments

@ohran9
Copy link

ohran9 commented May 5, 2025

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Meerkat | 2024.3.1 Patch 2
  • Firebase Component: Remote Config
  • Component version: 22.1.1

[REQUIRED] Step 3: Describe the problem

A Fatal Exception: android.os.NetworkOnMainThreadException occurring at com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient.setIsInBackground (ConfigRealtimeHttpClient.java:413) indicating that a network operation is being attempted on the main thread of our Android application within the Firebase Remote Config library, specifically related to its real-time features.

It occurs on a range of devices (Samsung, Lenovo, Oppo...) with varying Android versions (from 5.0 to 10)

Steps to reproduce:

This is the log from Crashlytics

Fatal Exception: android.os.NetworkOnMainThreadException:
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1318)
at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:300)
at com.android.org.conscrypt.OpenSSLSocketImpl.shutdownAndFreeSslNative(OpenSSLSocketImpl.java:1209)
at com.android.org.conscrypt.OpenSSLSocketImpl.close(OpenSSLSocketImpl.java:1204)
at com.android.okhttp.Connection.closeIfOwnedBy(Connection.java:173)
at com.android.okhttp.OkHttpClient$1.closeIfOwnedBy(OkHttpClient.java:77)
at com.android.okhttp.internal.http.HttpConnection.closeIfOwnedBy(HttpConnection.java:137)
at com.android.okhttp.internal.http.HttpTransport.disconnect(HttpTransport.java:135)
at com.android.okhttp.internal.http.HttpEngine.disconnect(HttpEngine.java:600)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.disconnect(HttpURLConnectionImpl.java:134)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.disconnect(DelegatingHttpsURLConnection.java:93)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.disconnect(HttpsURLConnectionImpl.java)
at com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient.setIsInBackground(ConfigRealtimeHttpClient.java:413)
at com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler.setBackgroundState(ConfigRealtimeHandler.java:94)
at com.google.firebase.remoteconfig.FirebaseRemoteConfig.setConfigUpdateBackgroundState(FirebaseRemoteConfig.java:715)
at com.google.firebase.remoteconfig.RemoteConfigComponent.notifyRCInstances(RemoteConfigComponent.java:367)
at com.google.firebase.remoteconfig.RemoteConfigComponent.access$100(RemoteConfigComponent.java:64)
at com.google.firebase.remoteconfig.RemoteConfigComponent$GlobalBackgroundListener.onBackgroundStateChanged(RemoteConfigComponent.java:405)
at com.google.android.gms.common.api.internal.BackgroundDetector.zza(com.google.android.gms:play-services-basement@@18.5.0:3)
at com.google.android.gms.common.api.internal.BackgroundDetector.onTrimMemory(com.google.android.gms:play-services-basement@@18.5.0:3)
at android.app.Application.onTrimMemory(Application.java:136)
at android.app.ActivityThread.handleTrimMemory(ActivityThread.java:5140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1726)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6289)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Relevant Code:

*Code is used in the Application class onCreate method!

 CoroutineScope(Dispatchers.IO).launch {
        try {
            val remoteConfigFirebase = Firebase.remoteConfig

            remoteConfigFirebase.apply {
                fetchAndActivate()
                    .addOnCompleteListener { task ->
                        if (task.isSuccessful) {
                                setRemoteValues(true, task, this)
                        } else {
                            AppLogger.d("ConfigFirebase update failed")
                        }
                    }
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        }
@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@lehcar09
Copy link
Contributor

lehcar09 commented May 6, 2025

Hi @ohran9, thank you for reaching out. This issue looks similar to #6934. To streamline updates, I'll close this issue now as duplicate. Please refer to @6934 for further communication. Thanks!

@lehcar09 lehcar09 closed this as completed May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants