You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experiencing a crash on iOS when using the Calf library in my Compose KMP project. After selecting a file using the file picker, the following error is logged:
[default] [ERROR] Could not create a bookmark: NSError: Cocoa 4097 “connection to service named com.apple.FileProvider”
This error appears to be associated with camera-taken images—when the selected file is an image captured by the camera, the app crashes during image decoding (Image.makeFromEncoded). In contrast, screenshots and other images load without issue.
my full code:
Column {
val galleryPermissionState = rememberPermissionState(Permission.Gallery)
if (!galleryPermissionState.status.isGranted) {
Button(onClick = { galleryPermissionState.launchPermissionRequest() }) {
Text("Request Gallery Permission")
}
} else {
Text("Test Image Picker")
val scope = rememberCoroutineScope()
val context = LocalPlatformContext.current
var imageBitmap: ImageBitmap? by remember { mutableStateOf(null) }
var imageByteArray: ByteArray? by remember { mutableStateOf(null) }
var uploadLink: String by remember { mutableStateOf("") }
val pickerLauncher = rememberFilePickerLauncher(
type = FilePickerFileType.Image,
selectionMode = FilePickerSelectionMode.Single,
onResult = { files ->
scope.launch {
files.firstOrNull()?.let { file ->
val data = file.readByteArray(context)
imageByteArray = data
imageBitmap = data.toImageBitmap() // Crashes here for camera images
}
}
}
)
PrimaryButton(
modifier = Modifier.padding(8.dp),
title = "Pick Image",
containerColor = getColors().primary.c900,
isLoading = false,
onClick = { pickerLauncher.launch() }
)
imageBitmap?.let {
Image(
bitmap = it,
contentDescription = "Selected Image",
modifier = Modifier.size(200.dp),
contentScale = ContentScale.Crop
)
PrimaryButton(
modifier = Modifier.padding(8.dp),
title = "Upload",
containerColor = getColors().primary.c900,
isLoading = false,
onClick = {
scope.launch {
AppApi.instance.uploadFile("test1.jpeg", imageByteArray!!, "service-bucket")
.run {
data?.let {
uploadLink = it.url
println("Uploaded image url is: ${it.url}")
}
err?.let {
uploadLink = it.getErrorMessage()
println("upload error: ${it}")
}
}
}
}
)
if (uploadLink.isNotEmpty()) {
Text(uploadLink)
}
}
}
}
also i add this line to my info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to select images.</string>
<key>NSCameraUsageDescription</key>
<string>Camera permission is required to take pictures</string>
the code on Android and Desktop works fine, i tested it on real device iPhone 15 pro max with iOS 18.3, calf library version 0.7.0
The text was updated successfully, but these errors were encountered:
Summary
I'm experiencing a crash on iOS when using the Calf library in my Compose KMP project. After selecting a file using the file picker, the following error is logged:
[default] [ERROR] Could not create a bookmark: NSError: Cocoa 4097 “connection to service named com.apple.FileProvider”
This error appears to be associated with camera-taken images—when the selected file is an image captured by the camera, the app crashes during image decoding (
Image.makeFromEncoded
). In contrast, screenshots and other images load without issue.my full code:
also i add this line to my info.plist
the code on Android and Desktop works fine, i tested it on real device iPhone 15 pro max with iOS 18.3, calf library version 0.7.0
The text was updated successfully, but these errors were encountered: