Add option that caches video thumbnails to disk#2197
Add option that caches video thumbnails to disk#2197zjupure wants to merge 2 commits intofacebook:mainfrom
Conversation
|
Hi @zjupure Thank you for your contribution! :) |
|
Hi, creating a separate copy of LocalVideoThumbnailProducer is really a bit ugly and the duplicated code might be extracted to an base abstract class. I think need to create new class not modify the existing class are based on following considration.
So I think when user enable this feature and we should build a new producer sequence. But if user disable it using the exsting producer sequence would be a better choice. @erikandre How do you think for this case? |
facebook-github-bot
left a comment
There was a problem hiding this comment.
erikandre has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Motivation
As #2171 comments, Fresco loads a thumbnail from local video URI without disk cache. Every time restart app or bitmap in memory cache are evicted, then Fresco need decode thumbnail from video again and it will be slow and poor performance. So put the thumbnail bitmap into disk cache will be a good choice.
To optimize for this case, I create a
LocalVideoThumbnailProducer2class that will return anEncodedImage, and then it can be consumed byDiskCacheWriteProducerandEncodedMemoryCacheProducer. We can build a new producer sequence for this case, seeProducerSequenceFactory#getLocalVideoFileFetchSequence2().Of course, it is a feature that you can enable/disable it by
ImageRequestBuilder, but I think it should be enabled by default.Test Plan
put a video file test.mp4 in sdcard and got the READ_EXTERNAL_STORAGE permission, and use following code to test.