Issue 1:
Glide Version: 3.8.0-SNAPSHOT

Device/Android Version: Nexus 5, 5.0.1

I'm using a PaletteBitmapTranscoder to generate a palette, as demonstrated in the Custom targets section of the Glide wiki.

However, when using .thumbnail() in cases where the thumbnail request finishes after the full request, it ends up using the palette that was generated for the thumbnail instead of the full image.

Since Palette generates very different color swatches as an image is resized, this can affect the results.

In my test, the thumbnail palette always gets used the first time the image is loaded, but the full image's palette is used for all subsequent loads. (I think that if the full request is in the cache, the thumbnail does not get generated?)

Is there a way to prevent transcoding of the thumbnail when using a transcoder for the full image request?

I've tried changing the order of where .thumbnail() is called when building the request, but didn't have any luck with that approach. Most of those attempts wouldn't compile because of type incompatibility, e.g. not having a compatible TranscodeType with the full request.

I also tried using an explicit thumbnail request with its own settings but that didn't work; the full request's resource transcoder still gets called for the thumbnail. Giving the thumbnail its own PalletteBitmapNullTranscoder that doesn't generate a palette didn't work either; it just resulted in additional transcode() calls (and additional DecodeJobs in the log output). The additional transcode() calls did what I wanted (namely, not generating a palette) but it didn't replace the original thumbnail transcode() call that I was trying to override.

At this point I've disabled thumbnail generation when using a PaletteBitmapTranscoder, but I'm still new to Glide so I wonder if there might be something obvious that I might be missing.

For instance, is there any way to create a thumbnail request that uses a different TranscodeType, or a different ModelType for that matter?

Or is there some way within a ResourceTranscoder to know whether transcode() is being called for the full request or the thumbnail request?

Issue 2:
Glide Version: glide:4.3.1

Integration libraries: okhttp3-integration:4.3.1

Device/Android Version: Various, reported from field. Stacktrace comes from Samsung Galaxy S5 (klteatt) Android 6.0

Issue details / Repro steps / Use case background:

The exception text is misleading as the problem is not occuring in my AppGlideModule implementation.

This is difficult to reproduce as it appears to be a timing issue. I'm getting several reports of crashes and the location varies. Possibly related to Kotlin coroutines, but this did not occur on Glide pre 4.0. The stacktrace indicates this is not inside a Kotlin coroutine.

I've tried adding a "dummy" Glide request of Uri.Empty at the beginning of onCreate() to init Glide, but this hasn't helped.

// force glide initialization
try {
if (!glideInitialized.getAndSet(true)) {
debug { LOG.log(LogLevel.ERROR, "Initialize Glide") }
Glide.with(this).load(Uri.EMPTY).submit(10, 10)
}
} catch (e: Exception) {
debug { LOG.caught(LogLevel.ERROR, e) }
}

Can I force Glide init in some other manner? While I appreciate lazy loading resources I may never use, my app will use Glide and my loaders when my first activity starts and I'm looking for a workaround. The code snippet is related to the included stack trace, however the problem occurs at many different Glide.with() invocations randomly. After a Glide.with() executes without error, the issue does not reoccur.

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val image = imageList[position]
val uri = Uri.parse(image.text)
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.DATA)
if (LastFm.IMAGE_SIZE_MEGA == image.size) {
options.override(OVERRIDE_SIZE, OVERRIDE_SIZE)
.fitCenter()
}

Glide.with(activity)
.asBitmap()
.load(uri)
.apply(options)
.listener(object : RequestListener<Bitmap> {
override fun onResourceReady(p0: Bitmap?, p1: Any?, p2: Target<Bitmap>?, p3: DataSource?, p4: Boolean): Boolean {
holder.progressBar.visibility = View.GONE
return false
}

override fun onLoadFailed(p0: GlideException?, p1: Any?, p2: Target<Bitmap>?, p3: Boolean): Boolean {
holder.progressBar.visibility = View.GONE
return false
}
})
.into(holder.albumArtView)

Layout XML:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
>

<android.support.v7.widget.CardView
android:id="@+id/album_art_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/ap_secondaryBackground"
>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<fr.castorflex.android.circularprogressbar.CircularProgressBar
android:id="@+id/last_art_card_progress"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:indeterminate="true"
app:cpb_color="?attr/ap_secondaryBackground"
app:cpb_colors="@array/gplus_colors"
app:cpb_rotation_speed="1.0"
app:cpb_sweep_speed="1.0"
app:cpb_stroke_width="4dp"
app:cpb_min_sweep_angle="10"
app:cpb_max_sweep_angle="300"
/>

<ImageView
android:id="@+id/album_art_image"
android:layout_width="156dp"
android:layout_height="156dp"
android:layout_alignParentTop="true"
android:layout_marginBottom="6dp"
android:layout_centerHorizontal="true"
tools:ignore="ContentDescription"
/>

<TextView
android:id="@+id/album_art_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/album_art_image"
android:gravity="center_horizontal"
android:textSize="18sp"
/>

</RelativeLayout>

</android.support.v7.widget.CardView>

</LinearLayout>

Stack trace / LogCat:

java.lang.IllegalStateException:
at com.bumptech.glide.Glide.checkAndInitializeGlide (Glide.java:172)
at com.bumptech.glide.Glide.get (Glide.java:160)
at com.bumptech.glide.Glide.getRetriever (Glide.java:583)
at com.bumptech.glide.Glide.with (Glide.java:620)
at com.ealva.alvaplayer.ui.image.LastFmImageAdapter.onBindViewHolder (LastFmImageAdapter.java:83)
at com.ealva.alvaplayer.ui.image.LastFmImageAdapter.onBindViewHolder (LastFmImageAdapter.java:48)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:6508)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:6541)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline (RecyclerView.java:5484)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:5750)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5589)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5585)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2231)
at android.support.v7.widget.GridLayoutManager.layoutChunk (GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1518)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:610)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren (GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3719)
at android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3436)
at android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:3988)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1080)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.support.design.widget.CoordinatorLayout.layoutChild (CoordinatorLayout.java:1171)
at android.support.design.widget.CoordinatorLayout.onLayoutChild (CoordinatorLayout.java:856)
at android.support.design.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:875)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1172)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:344)
at android.widget.FrameLayout.onLayout (FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:3193)
at android.view.View.layout (View.java:17945)
at android.view.ViewGroup.layout (ViewGroup.java:5814)
at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2717)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2418)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1488)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7451)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:920)
at android.view.Choreographer.doCallbacks (Choreographer.java:695)
at android.view.Choreographer.doFrame (Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:906)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:158)
at android.app.ActivityThread.main (ActivityThread.java:7224)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)