admob-plus / admob-plus

Trustable AdMob Plugin for Cordova, Capacitor, Ionic, React Native
https://admob-plus.github.io
MIT License
361 stars 150 forks source link

ConcurrentModificationException onPause #630

Open becvert opened 5 months ago

becvert commented 5 months ago

Describe the bug

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5423)
  at android.app.ActivityThread.performPauseActivity (ActivityThread.java:5374)
  at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:5321)
  at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:53)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2489)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:240)
  at android.os.Looper.loop (Looper.java:351)
  at android.app.ActivityThread.main (ActivityThread.java:8427)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:568)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1041)
Caused by java.util.ConcurrentModificationException:
  at java.util.LinkedHashMap$LinkedHashIterator.nextNode (LinkedHashMap.java:760)
  at java.util.LinkedHashMap$LinkedEntryIterator.next (LinkedHashMap.java:792)
  at java.util.LinkedHashMap$LinkedEntryIterator.next (LinkedHashMap.java:790)
  at admob.plus.cordova.AdMob.onPause (AdMob.kt:227)
  at org.apache.cordova.PluginManager.onPause (PluginManager.java:241)
  at org.apache.cordova.CordovaWebViewImpl.handlePause (CordovaWebViewImpl.java:482)
  at org.apache.cordova.CordovaActivity.onPause (CordovaActivity.java:255)
  at android.app.Activity.performPause (Activity.java:8614)
  at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1604)
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5413)

To Reproduce I did not reproduce it myself, just noticed it on Google Play Console lately

Additional context Android SDK 29 Android SDK 33 so far

Thank you

becvert commented 5 months ago

onDestroy too

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5176)
  at android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:5195)
  at android.app.servertransaction.DestroyActivityItem.execute (DestroyActivityItem.java:39)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2199)
  at android.os.Handler.dispatchMessage (Handler.java:112)
  at android.os.Looper.loop (Looper.java:216)
  at android.app.ActivityThread.main (ActivityThread.java:7625)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)
Caused by java.util.ConcurrentModificationException:
  at java.util.LinkedHashMap$LinkedHashIterator.nextNode (LinkedHashMap.java:760)
  at java.util.LinkedHashMap$LinkedValueIterator.next (LinkedHashMap.java:788)
  at admob.plus.cordova.AdMob.onDestroy (AdMob.kt:208)
  at org.apache.cordova.PluginManager.onDestroy (PluginManager.java:339)
  at org.apache.cordova.CordovaWebViewImpl.handleDestroy (CordovaWebViewImpl.java:531)
  at org.apache.cordova.CordovaActivity.onDestroy (CordovaActivity.java:327)
  at android.app.Activity.performDestroy (Activity.java:7737)
  at android.app.Instrumentation.callActivityOnDestroy (Instrumentation.java:1327)
  at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5161)
becvert commented 4 months ago

Since I replaced val ads = synchronizedMap(mutableMapOf<String, AdBase>())] in ExecuteContext.kt with ConcurrentHashMap I don't see the above exceptions.