Skip to content

Commit

Permalink
Force keep original size when isInDiskCache operation has unknown result
Browse files Browse the repository at this point in the history
Reviewed By: kartavya-ramnani

Differential Revision: D65858102

fbshipit-source-id: 692b5abf9b10cbced115ab26da7d0b509df88e4c
  • Loading branch information
Veeren Mandalia authored and facebook-github-bot committed Nov 13, 2024
1 parent 2d938d1 commit 3bb80b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,15 @@ class VitoImagePipelineImpl(
vitoImageRequest: VitoImageRequest,
timeout: Long,
unit: TimeUnit
): Boolean {
): Boolean? {
if (timeout <= 0) {
return isInDiskCacheSync(vitoImageRequest)
}
val imageRequest = vitoImageRequest.finalImageRequest ?: return false
val imageRequest = vitoImageRequest.finalImageRequest ?: return null
return try {
DataSources.waitForFinalResult(imagePipeline.isInDiskCache(imageRequest), timeout, unit)
?: false
} catch (t: Throwable) {
false
null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface VitoImagePipeline {
imageRequest: VitoImageRequest,
timeout: Long,
unit: TimeUnit,
): Boolean {
): Boolean? {
throw UnsupportedOperationException("Not implemented yet")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ object FrescoVitoImage2Spec {
// App is still starting
forceKeepOriginalSize.set(true)
} else {
forceKeepOriginalSize.set(
val isInDiskCache =
FrescoVitoProvider.getImagePipeline()
.isInDiskCacheSync(
requestCachedValue,
FrescoVitoProvider.getConfig().experimentalDynamicSizeDiskCacheCheckTimeoutMs(),
TimeUnit.MILLISECONDS))
TimeUnit.MILLISECONDS)
// Force keep original size if in disk cache OR unknown result (null)
forceKeepOriginalSize.set(isInDiskCache != false)
}
if (forceKeepOriginalSize.get() == true) {
// Prefetch in OnPrepare since no prefetch will happen in OnBoundsDefined
Expand Down

0 comments on commit 3bb80b8

Please sign in to comment.