pablobaxter / Harmony

Multi-process SharedPreference implementation without ContentProvider
Apache License 2.0
94 stars 8 forks source link

java.io.EOFException InternalCoreHarmony__HarmonyJsonUtilsKt.readHarmony #53

Open sklinefelter opened 10 months ago

sklinefelter commented 10 months ago

Hi @pablobaxter...it's me...again 🀣 πŸ˜† .

Have a nice stacktrace for you from _InternalCoreHarmony__HarmonyJsonUtilsKt.

Harmony: java.io.EOFException: End of input at android.util.JsonReader.nextNonWhitespace(JsonReader.java:835) at
  android.util.JsonReader.nextValue(JsonReader.java:697) at android.util.JsonReader.peek(JsonReader.java:336) at
  com.frybits.harmony.internal._InternalCoreHarmony__HarmonyJsonUtilsKt.readHarmony(HarmonyJsonUtils.kt:57) at
  com.frybits.harmony.internal._InternalCoreHarmony.readHarmony(Unknown Source:1) at
  com.frybits.harmony.HarmonyImpl.readHarmonyMapFromStream(Harmony.kt:291) at
  com.frybits.harmony.HarmonyImpl.initialLoad(Harmony.kt:337) at
  com.frybits.harmony.HarmonyImpl.isLoadedTask$lambda-4(Harmony.kt:173) at
  com.frybits.harmony.HarmonyImpl.$r8$lambda$JbZx2xhqu5H8w8MY6-eFqA-6GOI(Harmony.kt:0) at
  com.frybits.harmony.HarmonyImpl$$ExternalSyntheticLambda1.call(R8$$SyntheticClass:0) at
  java.util.concurrent.FutureTask.run(FutureTask.java:264) at android.os.Handler.handleCallback(Handler.java:938) at
  android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at
  android.os.Looper.loop(Looper.java:288) at android.os.HandlerThread.run(HandlerThread.java:67)

We're getting this EOFException with 1.1.11, but I also believe the latest as well...we upgraded and then reverted.

pablobaxter commented 10 months ago

This one might be because the process was killed before the write was allowed to flush. Regular SharedPreferences forces Activities, Broadcast Receivers, and Services to block the main thread on exit if the write queue hasn't completed. (Example)

Either that, or maybe I need to move away from using the internal Android Utils library and use something like GSON or other serialization library that isn't at the whim of Android OS versions of devices.

pablobaxter commented 10 months ago

Hey @sklinefelter I have a PR up in #54 that should fix this issue. At the very least, it will provide some better logging, as the kotlinx serialization library provides a better exception message. Feel free to review it (or have the team review it). I won't be merging or publishing these changes until I fix another issue I'm investigating.

pablobaxter commented 10 months ago

@sklinefelter I made a release of v1.2.5. Please update and see if the issue is resolved with this verison.

pablobaxter commented 9 months ago

@sklinefelter Any update on this?