Network plugin handleOnResume throws ANR
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java
- Domain
- mobile-dev, networking
Research direction
Start in network/android/src/main/java/com/capacitorjs/plugins/network/NetworkPlugin.java at handleOnResume and inspect Network.getNetworkStatus, especially the ConnectivityManager call shown in the ANR trace. Check how this plugin or repository dispatches background work before choosing an execution path. Done means resume handling no longer blocks the main thread while preserving the network-status behavior.
Written by the indexing model from the issue text.
Description
The network plugin's handleOnResume calls getNetworkStatus from main thread, which can be a slow operation:
https://github.com/ionic-team/capacitor-plugins/blob/2be8127d580a847c832698169893079b3960b9f3/network/android/src/main/java/com/capacitorjs/plugins/network/NetworkPlugin.java#L60
I've seen a crashlytics report of an ANR thrown because of this:
android.os.BinderProxy.transactNative (Native method)
This Binder call may be taking too long, causing the main thread to wait, and triggering the ANR.
android.os.BinderProxy.transact (BinderProxy.java:659)
android.net.IConnectivityManager$Stub$Proxy.getActiveNetwork (IConnectivityManager.java:1798)
android.net.ConnectivityManager.getActiveNetwork (ConnectivityManager.java:1549)
com.capacitorjs.plugins.network.Network.getNetworkStatus (Network.java:77)
com.capacitorjs.plugins.network.NetworkPlugin.handleOnResume (NetworkPlugin.java:60)
com.getcapacitor.Bridge.onResume (Bridge.java:1347)
com.getcapacitor.BridgeActivity.onResume (BridgeActivity.java:98)
android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1490)
android.app.Activity.performResume (Activity.java:8281)
android.app.ActivityThread.performResumeActivity (ActivityThread.java:4960)
android.app.ActivityThread.handleResumeActivity (ActivityThread.java:5018)
android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:60)
android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2374)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loopOnce (Looper.java:233)
android.os.Looper.loop (Looper.java:344)
android.app.ActivityThread.main (ActivityThread.java:8249)
java.lang.reflect.Method.invoke (Native method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:589)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1071)
Perhaps this call should make from a background thread like this?
@Override
public void handleOnResume() {
super.handleOnResume();
// Dispatch heavy operations off the Main thread
CapacitorJS.getEngine().executeOnBackgroundThread(() -> {
// Your background work here
});
}
``
- Dominant language
- Java
- Stars
- 682
- Forks
- 689
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ionic-team/capacitor-plugins
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageOpentriage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ionic-team/capacitor-plugins#2604 ·
-
platform: ios
Difficulty 4/5 3-5 days Newbie friendliness 58/100
ionic-team/capacitor-plugins#2603 · 1 comment ·
-
platform: android
Difficulty 3/5 1-2 days Newbie friendliness 76/100
ionic-team/capacitor-plugins#2599 ·
-
platform: ios
Difficulty 3/5 1-2 days Newbie friendliness 68/100
ionic-team/capacitor-plugins#2595 · 1 reaction ·
-
platform: android triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
ionic-team/capacitor-plugins#2593 ·
All issues in ionic-team/capacitor-plugins
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
apache/arrow-java#1311 ·
Maintainers usually reply within 2 days
-
bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
IBM/networking-java-sdk#204 ·