Skip to content

Commit

Permalink
Attempt to workaround #126
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Feb 16, 2025
1 parent 22bed4e commit f5e0fb4
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
Expand Down Expand Up @@ -161,10 +162,12 @@ internal class RealSubSamplingImageState(
ImageCache(scope, imageRegionDecoder)
}

LaunchedEffect(imageCache, viewportTiles) {
imageCache.loadOrUnloadForTiles(
regions = viewportTiles.fastMapNotNull { if (it.isVisible) it.region else null }
)
LaunchedEffect(imageCache) {
snapshotFlow { viewportTiles }.collect { tiles ->
imageCache.loadOrUnloadForTiles(
regions = tiles.fastMapNotNull { if (it.isVisible) it.region else null }
)
}
}
LaunchedEffect(imageCache) {
imageCache.observeCachedImages().collect {
Expand Down

0 comments on commit f5e0fb4

Please sign in to comment.