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: Concurrent Modification Exception when writing trip data #232

Open
Ixam97 opened this issue Jun 10, 2024 · 3 comments
Open

Bug: Concurrent Modification Exception when writing trip data #232

Ixam97 opened this issue Jun 10, 2024 · 3 comments
Labels
begun partially implemented bug Something isn't working to do list Features planed to be implemented

Comments

@Ixam97
Copy link
Owner

Ixam97 commented Jun 10, 2024

02.06.2024 10:33:05.642 E: [NEO] Car Stats Viewer has crashed!
 java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.next(ArrayList.java:860)
	at com.ixam97.carStatsViewer.dataProcessor.DataProcessor$updateDrivingDataPoint$1.invokeSuspend(DataProcessor.kt:851)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@661e7de, Dispatchers.IO]
02.06.2024 20:18:31.008 E: FATAL ERROR! Writing trips was not successful: java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.next(ArrayList.java:860)
	at com.ixam97.carStatsViewer.dataProcessor.DataProcessor.writeTripsToDatabase(DataProcessor.kt:861)
	at com.ixam97.carStatsViewer.dataProcessor.DataProcessor.access$writeTripsToDatabase(DataProcessor.kt:36)
	at com.ixam97.carStatsViewer.dataProcessor.DataProcessor$updateDrivingDataPoint$1.invokeSuspend(DataProcessor.kt:517)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
@Ixam97 Ixam97 added bug Something isn't working to do list Features planed to be implemented labels Jun 10, 2024
@Ixam97 Ixam97 added begun partially implemented and removed to do list Features planed to be implemented labels Aug 14, 2024
@Ixam97
Copy link
Owner Author

Ixam97 commented Aug 14, 2024

I have made some small code changes with 53ac6f0 in an attempt to fix this issue, in the hopes this fix does not create other issues. Some users are heavily affected by this and can't even launch the app because of this crash.

@Ixam97 Ixam97 added the to do list Features planed to be implemented label Aug 14, 2024
@Ixam97
Copy link
Owner Author

Ixam97 commented Aug 15, 2024

Feedback on this issue suggests that it may be caused by very large distances in a single trip. Currently I have no way to validate this, but I'll keep an eye on this and think about some possible optimizations in this regard.

@Ixam97
Copy link
Owner Author

Ixam97 commented Aug 17, 2024

To limit the effects of long trips, I have limited the number of driving points loaded by default to 2000 in 498e41e. This should improve performance when it comes to adding new data to a trip while driving by reducing the data that has to be copied.

This is a quick improvement, but taking a closer look at the current way ongoing trips are handled it's clear that this is quite cumbersome and error prone. Perspectively I will replace the list of sessions with a class that contains them and makes it more robust. #231 Should also profit from this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
begun partially implemented bug Something isn't working to do list Features planed to be implemented
Projects
None yet
Development

No branches or pull requests

1 participant