question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cancelled postprocessed images aren't cached

See original GitHub issue

Hi guys,

First of all, great library! Only problem I’ve had so far is with caching of post processed images - I’m following the documentation put up, and have looked around, but can’t seem to figure out what’s going wrong here.

I have a FragmentStatePagerAdapter, with each fragment having a full-sized, blurred image as its background, and I have a post-processor that blurs the background image, and all of that is working fine. But when I scroll between the fragments back and forth, the blurred background image is reprocessed every time, which is really annoying. There’s a section in the docs saying that post-processed images can be cached, and I’m doing everything it’s saying I should, but images are still not being caches.

My post-processor:

public class BlurPostprocessor extends BasePostprocessor {
        private Context context;
        private String url;

        public BlurPostprocessor(Context context, String url) {
            this.context = context;
            this.url = url;
        }

        @Override
        public String getName() {
            return "blurPostProcessor";
        }

        @Override
        public CacheKey getPostprocessorCacheKey() {
            return new SimpleCacheKey(url);
        }

        @Override
        public void process(Bitmap destBitmap, Bitmap sourceBitmap) {
                // code that blurs the image into destBitmap
        }
    }

I’ve also tried implementing my own CacheKey before finding out about SimpleCacheKey, but that didn’t work either. Any help would be appreciated!

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
foghinacommented, Jan 16, 2018

There’s no straightforward solution to this, but we’ve discussed internally and would like to provide some suggestions.

First, have a look at our sample ScalingBlurPostprocessor. This is much, much faster than the normal blur processor and produces almost indistinguishable results.

Second, in your custom post processor, you can evict the original image from memory cache. This will help keep more blurred images in the cache. Simply call imagePipeline.evictFromMemoryCache(uri) in your process() method.

Third, if you want to get fancy and cache the blurred image to disk cache, you can write a custom decoder (there are examples in the repo) that does the blurring implicitly. This will cause the original image to be thrown away and only the blurred one to be cached in both memory and disk caches.

I’ll close this now as it’s unlikely that we’ll make any changes within the library to address it.

CC @oprisnik

0reactions
atomd-zzcommented, Nov 10, 2015

I am also experiencing the same problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Images not being cached locally (using Universal Image Loader)
With my testing, the images are on disk, but loading is still slow. After extensive testing, I determined the primary issue is that...
Read more >
Unable to cancel stalled cache processing job - Esri Community
I am unable to cancel the stalled process. See the screenshot below, where I choose Cancel Job there is no effect - the...
Read more >
Cache intermediates in combination with cropping
This means no pixels are processed that would be discarded by the cropping. ... Now to my problem: Core Image can also cache...
Read more >
Enabling Docker Layer Caching - CircleCI
How to reuse unchanged cache layers in images you build to reduce overall run time. ... The DLC volumes are deleted after 3...
Read more >
Optimizing builds with cache management
Image layer diagram, but now with all links after COPY marked as invalid. And that's the Docker build cache in a nutshell. Once...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found