vinceglb / FileKit

Pick and save Files, Medias and Folder for Kotlin Multiplatform / KMP and Compose Multiplatform / CMP
https://vinceglb.github.io/FileKit/
MIT License
249 stars 8 forks source link

ReadBytes() crashes on iOS sometimes #49

Open Vaibhav2002 opened 1 week ago

Vaibhav2002 commented 1 week ago

readBytes() method crashes on iOS

Stack Trace:

Fatal Exception: kotlin.IllegalStateException Failed to read data from file:///private/var/mobile/Containers/Data/Application/D917AB1D-00E7-4BDF-B7CD-2E12E6CDF147/tmp/.com.apple.Foundation.NSItemProvider.DJVXPj/IMG_0020.jpeg

Fatal Exception: kotlin.IllegalStateException
0  Medial                         0x2b6aa2c kfun:io.github.vinceglb.filekit.core.PlatformFile.readBytes$lambda$0#internal + 38 (PlatformFile.apple.kt:38)
1  Medial                         0x2b6b1e4 kfun:io.github.vinceglb.filekit.core.PlatformFile.$readBytes$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 35 (PlatformFile.apple.kt:35)
2  Medial                         0xdcdcb0 kfun:kotlin.Function2#invoke(1:0;1:1){}1:2-trampoline + 1 ([K][Suspend]Functions:1)
3  Medial                         0xc8f140 kfun:kotlin.coroutines.intrinsics.object-4.invokeSuspend#internal + 72 (IntrinsicsNative.kt:72)
4  Medial                         0xdcd5cc kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 50 (ContinuationImpl.kt:50)
5  Medial                         0xc8b8ac kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 30 (ContinuationImpl.kt:30)
6  Medial                         0xdcd6ac kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 26 (Continuation.kt:26)
7  Medial                         0xed5d34 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 45 (Continuation.kt:45)
8  Medial                         0xf049cc kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 10 (Runnable.kt:10)
9  Medial                         0xed8a08 kfun:kotlinx.coroutines.internal.LimitedDispatcher.Worker.run#internal + 113 (LimitedDispatcher.kt:113)
10 Medial                         0xf049cc kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 10 (Runnable.kt:10)
11 Medial                         0xefbce0 kfun:kotlinx.coroutines.MultiWorkerDispatcher.$workerRunLoop$lambda$2COROUTINE$0.invokeSuspend#internal + 113 (MultithreadedDispatchers.kt:113)
12 Medial                         0xdcd5cc kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 50 (ContinuationImpl.kt:50)
13 Medial                         0xc8b8ac kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 30 (ContinuationImpl.kt:30)
14 Medial                         0xdcd6ac kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 26 (Continuation.kt:26)
15 Medial                         0xed5d34 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 45 (Continuation.kt:45)
16 Medial                         0xf049cc kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 10 (Runnable.kt:10)
17 Medial                         0xe5bd58 kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 263 (EventLoop.common.kt:263)
18 Medial                         0xf04718 kfun:kotlinx.coroutines.EventLoop#processNextEvent(){}kotlin.Long-trampoline + 49 (EventLoop.common.kt:49)
19 Medial                         0xef4ff0 kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal + 129 (Builders.kt:129)
20 Medial                         0xef3e54 kfun:kotlinx.coroutines#runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}0:0 + 68 (Builders.kt:68)
21 Medial                         0xef4034 kfun:kotlinx.coroutines#runBlocking$default(kotlin.coroutines.CoroutineContext?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>;kotlin.Int){0§<kotlin.Any?>}0:0 + 45 (Builders.kt:45)
22 Medial                         0xef9db0 kfun:kotlinx.coroutines.MultiWorkerDispatcher.workerRunLoop#internal + 99 (MultithreadedDispatchers.kt:99)
23 Medial                         0xefb12c kfun:kotlinx.coroutines.MultiWorkerDispatcher.<init>$lambda$1$lambda$0#internal + 86 (MultithreadedDispatchers.kt:86)
24 Medial                         0xefc428 kfun:kotlinx.coroutines.MultiWorkerDispatcher.$<init>$lambda$1$lambda$0$FUNCTION_REFERENCE$5.invoke#internal + 86 (MultithreadedDispatchers.kt:86)
25 Medial                         0xefc4f8 kfun:kotlinx.coroutines.MultiWorkerDispatcher.$<init>$lambda$1$lambda$0$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 86 (MultithreadedDispatchers.kt:86)
26 Medial                         0xdc9f68 kfun:kotlin.Function0#invoke(){}1:0-trampoline + 1 ([K][Suspend]Functions:1)
27 Medial                         0xc98fcc WorkerLaunchpad + 106 (Internal.kt:106)
28 Medial                         0xe2b684 Worker::processQueueElement(bool)
29 Medial                         0xe2aac4 (anonymous namespace)::workerRoutine(void*)
30 libsystem_pthread.dylib        0x606c _pthread_start
31 libsystem_pthread.dylib        0x10d8 thread_start
vinceglb commented 1 week ago

Thank you for reporting this!

Did the crash happen when you tried to use the iOS simulator, with the image picker, and you choose a default image of flowers? In this case, it will crash due to an emulator bug: https://stackoverflow.com/a/74760585/7947225

Vaibhav2002 commented 1 week ago

@vinceglb I tried on my iPhone It does not crash every time on a specific image, it works sometimes and crashes sometimes This happens on multiple images