You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/03/10 08:32:46 UTC

[GitHub] [cordova-android] HansKrywaa opened a new issue #924: Crash Report: ConcurrentModificationException

HansKrywaa opened a new issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924
 
 
   # Bug Report
   
   ## Problem
   
   We mentioned some Crash Reports from our App, build with `cordova-android@8.1.0`. Crashlog:
   
   **java.util.ConcurrentModificationException: java.util.ConcurrentModificationException**
   ```
   java.util.LinkedHashMap$LinkedHashIterator.nextNode LinkedHashMap.java:775
   java.util.LinkedHashMap$LinkedValueIterator.next LinkedHashMap.java:803
   org.apache.cordova.PluginManager.onResume PluginManager.java:262
   org.apache.cordova.CordovaWebViewImpl.handleResume CordovaWebViewImpl.java:452
   org.apache.cordova.CordovaActivity.onResume CordovaActivity.java:277
   android.app.Instrumentation.callActivityOnResume Instrumentation.java:1465
   android.app.Activity.performResume Activity.java:8203
   android.app.ActivityThread.performResumeActivity ActivityThread.java:4757
   android.app.ActivityThread.handleResumeActivity ActivityThread.java:4810
   android.app.servertransaction.ResumeActivityItem.execute ResumeActivityItem.java:52
   android.app.servertransaction.TransactionExecutor.executeLifecycleState TransactionExecutor.java:190
   android.app.servertransaction.TransactionExecutor.execute TransactionExecutor.java:105
   android.app.ActivityThread$H.handleMessage ActivityThread.java:2373
   android.os.Handler.dispatchMessage Handler.java:107
   android.os.Looper.loop Looper.java:213
   android.app.ActivityThread.main ActivityThread.java:8147
   java.lang.reflect.Method.invoke Method.java
   com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:513
   com.android.internal.os.ZygoteInit.main ZygoteInit.java:1101
   ```
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   
   From Crashlog this happens to a Mate 20 Pro with Android 9 and a Galaxy Note10+ with Android 10 too.
   
   ### Maybe related Issue?
    - #912 
   
   Please fix this 😊
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [X] I searched for existing GitHub issues
   - [X] I updated all Cordova tooling to most recent version
   - [X] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613461405
 
 
   The App is a „big" one, from one of the biggest Insurances from Germany. I'm the developer, but i can't just say: Yes we make it like this, if we don't know how the performance is losing. 🤔
   
   But in general this sounds like a good idea, is this fork much work for you? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-612698912
 
 
   Nah... the content of your app doesn't sound like it fit well with my theory... How often do you see these crashes in your crashlytics? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613423950
 
 
   It happen like 30 Times now 🤔

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613745852
 
 
   @HansKrywaa I have a branch at https://github.com/breautek/cordova-android/commits/concurrent-plugin-manager-8.1
   
   I would advise you to fork `cordova-android` and merge my branch into your own fork (that way you have complete control)
   
   Then you can install the platform via
   
   `cordova platform add https://github./com/yourgitrepo.git#your-branch`
   
   Just like any `cordova-android` update, you'll need to remove the platform first by doing:
   `cordova platform remove android`
   
   You can look at the change set at https://github.com/breautek/cordova-android/commit/bfda452a09ba26412e0f527f6af1957379d89453
   
   Upon further reading, it looks like I didn't need to wrap everything inside a `synchronized` block, **unless** if you use the iterators, which the codebase does not. So using `Collections.synchronizedMap` should be enough, but again, hard to say for certain when we lack a reproducible test case.
   
   I saw no significant performance impact with my test app, but obviously my test app wasn't a real production app. It was just the cordova hello world app with all of the apache plugins installed. I'll leave it up to you if you see any significant performance impacts on your app, which would represent a real-world scenario.
   
   Given how frequent the crash appears to occur... with any luck, you won't see the crash for the next 30 days or so...? :crossed_fingers: 
   
   Please do keep me updated.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-612619725
 
 
   Hey @breautek ,
   
   thanks for your explanation.
   
   About our App: It's a App where you can companionship someone, so basically it's a lot about Background Location and Websockets. I also used a Plugin which allows me to run in the Background, with a Method do disable the WebView Optimization: https://github.com/HansKrywaa/cordova-plugin-advanced-background-mode
   
   Can i give you any more Information?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613471483
 
 
   I currently won't have the time 😕 Please message me if you are ready, so i can try it out and maybe use it in the next Release. Will we be able to test performance somehow?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] timbru31 commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
timbru31 commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613443387
 
 
   We know this issue happens, without a proper way to reproduce it, it is however very difficult to debug, fix and confirm the fix. :(

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
HansKrywaa commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613837805
 
 
   Thanks for your work, i will do like you told. I'm not sure when we will build the next Release Version, but i will use the Fork in this and ping you here for your Information! 😊

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-612563876
 
 
   I believe this is caused because we access these `LinkedHashMap` objects potentially from different threads and these hash maps are not thread safe.
   
   > Note that this implementation is not synchronized. If multiple threads access a linked hash map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. This is typically accomplished by synchronizing on some object that naturally encapsulates the map. If no such object exists, the map should be "wrapped" using the Collections.synchronizedMap method. This is best done at creation time, to prevent accidental unsynchronized access to the map:
      Map m = Collections.synchronizedMap(new LinkedHashMap(...));
   
   https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html
   
   However it will be very hard to be confident unless if we can reproduce this reliability. In the above callstacks, it seems to be occurring on the iteration of plugins on responding to a pause or resume event. Unfortunately this isn't necessary the error, it's just tells us that the hash map has changed while we were iterating.
   
   @HansKrywaa can you tell me a little bit of your app? My wild theory is this is related to maybe the webview being unloaded/killed but that would only make sense if your app goes into the background to load up something memory intensive (such as the camera app). Normally under this situation, the webview is suppose to load back up (but the webview environment would be refreshed). I'm thinking there might be a race condition there...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613470397
 
 
   I don't think it's that much work, I think it's literally just wrapping our Linked Hash Maps inside a [synchronizedMap](https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap(java.util.Map)) and using the wrapping the map iterations inside a `synchronized` block. 
   
   I'll probably start this tonight, or if you like to tackle this yourself, feel free.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek edited a comment on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek edited a comment on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613476176
 
 
   I think all iterations of the plugin map needs to be synchronized, so logically I think I believe if you have a large number of plugins, you'll see a bigger impact. I'll test by installing all the apache plugins + maybe a few more and try to compare apps on cordova-android@8.1 vs the fork.
   
   This is all just speculation, so we'll see just how big of the impact is. The impact could be insignificant altogether as well, for all we know...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613476176
 
 
   I think all iterations of the plugin map needs to be synchronized, so logically I think I believe if you have a large number of plugins, you'll see a bigger impact. I'll test by installing all the apache plugins + maybe a few more and try to compare apps on cordova-android@8.1 vs the fork.
   
   This is all just speculation, so we'll see just how big of the impact is.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #924: Crash Report: ConcurrentModificationException

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #924: Crash Report: ConcurrentModificationException
URL: https://github.com/apache/cordova-android/issues/924#issuecomment-613457396
 
 
   To be clear he was just simply responding to my question haha...
   
   If it only happened 30 times since you opened the issue, that's approximately 1 occurrence per day... which means the chances of intentionally triggering the bug naturally will likely be extremely difficult.
   
   I have a feeling that there are potential race conditions in the resume/pause lifecycles but we will likely need a controlled test case to prove it...
   
   Or if you're willing... I can branch off of 8.1 and implement `synchronizedMap` and you can fork my branch. We'll see if the problem goes away. If it is a race condition, the java docs appears to suggest that `synchronizedMap` should fix it by ensuring synchronised access to our plugin maps. I'm assuming this is at a performance cost though and I'm not sure how significant that would be...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org