Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random fail when loading asset images #2708

Closed
perracodex opened this issue Dec 11, 2017 · 3 comments
Closed

Random fail when loading asset images #2708

perracodex opened this issue Dec 11, 2017 · 3 comments
Labels

Comments

@perracodex
Copy link

Glide Version: 4.4

Device/Android Version: Nexus 5X / 7.1.2

Issue details / Repro steps / Use case background:

I've found that with version 4.4 sometimes images don’t load. I must point out that this happens rarely, but as it happens I think was better to report it. The loading process is in a very simple RecyclerView with no complex code, which at the present time only displays a very small number of items, not even enough to scroll.

Glide load line / GlideModule (if any) / list Adapter code (if any):

public class AdapterThumbnails extends RecyclerView.Adapter<ThumbnailViewHolder>
{
    private static final String ASSETS_PATH = "file:///android_asset/thumbnails/";

    private final String[] mTestList = new String[]{"0.jpg", "1.jpg", "2.jpg"};

    private final Context mContext;
    private final int mMaxSize;

    public AdapterThumbnails(final Context context, final int maxSize)
    {
        this.mContext = context;
        this.mMaxSize = maxSize;
    }

    @Override
    public long getItemId(final int position)
    {
        return position;
    }

    @Override
    public int getItemCount()
    {
        return this.mTestList.length;
    }

    @Override
    public ThumbnailViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType)
    {
        final ImageView newView = new ImageView(this.mContext);
        newView.setLayoutParams(new ViewGroup.LayoutParams(this.mMaxSize, this.mMaxSize));
        return new ThumbnailViewHolder(newView);
    }

    @Override
    public void onBindViewHolder(final ThumbnailViewHolder holder, final int position)
    {
        final ImageView thumbnail = (ImageView)holder.itemView;

        final Uri uri = Uri.parse(AdapterThumbnails.ASSETS_PATH + this.mTestList[position]);

        GlideApp.with(this.mContext)
                .asBitmap()
                .load(uri)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .override(this.mMaxSize, this.mMaxSize)
                .into(thumbnail);
    }

    @Override
    public void onViewRecycled(final ThumbnailViewHolder holder)
    {
        GlideApp.with(this.mContext).clear(holder.itemView);
    }
}

Stack trace / LogCat:

E/GlideExecutor: Request threw uncaught throwable
   java.lang.NullPointerException: Attempt to invoke virtual method 'com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.engine.LoadPath.load(com.bumptech.glide.load.data.DataRewinder, com.bumptech.glide.load.Options, int, int, com.bumptech.glide.load.engine.DecodePath$DecodeCallback)' on a null object reference
	   at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:499)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:471)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:457)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:411)
	   at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:380)
	   at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:111)
	   at com.bumptech.glide.load.data.AssetPathFetcher.loadData(AssetPathFetcher.java:40)
	   at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
	   at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:303)
	   at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:270)
	   at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
	   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	   at java.lang.Thread.run(Thread.java:761)
	   at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:445)
12-11 12:10:59.049 30395-30395/com.perracolabs.test W/Glide: Load failed for file:///android_asset/thumbnails/0.jpg with size [189x189]
   class com.bumptech.glide.load.engine.GlideException: Failed to load resource
	 Cause (1 of 1): class java.lang.NullPointerException: Attempt to invoke virtual method 'com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.engine.LoadPath.load(com.bumptech.glide.load.data.DataRewinder, com.bumptech.glide.load.Options, int, int, com.bumptech.glide.load.engine.DecodePath$DecodeCallback)' on a null object reference
12-11 12:10:59.050 30395-30395/com.perracolabs.test I/Glide: Root cause (1 of 1)
   java.lang.NullPointerException: Attempt to invoke virtual method 'com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.engine.LoadPath.load(com.bumptech.glide.load.data.DataRewinder, com.bumptech.glide.load.Options, int, int, com.bumptech.glide.load.engine.DecodePath$DecodeCallback)' on a null object reference
	   at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:499)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:471)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:457)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:411)
	   at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:380)
	   at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:111)
	   at com.bumptech.glide.load.data.AssetPathFetcher.loadData(AssetPathFetcher.java:40)
	   at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
	   at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:303)
	   at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:270)
	   at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
	   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	   at java.lang.Thread.run(Thread.java:761)
	   at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:445)
12-11 12:10:59.051 30395-30395/com.perracolabs.test W/Glide: Load failed for file:///android_asset/thumbnails/0.jpg with size [189x189]
   class com.bumptech.glide.load.engine.GlideException: Failed to load resource
	 Cause (1 of 1): class java.lang.NullPointerException: Attempt to invoke virtual method 'com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.engine.LoadPath.load(com.bumptech.glide.load.data.DataRewinder, com.bumptech.glide.load.Options, int, int, com.bumptech.glide.load.engine.DecodePath$DecodeCallback)' on a null object reference
12-11 12:10:59.051 30395-30395/com.perracolabs.test I/Glide: Root cause (1 of 1)
   java.lang.NullPointerException: Attempt to invoke virtual method 'com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.engine.LoadPath.load(com.bumptech.glide.load.data.DataRewinder, com.bumptech.glide.load.Options, int, int, com.bumptech.glide.load.engine.DecodePath$DecodeCallback)' on a null object reference
	   at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:499)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:471)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:457)
	   at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:411)
	   at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:380)
	   at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:111)
	   at com.bumptech.glide.load.data.AssetPathFetcher.loadData(AssetPathFetcher.java:40)
	   at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
	   at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:303)
	   at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:270)
	   at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
	   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	   at java.lang.Thread.run(Thread.java:761)
	   at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:445)
@sjudd sjudd added the bug label Dec 11, 2017
@sjudd
Copy link
Collaborator

sjudd commented Dec 11, 2017

Thanks for letting me know. Do you use Glide elsewhere in your application, or only here?

@perracodex
Copy link
Author

For this project this is the only place where we use it, as this specific project is still at a very early stage.
In case it is of any use, next is the code of the Glide Module we are using:

@GlideModule
public final class GlideManager extends AppGlideModule
{
	@Override
	public boolean isManifestParsingEnabled()
	{
		return false;
	}

	@Override
	public void applyOptions(final Context context, final GlideBuilder builder)
	{
		final int sizeMemory = 40 * 1024 * 1024; // 40 MB
		builder.setMemoryCache(new LruResourceCache(sizeMemory));

		final int sizeDisk = 75 * 1024 * 1024; // 75 MB
		builder.setDiskCache(new InternalCacheDiskCacheFactory(context, sizeDisk));
	}
}

@sjudd
Copy link
Collaborator

sjudd commented Dec 12, 2017

Thanks for the detailed information, super helpful. I believe this is fixed in d427cbd. You can try out the latest snapshot when it finishes building by following the instructions here: http://bumptech.github.io/glide/dev/snapshots.html

@sjudd sjudd closed this as completed Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@sjudd @perracodex and others