xxfast / KStore

A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and kotlinx.io
https://xxfast.github.io/KStore/
Apache License 2.0
470 stars 15 forks source link

IOS and Android Crash #63

Closed srikrishnacj closed 8 months ago

srikrishnacj commented 1 year ago

Hi I am using v0.6.0 In Both android and ios the app crash when launching.

IOS Crash log

Uncaught Kotlin exception: okio.IOException: Read-only file system
    at 0   My application                      0x100ff8fbb        kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} + 147 
    at 1   My application                      0x10184aadb        kfun:okio.IOException#<init>(kotlin.String?;kotlin.Throwable?){} + 147 
    at 2   My application                      0x10184ab6b        kfun:okio.IOException#<init>(kotlin.String?){} + 123 
    at 3   My application                      0x1018456c3        kfun:okio#errnoToIOException(kotlin.Int){}okio.IOException + 523 
    at 4   My application                      0x10186e3b7        kfun:okio#variantSink__at__okio.PosixFileSystem(okio.Path;kotlin.Boolean){}okio.Sink + 715 
    at 5   My application                      0x101849fd7        kfun:okio.PosixFileSystem#sink(okio.Path;kotlin.Boolean){}okio.Sink + 199 
    at 6   My application                      0x1018480cb        kfun:okio.FileSystem#sink$default(okio.Path;kotlin.Boolean;kotlin.Int){}okio.Sink + 275 
    at 7   My application                      0x101873e7b        kfun:io.github.xxfast.kstore.file.FileCodec#encode#suspend(1:0?;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 723 
    at 8   My application                      0x101825cab        kfun:io.github.xxfast.kstore.KStore.$write$lambda$1COROUTINE$6.invokeSuspend#internal + 551 
    at 9   My application                      0x1018260af        kfun:io.github.xxfast.kstore.KStore.write$lambda$1#internal + 363 
    at 10  My application                      0x101826e73        kfun:io.github.xxfast.kstore.KStore.$write$lambda$1$FUNCTION_REFERENCE$1.invoke#internal + 163 
    at 11  My application                      0x101008d2b        kfun:kotlin.coroutines.intrinsics.object-3.invokeSuspend#internal + 799 
    at 12  My application                      0x1010059db        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 651 
    at 13  My application                      0x1011d0b8b        kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2715 
    at 14  My application                      0x1011d426b        kfun:kotlinx.coroutines.internal.LimitedDispatcher.Worker.run#internal + 307 
    at 15  My application                      0x101201deb        kfun:kotlinx.coroutines.MultiWorkerDispatcher.$workerRunLoop$lambda$2COROUTINE$0.invokeSuspend#internal + 2591 
    at 16  My application                      0x1010059db        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 651 
    at 17  My application                      0x1011d0b8b        kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2715 
    at 18  My application                      0x10115ff13        kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 1431 
    at 19  My application                      0x1011f8de7        kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal + 483 
    at 20  My application                      0x1011f85a3        kfun:kotlinx.coroutines#runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}0:0 + 1615 
    at 21  My application                      0x1011f87df        kfun:kotlinx.coroutines#runBlocking$default(kotlin.coroutines.CoroutineContext?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>;kotlin.Int){0§<kotlin.Any?>}0:0 + 271 
    at 22  My application                      0x1011ff7cf        kfun:kotlinx.coroutines.MultiWorkerDispatcher.workerRunLoop#internal + 203 
    at 23  My application                      0x10120102b        kfun:kotlinx.coroutines.MultiWorkerDispatcher.<init>$lambda$1$lambda$0#internal + 91 
    at 24  My application                      0x10120272b        kfun:kotlinx.coroutines.MultiWorkerDispatcher.$<init>$lambda$1$lambda$0$FUNCTION_REFERENCE$4.invoke#internal + 95 
    at 25  My application                      0x10120283f        kfun:kotlinx.coroutines.MultiWorkerDispatcher.$<init>$lambda$1$lambda$0$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 95 
    at 26  My application                      0x10101383b        WorkerLaunchpad + 195 
    at 27  My application                      0x101b03b27        _ZN6Worker19processQueueElementEb + 2603 
    at 28  My application                      0x101b02f9f        _ZN12_GLOBAL__N_113workerRoutineEPv + 219 
    at 29  libsystem_pthread.dylib             0x1b1838427        _pthread_start + 115 
    at 30  libsystem_pthread.dylib             0x1b1833647        thread_start + 7 
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.BroadcastFrameClock@7a830e70, StandaloneCoroutine{Cancelling}@7a92be00, FlushCoroutineDispatcher@7a840490]
        at 0   My application                      0x10100034b        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 123 
        at 1   My application                      0x100ff8f13        kfun:kotlin.Exception#<init>(kotlin.String?){} + 119 
        at 2   My application                      0x100ff923f        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 119 
        at 3   My application                      0x101203dff        kfun:kotlinx.coroutines.internal.DiagnosticCoroutineContextException#<init>(kotlin.coroutines.CoroutineContext){} + 203 
        at 4   My application                      0x1011cbb23        kfun:kotlinx.coroutines.internal#handleUncaughtCoroutineException(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} + 1135 
        at 5   My application                      0x10115af37        kfun:kotlinx.coroutines#handleCoroutineException(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} + 819 
        at 6   My application                      0x10114b353        kfun:kotlinx.coroutines.StandaloneCoroutine.handleJobException#internal + 187 
        at 7   My application                      0x101168057        kfun:kotlinx.coroutines.JobSupport.finalizeFinishingState#internal + 1235 
        at 8   My application                      0x10117228b        kfun:kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath#internal + 2239 
        at 9   My application                      0x101171993        kfun:kotlinx.coroutines.JobSupport.tryMakeCompleting#internal + 719 
        at 10  My application                      0x1011714d7        kfun:kotlinx.coroutines.JobSupport#makeCompletingOnce(kotlin.Any?){}kotlin.Any? + 411 
        at 11  My application                      0x10114a027        kfun:kotlinx.coroutines.AbstractCoroutine#resumeWith(kotlin.Result<1:0>){} + 243 
        at 12  My application                      0x101005c43        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 1267 
        at 13  My application                      0x1011d0a3b        kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2379 
        at 14  My application                      0x1016552b7        kfun:androidx.compose.ui.platform.FlushCoroutineDispatcher.dispatch$lambda$1$lambda$0#internal + 571 
        at 15  My application                      0x101656c57        kfun:androidx.compose.ui.platform.FlushCoroutineDispatcher.$dispatch$lambda$1$lambda$0$FUNCTION_REFERENCE$3.invoke#internal + 99 
        at 16  My application                      0x101656dab        kfun:androidx.compose.ui.platform.FlushCoroutineDispatcher.$dispatch$lambda$1$lambda$0$FUNCTION_REFERENCE$3.$<bridge-UNN>invoke(){}#internal + 95 
        at 17  My application                      0x101654b53        kfun:androidx.compose.ui.platform.FlushCoroutineDispatcher.performRun#internal + 399 
        at 18  My application                      0x1016554db        kfun:androidx.compose.ui.platform.FlushCoroutineDispatcher.dispatch$lambda$1#internal + 259 
        at 19  My application                      0x10165677b        kfun:androidx.compose.ui.platform.FlushCoroutineDispatcher.$dispatch$lambda$1$FUNCTION_REFERENCE$0.invoke#internal + 163 
        at 20  My application                      0x101008d2b        kfun:kotlin.coroutines.intrinsics.object-3.invokeSuspend#internal + 799 
        at 21  My application                      0x1010059db        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 651 
        at 22  My application                      0x1011d0b8b        kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2715 
        at 23  My application                      0x1013cbc9f        kfun:org.jetbrains.skiko.NsQueueDispatcher.dispatch$lambda$0#internal + 155 
        at 24  My application                      0x1013cc01f        kfun:org.jetbrains.skiko.NsQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 95 
        at 25  My application                      0x1013cc133        kfun:org.jetbrains.skiko.NsQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNN>invoke(){}#internal + 95 
        at 26  My application                      0x1013cd2c7        _6f72672e6a6574627261696e732e736b696b6f3a736b696b6f2f6f70742f6275696c644167656e742f776f726b2f613634643361613437376431326636622f736b696b6f2f7372632f64617277696e4d61696e2f6b6f746c696e2f6f72672f6a6574627261696e732f736b696b6f2f44697370617463686572732e6b74_knbridge6 + 279 
        at 27  libdispatch.dylib                   0x180132ee3        _dispatch_call_block_and_release + 23 
        at 28  libdispatch.dylib                   0x180134707        _dispatch_client_callout + 15 
        at 29  libdispatch.dylib                   0x180143fd7        _dispatch_main_queue_drain + 1219 
        at 30  libdispatch.dylib                   0x180143b03        _dispatch_main_queue_callback_4CF + 39 
        at 31  CoreFoundation                      0x18039a783        __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11 
        at 32  CoreFoundation                      0x180394de3        __CFRunLoopRun + 1911 
        at 33  CoreFoundation                      0x180394253        CFRunLoopRunSpecific + 583 
        at 34  GraphicsServices                    0x188eb7c9b        GSEventRunModal + 159 
        at 35  UIKitCore                           0x10553afef        -[UIApplication _run] + 867 
        at 36  UIKitCore                           0x10553ef3b        UIApplicationMain + 123 
        at 37  SwiftUI                             0x1095e734b        OUTLINED_FUNCTION_54 + 499 
        at 38  SwiftUI                             0x1095e71eb        OUTLINED_FUNCTION_54 + 147 
        at 39  SwiftUI                             0x108ddf473        OUTLINED_FUNCTION_16 + 87 
        at 40  My application                      0x100fe11d3        $s14My_application6iOSAppV5$mainyyFZ + 39 (/Users/a503959/mydrive/projects/personal/Photo Manager/PhotoManagerMulti/iosApp/iosApp/iOSApp.swift:<unknown>)
        at 41  My application                      0x100fe127f        main + 11 
        at 42  dyld                                0x104621513        0x0 + 4368504083 
        at 43  ???                                 0x10452df27        0x0 + 4367507239 
        at 44  ???                                 0x9479ffffffffffff 0x0 + -7747880208937517057 

Android Crash Log

4617-4617  AndroidRuntime          com.myapplication.MyApplication      E  FATAL EXCEPTION: main
                                                                            Process: com.myapplication.MyApplication, PID: 4617
                                                                            java.io.FileNotFoundException: testPreference.json: open failed: EROFS (Read-only file system)
                                                                                at libcore.io.IoBridge.open(IoBridge.java:574)
                                                                                at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
                                                                                at okio.Okio__JvmOkioKt.sink(JvmOkio.kt:174)
                                                                                at okio.Okio.sink(Unknown Source:1)
                                                                                at okio.Okio__JvmOkioKt.sink$default(JvmOkio.kt:174)
                                                                                at okio.Okio.sink$default(Unknown Source:1)
                                                                                at okio.JvmSystemFileSystem.sink(JvmSystemFileSystem.kt:101)
                                                                                at okio.FileSystem.sink(FileSystem.kt:75)
                                                                                at io.github.xxfast.kstore.file.FileCodec.encode(FileCodec.kt:45)
                                                                                at io.github.xxfast.kstore.KStore$write$2.invokeSuspend(KStore.kt:34)
                                                                                at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                                                                                at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
                                                                                at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:100)
                                                                                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: [androidx.compose.ui.platform.MotionDurationScaleImpl@5515b02, androidx.compose.runtime.BroadcastFrameClock@2ea8c13, StandaloneCoroutine{Cancelling}@e3d9e50, AndroidUiDispatcher@858f849]
                                                                            Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
                                                                                at libcore.io.Linux.open(Native Method)
                                                                                at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
                                                                                at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
                                                                                at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
                                                                                at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7779)
                                                                                at libcore.io.IoBridge.open(IoBridge.java:560)
                                                                                ... 17 more
xxfast commented 12 months ago

Hi! Can you share how you initialised the store?

xxfast commented 8 months ago

It looks like you are trying to write to a read-only directory.

Docs on how to get a path on Android, and iOS