okio.IOException: Operation not permitted.
Uncaught Kotlin exception: okio.IOException: Operation not permitted
at 0 Multiplatform App 0x1024c2983 kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} + 143
at 1 Multiplatform App 0x102bc391f kfun:okio.IOException#<init>(kotlin.String?;kotlin.Throwable?){} + 143
at 2 Multiplatform App 0x102bc39ab kfun:okio.IOException#<init>(kotlin.String?){} + 119
at 3 Multiplatform App 0x102ba7993 kfun:okio#errnoToIOException(kotlin.Int){}okio.IOException + 523
at 4 Multiplatform App 0x102bd3d5f kfun:okio#variantOpenReadWrite__at__okio.PosixFileSystem(okio.Path;kotlin.Boolean;kotlin.Boolean){}okio.FileHandle + 879
at 5 Multiplatform App 0x102bac01f kfun:okio.PosixFileSystem#openReadWrite(okio.Path;kotlin.Boolean;kotlin.Boolean){}okio.FileHandle + 163
at 6 Multiplatform App 0x102ca7f23 kfun:okio.FileSystem#openReadWrite(okio.Path;kotlin.Boolean;kotlin.Boolean){}okio.FileHandle-trampoline + 91
at 7 Multiplatform App 0x102c1a673 kfun:today.okio.problem.file_downloader.FileDownloader.$downloadFileNormallyCOROUTINE$1.invokeSuspend#internal + 1583
at 8 Multiplatform App 0x102c1adbb kfun:today.okio.problem.file_downloader.FileDownloader.downloadFileNormally#internal + 419
at 9 Multiplatform App 0x102c1bb67 kfun:today.okio.problem.file_downloader.FileDownloader.$downloadFile$lambda$2$lambda$0COROUTINE$2.invokeSuspend#internal + 3023
at 10 Multiplatform App 0x102c2df37 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 67
at 11 Multiplatform App 0x1024cd697
I am facing this issue only in iOS real device iOS 17.2. Simulator iOS 17.2 works fine. Here is the link to repository OkioReproduce.
This issue can be reproduced using 3.6.0 Okio version and also with latest 3.9.0 version. I hope you can solve this as soon as possible. I have tried my best to help you with reproducing. Here is line that causes this bug FILESYSTEM.openReadWrite(tempPath, mustCreate = false, mustExist = false).
@swankjesse I have created new issue for that bug
I am also facing this problem @swankjesse. Can you help us with this?
I'm seeing it as well. Simulator works fine, crashes with iPhone 12 on iOS 17.5.1. I'm getting it through Jetpack Datastore though.
`Uncaught Kotlin exception: at 0 News 0x104dec50b kfun:kotlin.Exception#
at 1 News 0x1063c02e7 kfun:okio.IOException#<init>(kotlin.String?;kotlin.Throwable?){} + 123
at 2 News 0x1063c035f kfun:okio.IOException#<init>(kotlin.String?){} + 99
at 3 News 0x1063a62c7 kfun:okio#errnoToIOException(kotlin.Int){}okio.IOException + 503
at 4 News 0x1063cf0e3 kfun:okio#variantOpenReadWrite__at__okio.PosixFileSystem(okio.Path;kotlin.Boolean;kotlin.Boolean){}okio.FileHandle + 859
at 5 News 0x1063a9e83 kfun:okio.PosixFileSystem#openReadWrite(okio.Path;kotlin.Boolean;kotlin.Boolean){}okio.FileHandle + 143
at 6 News 0x1063d190f kfun:okio.FileSystem#openReadWrite(okio.Path;kotlin.Boolean;kotlin.Boolean){}okio.FileHandle-trampoline + 91
at 7 News 0x1063a83bf kfun:okio.FileSystem#openReadWrite$default(okio.Path;kotlin.Boolean;kotlin.Boolean;kotlin.Int){}okio.FileHandle + 251
at 8 News 0x104db820f kfun:androidx.datastore.core.okio.OkioWriteScope.$writeDataCOROUTINE$3.invokeSuspend#internal + 863
at 9 News 0x104db8ba7 kfun:androidx.datastore.core.okio.OkioWriteScope#writeData#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 295
at 10 News 0x106ca4b87 kfun:androidx.datastore.core.WriteScope#writeData#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any-trampoline + 115
`
Same here with Compose Multiplatform and Datastore. Any updates?
I was able to fix by switching from NSDocumentDirectory -> NSCachesDirectory When creating the DataStore object on iOS.
actual fun getDataStore(name: String): DataStore<Preferences> {
return PreferenceDataStoreFactory
.createWithPath(
scope = CoroutineScope(Job() + Dispatchers.IO),
produceFile = {
val documentDirectory: NSURL? = NSFileManager.defaultManager.URLForDirectory(
directory = NSCachesDirectory,
inDomain = NSUserDomainMask,
appropriateForURL = null,
create = false,
error = null,
)
(requireNotNull(documentDirectory).path + name + ".preferences_pb").toPath()
}
)
}
Unclear what action to take here. Can you reproduce this exception consistently? Or perhaps only when the device is locked?
It was 100% reproducible at the time with NSDocumentDirectory since switching to NSCachesDirectory I haven't had any issues. I suppose the action here would be to fix using NSDocumentDirectory? Or perhaps documenting that it is not supported?
I had the same issue but was able to resolve by adding ?.relativePath:
val documentDirectory = NSFileManager.defaultManager.URLForDirectory(
directory = NSDocumentDirectory,
inDomain = NSUserDomainMask,
appropriateForURL = null,
create = false,
error = null
)?.relativePath
still experiencing the same issue
Fatal Exception: okio.IOException
0 app 0xaef564 kfun:okio#errnoToIOException(kotlin.Int){}okio.IOException + 76 (Cinterop.kt:76)
1 app 0xaf59e4 kfun:okio.PosixFileSystem#source(okio.Path){}okio.Source + 107 (UnixPosixVariant.kt:107)
2 app 0xb0bd34 kfun:androidx.datastore.core.okio.OkioReadScope.$readDataCOROUTINE$2.invokeSuspend#internal + 56 (FileSystem.kt:56)
3 app 0xb0c620 kfun:androidx.datastore.core.okio.OkioReadScope#readData#suspend(kotlin.coroutines.Continuation<1:0>){}kotlin.Any? + 193 (OkioStorage.kt:193)
4 app 0xae1dcc kfun:androidx.datastore.core.readData$2.$<bridge-NNNUN>invoke#suspend(androidx.datastore.core.ReadScope<1:0>;kotlin.Boolean;kotlin.coroutines.Continuation<1:0>){}kotlin.Any?#internal + 74 (StorageConnection.kt:74)
5 app 0xb0a530 kfun:androidx.datastore.core.okio.OkioStorageConnection.$readScopeCOROUTINE$0.invokeSuspend#internal + 1 ([K][Suspend]Functions:1)
6 app 0xb0a874 kfun:androidx.datastore.core.okio.OkioStorageConnection#readScope#suspend(kotlin.coroutines.SuspendFunction2<androidx.datastore.core.ReadScope<1:0>,kotlin.Boolean,0:0>;kotlin.coroutines.Continuation<0:0>){0§<kotlin.Any?>}kotlin.Any? + 120 (OkioStorage.kt:120)
7 app 0xae1c2c kfun:androidx.datastore.core#readData#suspend__at__androidx.datastore.core.StorageConnection<0:0>(kotlin.coroutines.Continuation<0:0>){0§<kotlin.Any?>}kotlin.Any? + 74 (StorageConnection.kt:74)
8 app 0xad5c8c kfun:androidx.datastore.core.DataStoreImpl.$readDataOrHandleCorruptionCOROUTINE$19.invokeSuspend#internal + 323 (DataStoreImpl.kt:323)
9 app 0xad6618 kfun:androidx.datastore.core.DataStoreImpl.readDataOrHandleCorruption#internal + 403 (DataStoreImpl.kt:403)
10 app 0xad7038 kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.DataStoreImpl$InitDataStore$doRun$initData$1.$invokeCOROUTINE$1.invokeSuspend#internal + 437 (DataStoreImpl.kt:437)
11 app 0xad7b58 kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.DataStoreImpl$InitDataStore$doRun$initData$1.invoke#internal + 470 (DataStoreImpl.kt:470)
12 app 0xae0a70 kfun:androidx.datastore.core.SingleProcessCoordinator.$lockCOROUTINE$0.invokeSuspend#internal + 1 ([K][Suspend]Functions:1)
13 app 0xae0eb0 kfun:androidx.datastore.core.SingleProcessCoordinator#lock#suspend(kotlin.coroutines.SuspendFunction0<0:0>;kotlin.coroutines.Continuation<0:0>){0§<kotlin.Any?>}kotlin.Any? + 43 (SingleProcessCoordinator.kt:43)
14 app 0xad6a40 kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.$doRunCOROUTINE$2.invokeSuspend#internal + 46 (InterProcessCoordinator.kt:46)
15 app 0xad6ce8 kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.doRun#internal + 473 (DataStoreImpl.kt:473)
16 app 0xadecc0 kfun:androidx.datastore.core.RunOnce.$runIfNeededCOROUTINE$20.invokeSuspend#internal + 489 (DataStoreImpl.kt:489)
17 app 0xad410c kfun:androidx.datastore.core.DataStoreImpl.$readAndInitOrPropagateAndThrowFailureCOROUTINE$16.invokeSuspend#internal + 493 (DataStoreImpl.kt:493)
18 app 0xad4548 kfun:androidx.datastore.core.DataStoreImpl.readAndInitOrPropagateAndThrowFailure#internal + 271 (DataStoreImpl.kt:271)
19 app 0xadb97c kfun:androidx.datastore.core.DataStoreImpl.DataStoreImpl$readState$2.$invokeCOROUTINE$6.invokeSuspend#internal + 218 (DataStoreImpl.kt:218)
20 app 0xadbc0c kfun:androidx.datastore.core.DataStoreImpl.DataStoreImpl$readState$2.invoke#internal + 228 (DataStoreImpl.kt:228)
21 app 0x185284 kfun:kotlinx.coroutines.intrinsics.startUndspatched#internal + 1 ([K][Suspend]Functions:1)
22 app 0x125dc4 kfun:kotlinx.coroutines#withContext#suspend(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>;kotlin.coroutines.Continuation<0:0>){0§<kotlin.Any?>}kotlin.Any? + 157 (Builders.common.kt:157)
23 app 0xad87d4 kfun:androidx.datastore.core.DataStoreImpl.DataStoreImpl$1.$invokeCOROUTINE$3.invokeSuspend#internal + 211 (DataStoreImpl.kt:211)
24 app 0xad9240 kfun:androidx.datastore.core.DataStoreImpl.DataStoreImpl$1.invoke#internal + 118 (DataStoreImpl.kt:118)
25 app 0x162c64 kfun:kotlinx.coroutines.flow.SafeFlow.collectSafely#internal + 58 (Builders.kt:58)
26 app 0x164214 kfun:kotlinx.coroutines.flow.AbstractFlow.$collectCOROUTINE$0.invokeSuspend#internal + 245 (Flow.kt:245)
27 app 0x164474 kfun:kotlinx.coroutines.flow.AbstractFlow#collect#suspend(kotlinx.coroutines.flow.FlowCollector<1:0>;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 230 (Flow.kt:230)
28 app 0x1544f40 kfun:app.data.local.getValue$$inlined$map$1.collect#internal + 108 (SafeCollector.common.kt:108)
29 app 0x112ed6c kfun:co.touchlab.skie.runtime.coroutines.flow.SkieColdFlowIterator.SkieColdFlowIterator$1.$invokeCOROUTINE$1.invokeSuspend#internal + 194 (Flow.kt:194)
30 app 0x1df64 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 50 (ContinuationImpl.kt:50)
31 app 0x17ed0c kfun:kotlinx.coroutines.DispatchedTask#run(){} + 26 (Continuation.kt:26)
32 app 0x19f0d0 kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.DarwinGlobalQueueDispatcher$dispatch$$inlined$autoreleasepool$1.$<bridge-DN>invoke(){}#internal + 23 (Dispatchers.kt:23)
33 app 0x1920744 ___6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f72652f6f70742f6275696c644167656e742f776f726b2f343465633665383530643563363366302f6b6f746c696e782d636f726f7574696e65732d636f72652f6e617469766544617277696e2f7372632f44697370617463686572732e6b74_knbridge2_block_invoke
34 libdispatch.dylib 0x1aac _dispatch_call_block_and_release
35 libdispatch.dylib 0x1b584 _dispatch_client_callout
36 libdispatch.dylib 0x372b0 _dispatch_queue_override_invoke.cold.3
37 libdispatch.dylib 0x61f8 _dispatch_queue_override_invoke
38 libdispatch.dylib 0x13db0 _dispatch_root_queue_drain
39 libdispatch.dylib 0x1454c _dispatch_worker_thread2
40 libsystem_pthread.dylib 0x9d0 _pthread_wqthread
41 libsystem_pthread.dylib 0xaac start_wqthread
@maqsats is this still reproducible? And is there are any updates?