GIF artifacts on < Android 4.3
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
GIF artifacts on < Android 4.3
**Glide Version**: 4.0.0-SNAPSHOT
On first load all looks okay, on second load the gif looks like this on a I9100@4.1.2:

Logfile using @TWiStErRob nice [logging wrapper](https://github.com/TWiStErRob/glide-support/blob/master/src/glide3/java/com/bumptech/glide/supportapp/utils/LoggingTarget.java) :)
``` java
// First load from coldstart
04-10 18:35:46.281 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: getRequest()
04-10 18:35:46.291 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: setRequest(com.bumptech.glide.request.SingleRequest@41ff2408)
04-10 18:35:46.346 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: getSize(com.bumptech.glide.request.SingleRequest@41ff2408)
04-10 18:35:46.346 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onSizeReady(com.bumptech.glide.request.SingleRequest@41ff2408, 300, 300)
04-10 18:35:46.441 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onLoadStarted(android.graphics.drawable.BitmapDrawable@41c36a60)
04-10 18:35:46.446 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onStart()
04-10 18:35:46.776 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onResourceReady(com.bumptech.glide.load.resource.gif.GifDrawable@41ae9488, com.bumptech.glide.request.transition.NoTransition@41fed0a8)
// Subsequent second load demonstrating the issue
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: getRequest()
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: getRequest()
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onLoadCleared(android.graphics.drawable.BitmapDrawable@41c36a60)
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: setRequest(null)
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: setRequest(com.bumptech.glide.request.SingleRequest@41ff2408)
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: getSize(com.bumptech.glide.request.SingleRequest@41ff2408)
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onSizeReady(com.bumptech.glide.request.SingleRequest@41ff2408, 300, 300)
04-10 18:36:12.626 16652-16652/eu.thedarken.sdm D/SDM:GlideGif: onResourceReady(com.bumptech.glide.load.resource.gif.GifDrawable@425f1368, com.bumptech.glide.request.transition.NoTransition@41fed0a8)
```
Code:
``` java
public void setState(@NonNull Fragment fragment, @NonNull State state) {
mState = state;
if (state == State.WORKING) {
setVisibility(VISIBLE);
mEasterEggCounter = 0;
mIntroContainer.setVisibility(GONE);
mEmptyContainer.setVisibility(GONE);
mWorkingContainer.setVisibility(VISIBLE);
//if (ApiHelper.hasJellyBeanMR2()) {
Glide.with(fragment)
.load(COFFEE_ANIM_ASSET)
.apply(new RequestOptions()
.format(DecodeFormat.PREFER_RGB_565)
.placeholder(R.drawable.sdmanimation)
.optionalFitCenter(mWorkingAnimation.getContext()))
.into(new LoggingTarget<>(TAG_GIFISSUE, Log.DEBUG, new DrawableImageViewTarget(mWorkingAnimation)));
//} else {
// mWorkingAnimation.setImageResource(R.drawable.graphic_mascot);
//}
} else {
// if (ApiHelper.hasJellyBeanMR2()) {
Drawable drawable = mWorkingAnimation.getDrawable();
if (drawable instanceof Animatable) {
Animatable gif = (Animatable) drawable;
if (gif.isRunning()) gif.stop();
}
// } else {
// mWorkingAnimation.setImageResource(R.drawable.graphic_mascot);
// }
mWorkingContainer.setVisibility(GONE);
if (state == State.INTRO) {
setVisibility(VISIBLE);
mEmptyContainer.setVisibility(GONE);
mIntroContainer.setVisibility(VISIBLE);
} else if (state == State.NORESULTS) {
setVisibility(VISIBLE);
mIntroContainer.setVisibility(GONE);
mEmptyContainer.setVisibility(VISIBLE);
} else if (state == State.GONE) {
setVisibility(GONE);
mIntroContainer.setVisibility(GONE);
mEmptyContainer.setVisibility(GONE);
}
}
}
```
``` xml
```
Contributor guide
Research direction
Start with the provided setState method and the Glide.with(fragment).load(COFFEE_ANIM_ASSET) call, then reproduce the second load on Android 4.1.2 using the supplied logging output and image. Compare the first and subsequent GIF loads; done means the animation renders without artifacts on the affected Android versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100