Skip to content

Commit

Permalink
Remove CallerContext from cache keys to prevent caller context leaks.
Browse files Browse the repository at this point in the history
Reviewed By: oprisnik

Differential Revision: D67636632

fbshipit-source-id: e9eef8cd88f2fd2ebd25097cec1dfbdf3683c0a7
  • Loading branch information
Ilia Zaslavski authored and facebook-github-bot committed Jan 31, 2025
1 parent 21a3f60 commit d14c122
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ data class BitmapMemoryCacheKey(
val postprocessorName: String?,
) : CacheKey {

var callerContext: Any? = null

private val hash: Int = run {
var result = sourceString.hashCode()
result = 31 * result + (resizeOptions?.hashCode() ?: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public CacheKey getBitmapCacheKey(ImageRequest request, @Nullable Object callerC
request.getImageDecodeOptions(),
null,
null);
cacheKey.setCallerContext(callerContext);
return cacheKey;
}

Expand All @@ -65,7 +64,6 @@ public CacheKey getPostprocessedBitmapCacheKey(
request.getImageDecodeOptions(),
postprocessorCacheKey,
postprocessorName);
cacheKey.setCallerContext(callerContext);
return cacheKey;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,11 @@ abstract class BaseFrescoStethoPlugin() : DumperPlugin {
val entryValue = checkNotNull(entry.value)
writer.println(
formatStrLocaleSafe(
"size: %7.2fkB (%4d x %4d) key: %s, %s, duration: %dms",
"size: %7.2fkB (%4d x %4d) key: %s, duration: %dms",
entryValue.get().sizeInBytes / KB,
entryValue.get().width,
entryValue.get().height,
entry.key,
checkNotNull(cacheKey.callerContext),
RealtimeSinceBootClock.get().now() - cacheKey.inBitmapCacheSince))
}

Expand Down

0 comments on commit d14c122

Please sign in to comment.