-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Crash Report: ConcurrentModificationException #924
Comments
I believe this is caused because we access these
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... |
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? |
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? |
It happen like 30 Times now 🤔 |
We know this issue happens, without a proper way to reproduce it, it is however very difficult to debug, fix and confirm the fix. :( |
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 |
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? |
I don't think it's that much work, I think it's literally just wrapping our Linked Hash Maps inside a synchronizedMap and using the wrapping the map iterations inside a I'll probably start this tonight, or if you like to tackle this yourself, feel free. |
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? |
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... |
@HansKrywaa I have a branch at https://github.com/breautek/cordova-android/commits/concurrent-plugin-manager-8.1 I would advise you to fork Then you can install the platform via
Just like any You can look at the change set at breautek@bfda452 Upon further reading, it looks like I didn't need to wrap everything inside a 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...? 🤞 Please do keep me updated. |
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! 😊 |
So just to let you know: Currently we had two Versions released before. Within these we had for now over 35 Crash Reports (nearly daily). |
Just got this Crash:
I think it is the same? |
Hmm, looks like it, just in a different area. But it's still inside a loop like the original 2 stacktraces. Using We don't use iterators directly, we use a for in block... so I didn't think we needed the And I trust that your new stacktrace crash came from an updated version of the app that contains the breautek@bfda452 patch? |
Like you said, i forked your branch (See my Fork) and use this as the android platform. It is definitely used |
It's important to determine that the crash came from someone who has actually updated their app to the version that includes your fork. If the crash came from someone who was using the older version that we already know was broken because they simply have not updated then the stack trace doesn't tell us anything new. |
Yeah i can see that the User with the Crash is using Version 2.0.3 which is the one we build today |
oh sorry sorry sorry my bad. It was Version 2.0.2, i was confused because like we have 30-40 other crashes right now from other stuff... My bad i'm sorry |
Ah ok, and does 2.0.2 includes your fork or was that only added in 2.0.3? |
no the Fork only was includes since 2.0.3, so we are running good at this front at the moment 😂 Sorry for confusing |
No problem 😄 so as far as we know, the |
Ok but know really. I got the same Crash for the Version with the Fork... 😕 This Time really^^ Huawei P30 Lite (Android 9) |
Ok... well that means I think every loop block needs to be inside a I'm not sure why |
But the "default" Crash didn't happen so far. So how should we continue? |
Hey again, any Updates on this? |
Sorry, I got busy.
What do you mean by the "default" crash? |
I mean the Crash the Issue was about. So at But that is not true, this Crash still happens. |
Ok, I'm going to have to add the Info needed tag. I'm not sure when I'll be able to get back to this but we will going to need to find a way to reliably reproduce the crash in a sample app. I think it's obvious that this issue is caused by a race condition so that it is going to be very difficult to reproduce this in a simple sample app, so the sample app may need to have modified framework code that forces the app to reliably trigger |
@breautek Did you see the PR - will this fix this? We still have many crashes with this |
@breautek @EinfachHans The issue is caused by cordova plugin's that use different threads to perform there executions. When they complete their action, some times the iterators are changed, causing the My initial thought was using Only by wrapping all the Note the downside of doing this is that your app load may be abit slow as now the plugins different threads need to wait for the threads of another plugin. The 2 changesets that fix this problem. Feel free to use as you see fit. |
Are you saying the PR #1073 did not address the issue for you?
Personally I don't see a way around that if unrelated plugin code is causing conflicts. My motto is make the framework work, then find a way to optimise later if necessary. So I think that's okay for now.
A PR would be appreciated. I was never able to reproduce this issue myself, and the combination of plugins in my production apps doesn't appear to trigger this issue so I'm relying on your observations. If you can prepare a branch with those commits and create a PR, it will make it easy for @EinfachHans to try it on his own apps to see if it resolves the issue for him. |
I didn't use PR #1073, so can't comment whether it works or not. I can confirm that just changing to using the synchronizedMap does not fix the issue. I will add that even if PR #1073 works, it will not fix all |
Not sure why the PR #1091 failed macOs tests.... |
Yah, I provided a test fix for @EinfachHans awhile back that simply changed the lists to a
Glancing over the PR, it looks like you've updated all methods to be synchronized?
I don't think it's the fault of the PR, it appears to be a timeout issue, I can try restarting the tests. |
Yes, because in my app, I had CME occurring on the other functions too. |
So whenever you say, i can use a Fork in the next release of our app. Because this is currently only supported in production (often) and then check for some month/weeks if the crash appears. But because of this and because our app is very "important" (emergenc app in cooperation with german police) and we have many users the fork should be really safe to use 😬 |
Co-authored-by: 8bhsolutions <48874658+8bhsolutions@users.noreply.github.com>
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
and
java.util.ConcurrentModificationException: java.util.ConcurrentModificationException
Environment, Platform, Device
From Crashlog this happens to a Mate 20 Pro with Android 9 and a Galaxy Note10+ with Android 10 too.
Maybe related Issue?
Please fix this 😊
Checklist
The text was updated successfully, but these errors were encountered: