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

bug: ANR crash java.util.ConcurrentModificationException com.getcapacitor.Plugin.notifyListeners #4797

Closed
Rosadojonathan opened this issue Jul 7, 2021 · 3 comments · Fixed by #5125

Comments

@Rosadojonathan
Copy link

Rosadojonathan commented Jul 7, 2021

Bug Report

Capacitor Version


  @capacitor/cli 1.5.2

  @capacitor/android 2.4.7

  @capacitor/ios 2.4.7

  @capacitor/core 1.5.2

Platform(s)

Android

Current Behavior

My app seems to crash fairly often (4.5% of sessions) on android.
It seems to happen after accessing the Camera, but not while accessing it.
The error I see mentioned on the Google Play Console ANR crash report.
image
java.util.ConcurrentModificationException
com.getcapacitor.Plugin.notifyListeners

Expected Behavior

I expect the app not to crash as often.

@danishin
Copy link

danishin commented Jul 11, 2021

I have the same issue and in my case, it seems to happen in push-notifications library.
We also have fairly high number of crashes happening with our users.
I'm currently using "@capacitor/android": "3.0.2", "@capacitor/ios": "3.0.2", "@capacitor/push-notifications": "1.0.2"

java.util.ConcurrentModificationException
	at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
	at com.getcapacitor.Plugin.notifyListeners(Plugin.java:671)
	at com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin.sendToken(PushNotificationsPlugin.java:194)
	at com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin$1.onSuccess(PushNotificationsPlugin.java:91)
	at com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin$1.onSuccess(PushNotificationsPlugin.java:88)
	at com.google.android.gms.tasks.zzn.run(com.google.android.gms:play-services-tasks@@17.2.0:4)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5927)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)

@phal0r
Copy link

phal0r commented Jul 26, 2021

Can confirm this error on Android. In my case it's the Keyboard plugin:

java.util.ConcurrentModificationException: 
  at java.util.ArrayList$Itr.next (ArrayList.java:860)
  at com.getcapacitor.Plugin.notifyListeners (Plugin.java:348)
  at com.getcapacitor.Plugin.notifyListeners (Plugin.java:361)
  at com.getcapacitor.plugin.Keyboard.access$900 (Keyboard.java:25)
  at com.getcapacitor.plugin.Keyboard$1$1.onGlobalLayout (Keyboard.java:91)
  at android.view.ViewTreeObserver.dispatchOnGlobalLayout (ViewTreeObserver.java:1056)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2739)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1819)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7781)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1031)
  at android.view.Choreographer.doCallbacks (Choreographer.java:854)
  at android.view.Choreographer.doFrame (Choreographer.java:789)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1016)
  at android.os.Handler.handleCallback (Handler.java:883)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:224)
  at android.app.ActivityThread.main (ActivityThread.java:7562)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)

The error suggests, that the cause is in the BasePlugin Class and not a plugin itself. Looking at the sourcecode I am not sure, how notifyListeners modifies its list as it actually only reads from it. Hopefully someone from the core team can shed some light on this.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants