Skip to content

SOURCE and RESULT cache read by same cacheDecoder #707

Open
@TWiStErRob

Description

@TWiStErRob

Glide Version/Integration library (if any): 3.6.1
Device/Android Version: above API 10, so almost any
Issue details/Repro steps/Use case background:
I was playing around to try my proposed solution for #700 (sample code in that issue) and found this issue. The idea there is to SOURCE cache the original image file and use BitmapRegionDecoder read parts of the image. The problem is that when I specify cacheDecoder it not only reads from SOURCE but from RESULT cache as well. When it tries to load the specified rect from a smaller image it throws a "rectangle is outside the image" correctly. There is no way to work around this because I can't tell which cache contains the File I received to decode.

Glide load line:

Glide
        .with(context)
        .load(url)
        .asBitmap()
        .override(viewWidth, viewHeight)
        .decoder(new RegionImageVideoDecoder(context, rect))
        .cacheDecoder(new RegionFileDecoder(context, rect))
        .diskCacheStrategy(DiskCacheStrategy.SOURCE)
        .into(holder.imageView)
;

Stack trace / LogCat:

java.lang.IllegalArgumentException: rectangle is outside the image
    at android.graphics.BitmapRegionDecoder.decodeRegion(BitmapRegionDecoder.java:371)
    at net.twisterrob.app.glide.github._700_large_image.RegionResourceDecoder.decode(RegionResourceDecoder.java:29)
    at com.bumptech.glide.load.engine.DecodeJob.loadFromCache(DecodeJob.java:222)
    at com.bumptech.glide.load.engine.DecodeJob.decodeResultFromCache(DecodeJob.java:85)
    at com.bumptech.glide.load.engine.EngineRunnable.decodeFromCache(EngineRunnable.java:108)
    at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:99)
    at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:841)
    at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)

See also https://docs.google.com/drawings/d/1KyOJkNd5Dlm8_awZpftzW7KtqgNR6GURvuF6RfB210g/edit?usp=sharing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions