Issue 1:
Glide Version: 4.6.1

Integration libraries: None

Device/Android Version: Robolectric environment

Issue summary: When attempting to load an https image which returns a 404 error, the request is performed twice.

Issue details / Repro steps / Use case background:

I have a test case which requests an image url, and the server returns a 404 not found. I use Wiremock for the server.

The glide code in the test:

String url = "https://127.0.0.1:31626/static/country/FR/image.jpg";
GlideApp.with(RuntimeEnvironment.application)
.asBitmap()
.load(url)
.into(new SimpleTarget<Bitmap>(100, 100) {
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
System.out.println("error");
}

@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
System.out.println("ready");
}
});

I noticed from Wiremock logs that the request for the image is actually being requested twice.

When debugging, I noticed:

A MultiModelLoader is being used. Its modelLoaders field has six loaders, two of which are a HttpUriLoader and a UrlUriLoader. In buildLoadData(), both of these match the handles(model) test, so their corresponding fetchers are added to the fetchers field. In this case both fetchers are of type HttpUrlFetcher.

I didn't follow the debugger further than this to understand more, but it looks like the first fetcher fails to load the image (the 404), and so the second one must be attempted (which will also fail with a 404). I'm not sure this is efficient. Is this expected?

Issue 2:
Glide Version:

4.0.0

Integration libraries:

Device/Android Version:

Emulator Pixel / API 25

Issue details / Repro steps / Use case background:

I have trouble loading resources to an image view using the load method.

I have test with several different resources.

I observed that this error only occurred when firstResId (the id of the drawable i use to call load) is the id of an xml drawable.

However this kind of drawable are handle fine by the placeholder method.

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

mGlideRequestManager = Glide.with(DealThreadsFragmentBase.this)
...
mGlideRequestManager
.load(firstResId) //id of a drawable
.apply(mRequestOptions
.placeholder(secondeResId) //id of a drawable
)
.into(viewHolder.threadImageView);

Layout XML:

<ImageView
android:id="@+id/post_deal_thread_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_marginLeft="@dimen/deal_thread_image_margin_left"
android:layout_marginStart="@dimen/deal_thread_image_margin_left"
android:scaleType="centerCrop"
tools:src="@drawable/placeholder_deal_96dp" />

Stack trace / LogCat:

I/Glide: Root cause (1 of 1)
java.io.FileNotFoundException: Resource does not exist:
android.resource://com.pepper.apps.android.beta4.debug/drawable/smiley_devil_height_24dp

at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:976)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:907)
at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:21)
at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:13)
at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:40)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:95)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:398)
at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:359)
at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:111)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:129)
at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:48)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:95)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:252)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:222)
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:347)