jetpref icon indicating copy to clipboard operation
jetpref copied to clipboard

java.util.ConcurrentModificationException

Open Purehi opened this issue 6 months ago • 15 comments

Device: Samsung Galaxy A35 5G Andorid OS: Android 14 (SDK 34)

Exception java.util.ConcurrentModificationException: at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:1111) at java.util.ArrayList$Itr.next (ArrayList.java:1064) at dev.patrickgold.jetpref.datastore.model.PreferenceModel$PersistenceHandler$loadPrefs$2$1$1$1.invokeSuspend (PreferenceModel.kt:304) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:100) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run (LimitedDispatcher.java:124) at kotlinx.coroutines.scheduling.TaskImpl.run (Tasks.kt:89) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.java:586) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:820) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:717) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:704)

Purehi avatar Jul 21 '25 14:07 Purehi

Which version of JetPref did you use to produce this crash, and do you have a way to reproduce this consistently?

patrickgold avatar Jul 21 '25 20:07 patrickgold

Version: v0.2.0-rc04 I use it with hilt with a @Singleton

Purehi avatar Jul 21 '25 22:07 Purehi

I have some rough idea on what could go wrong, as it may be connected to https://github.com/florisboard/florisboard/issues/1726

I will test some things tomorrow and come back to you.

patrickgold avatar Jul 21 '25 23:07 patrickgold

Your exception gave me some important hints to where JetPref's state bug originates => I will release 0.2 today and then start with 0.3 dev, where I will need to do some model rework (and breaking changes) to fix the state bug

patrickgold avatar Jul 22 '25 15:07 patrickgold

Thank you. I will test it now.

Purehi avatar Jul 23 '25 03:07 Purehi

Any updates? @patrickgold

Same Error. Version: 0.2

Exception java.util.ConcurrentModificationException: at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:1111) at java.util.ArrayList$Itr.next (ArrayList.java:1064) at dev.patrickgold.jetpref.datastore.model.PreferenceModel$PersistenceHandler$loadPrefs$2$1$1$1.invokeSuspend (PreferenceModel.kt:304) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:100) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run (LimitedDispatcher.java:124) at kotlinx.coroutines.scheduling.TaskImpl.run (Tasks.kt:89) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.java:586) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:820) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:717) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:704)

Purehi avatar Jul 23 '25 13:07 Purehi

=> I will release 0.2 today and then start with 0.3 dev

As stated here, I needed to do the 0.2 release because I want to rewrite the model internally (and a bit also the public API). Current dev work for first 0.3 beta is on the feat/jetprefv3 branch, but there is still testing to do by me, then I will open a draft PR and you can test the snapshot version.

patrickgold avatar Jul 27 '25 00:07 patrickgold

=> I will release 0.2 today and then start with 0.3 dev

As stated here, I needed to do the 0.2 release because I want to rewrite the model internally (and a bit also the public API). Current dev work for first 0.3 beta is on the feat/jetprefv3 branch, but there is still testing to do by me, then I will open a draft PR and you can test the snapshot version.

Do you have a draft PR ready for today?

Purehi avatar Jul 27 '25 00:07 Purehi

If today means CEST time zone then yes probably

patrickgold avatar Jul 27 '25 01:07 patrickgold

If today means CEST time zone then yes probably

Can it be released today? Or can you tell me how to modify it? Currently, more than 1,000 users are affected by this.

Purehi avatar Jul 28 '25 03:07 Purehi

Please see PR #22 for the draft new implementation, also having attached a snapshot version to test the new JetPref version.

patrickgold avatar Jul 28 '25 11:07 patrickgold

Please see PR #22 for the draft new implementation, also having attached a snapshot version to test the new JetPref version.

How to use it?

Purehi avatar Jul 28 '25 11:07 Purehi

As stated in the PR, add maven("https://central.sonatype.com/repository/maven-snapshots/") as a maven repo (only needed for snapshots), then set the JetPref version to 20250728T110348Z-SNAPSHOT.

Then have a look at the draft v3 README for applying KSP to your project (may already be applied depending on which libraries you use) and the datastore-model-processor artifact, and lastly you will have compiler errors because the API had some breaking changes, adapt these and then it should work again

patrickgold avatar Jul 28 '25 11:07 patrickgold

Seems a bit cumbersome. Is it possible to release a beta version instead?

Purehi avatar Jul 28 '25 11:07 Purehi

We are currently testing the snapshot in FlorisBoard to check how the new implementation behaves in a big project, then I'd release a beta release for JetPref.

patrickgold avatar Jul 28 '25 11:07 patrickgold