{"record":{"id":"b796726c2e4c62c6","repo":"bumptech/glide","slug":"received-unexpected-drawable-type-for-animated-web","errorCode":null,"errorMessage":"Received unexpected drawable type for animated webp, failing: {decoded}","messagePattern":"Received unexpected drawable type for animated webp, failing: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/load/resource/drawable/AnimatedWebpDecoder.java","lineNumber":75,"sourceCode":"  }\n\n  @Synthetic\n  boolean handles(InputStream is) throws IOException {\n    return isHandled(ImageHeaderParserUtils.getType(imageHeaderParsers, is, arrayPool));\n  }\n\n  private boolean isHandled(ImageType imageType) {\n    return imageType == ImageType.ANIMATED_WEBP;\n  }\n\n  @Synthetic\n  Resource<Drawable> decode(@NonNull Source source, int width, int height, @NonNull Options options)\n      throws IOException {\n    Drawable decoded =\n        ImageDecoder.decodeDrawable(\n            source, new DefaultOnHeaderDecodedListener(width, height, options));\n    if (!(decoded instanceof AnimatedImageDrawable)) {\n      throw new IOException(\n          \"Received unexpected drawable type for animated webp, failing: \" + decoded);\n    }\n    return new AnimatedImageDrawableResource((AnimatedImageDrawable) decoded);\n  }\n\n  private static final class AnimatedImageDrawableResource implements Resource<Drawable> {\n    /** A totally made up number of the number of frames we think are held in memory at once... */\n    private static final int ESTIMATED_NUMBER_OF_FRAMES = 2;\n\n    private final AnimatedImageDrawable imageDrawable;\n\n    AnimatedImageDrawableResource(AnimatedImageDrawable imageDrawable) {\n      this.imageDrawable = imageDrawable;\n    }\n\n    @NonNull\n    @Override\n    public Class<Drawable> getResourceClass() {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/load/resource/drawable/AnimatedWebpDecoder.java#L57-L93","documentation":"IOException thrown by AnimatedWebpDecoder.decode() when ImageDecoder.decodeDrawable returns a non-AnimatedImageDrawable for a source classified as ANIMATED_WEBP. The decoder requires an AnimatedImageDrawable to expose frame looping; a still drawable is treated as a decode failure.","triggerScenarios":"An ANIMATED_WEBP source decoded on a device whose ImageDecoder returns a BitmapDrawable (still) instead of AnimatedImageDrawable. Common on older API levels or OEM-modified decoders.","commonSituations":"Loading animated WebP on devices with broken ImageDecoder support for WebP animation. File misidentified as animated by the sniffing logic. AVIF/other format masquerading as WebP.","solutions":["Fall back to .asBitmap() or the GIF-style pipeline on failure.","Use .error() to chain a bitmap-based fallback request.","Re-encode the WebP with a tool that guarantees animation frames.","Restrict animated WebP loads to API levels where ImageDecoder reliably returns AnimatedImageDrawable (typically API 31+)."],"exampleFix":"// before\nGlide.with(ctx).load(webpUri).into(img);\n// after\nGlide.with(ctx).load(webpUri)\n  .error(Glide.with(ctx).asBitmap().load(webpUri))\n  .into(img);","handlingStrategy":"fallback","validationCode":"// Use the simpler .load(resId) or .asBitmap() path for WebP you suspect is still.\n// Pre-classify with an ImageHeaderParser if available.","typeGuard":null,"tryCatchPattern":"// Chain a bitmap fallback.\nGlide.with(ctx).load(webpUri)\n  .error(Glide.with(ctx).asBitmap().load(webpUri))\n  .into(img);","preventionTips":["Always provide an .error() fallback for animated WebP loads.","Re-encode WebP with a reliable encoder if ImageDecoder misbehaves.","Pin animated-WebP support to API levels with reliable AnimatedImageDrawable."],"tags":["animated","webp","imagedecoder","android"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}