urbanairship / android-library

Urban Airship Android SDK
Other
109 stars 123 forks source link

IllegalArgumentException: Too many NetworkRequests filed #237

Closed juliocbcotta closed 6 months ago

juliocbcotta commented 6 months ago

Preliminary Info

We got this crash from crashlytics

Screenshot 2024-02-15 at 10 48 30

What Airship dependencies are you using?

airship = "17.7.1"

airship = { module = "com.urbanairship.android:urbanairship-fcm", version.ref = "airship" } airship_automation = { module = "com.urbanairship.android:urbanairship-automation", version.ref = "airship" }

Report

What unexpected behavior are you seeing?

Fatal Exception: java.lang.IllegalArgumentException: Too many NetworkRequests filed
       at android.os.Parcel.readException(Parcel.java:1687)
       at android.os.Parcel.readException(Parcel.java:1636)
       at android.net.IConnectivityManager$Stub$Proxy.requestNetwork(IConnectivityManager.java:2281)
       at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:2793)
       at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:3070)
       at com.urbanairship.automation.NetworkMonitor.registerNetworkCallback(NetworkMonitor.java:51)
       at com.urbanairship.automation.NetworkMonitor.setConnectionListener(NetworkMonitor.java:78)
       at com.urbanairship.automation.AutomationEngine.start(AutomationEngine.java:295)
       at com.urbanairship.automation.InAppAutomation.ensureStarted(InAppAutomation.java:957)
       at com.urbanairship.automation.InAppAutomation.checkUpdatesSubscription(InAppAutomation.java:964)
       at com.urbanairship.automation.InAppAutomation.onAirshipReady(InAppAutomation.java:336)
       at com.urbanairship.UAirship.executeTakeOff(UAirship.java:437)
       at com.urbanairship.UAirship.access$000(UAirship.java:70)
       at com.urbanairship.UAirship$2.run(UAirship.java:385)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at com.urbanairship.util.AirshipThreadFactory$1.run(AirshipThreadFactory.java:50)
       at java.lang.Thread.run(Thread.java:761)

What is the expected behavior?

Not crashing

What are the steps to reproduce the unexpected behavior?

We don't know how to reproduce.

jyaganeh commented 6 months ago

Hi @juliocbcotta, we're looking into this. Do you call registerNetworkCallback on ConnectivityManager anywhere in your app code, or do you use WorkManager with jobs that require network access?

juliocbcotta commented 6 months ago

Not that I am aware of, but some other library may do the same, right ?

jyaganeh commented 6 months ago

@juliocbcotta Yes, there's a limit of 100 active network callbacks, per-app, and it seems likely that another library may be using up all of the available requests before we're able to register our listener.

I've checked the few spots where we're doing that and I'm not seeing a path through the code that would cause our SDK to repeatedly register the network callback. If you don't mind sharing the dependencies section from your build.gradle, I could take a look to see which ones may be registering network callbacks. If you'd rather not post that in a public space, my email is {first}.{last}@airship.com (using the name in my github profile for the first and last).

jyaganeh commented 6 months ago

Closing this due to lack of updates. Please feel free to re-open if you'd like me to take a look at your dependencies.