mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-30 09:06:27 +00:00
multiplatform: fix image loading performance and layout stability (#6631)
- Replace runBlocking { imageAndFilePath(file) } with LaunchedEffect +
withContext(Dispatchers.IO) to unblock main thread on all platforms
- Set fixed container size (width + aspectRatio) from preview bitmap to
eliminate layout shifts during async image loading
- Cache base64ToBitmap() with remember() in CIImageView and FramedItemView
- Desktop: replace imageBitmap.toAwtImage().toPainter() with BitmapPainter
to eliminate unnecessary round-trip conversion
- Desktop: add LRU cache for base64ToBitmap (200 entries) and
getLoadedImage (30 entries) to survive LazyColumn item disposal
- Clear loaded image cache on app file deletion via expect/actual
Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
+2
@@ -182,6 +182,8 @@ private fun spannableStringToAnnotatedString(
|
||||
actual fun getAppFileUri(fileName: String): URI =
|
||||
FileProvider.getUriForFile(androidAppContext, "$APPLICATION_ID.provider", if (File(fileName).isAbsolute) File(fileName) else File(getAppFilePath(fileName))).toURI()
|
||||
|
||||
actual fun clearImageCaches() {}
|
||||
|
||||
// https://developer.android.com/training/data-storage/shared/documents-files#bitmap
|
||||
actual suspend fun getLoadedImage(file: CIFile?): Pair<ImageBitmap, ByteArray>? {
|
||||
val filePath = getLoadedFilePath(file)
|
||||
|
||||
Reference in New Issue
Block a user