{"record":{"id":"b6b737fe64f0c384","repo":"koral--/android-gif-drawable","slug":"bitmap-ia-too-small-size-must-be-greater-than-or","errorCode":null,"errorMessage":"Bitmap ia too small, size must be greater than or equal to GIF size","messagePattern":"Bitmap ia too small, size must be greater than or equal to GIF size","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDecoder.java","lineNumber":165,"sourceCode":"\t * @return true if GIF is animated (has at least 2 frames and positive duration), false otherwise\n\t */\n\tpublic boolean isAnimated() {\n\t\treturn mGifInfoHandle.getNumberOfFrames() > 1 && getDuration() > 0;\n\t}\n\n\t/**\n\t * See {@link GifDrawable#recycle()}\n\t */\n\tpublic void recycle() {\n\t\tmGifInfoHandle.recycle();\n\t}\n\n\tprivate void checkBuffer(final Bitmap buffer) {\n\t\tif (buffer.isRecycled()) {\n\t\t\tthrow new IllegalArgumentException(\"Bitmap is recycled\");\n\t\t}\n\t\tif (buffer.getWidth() < mGifInfoHandle.getWidth() || buffer.getHeight() < mGifInfoHandle.getHeight()) {\n\t\t\tthrow new IllegalArgumentException(\"Bitmap ia too small, size must be greater than or equal to GIF size\");\n\t\t}\n\t\tif (buffer.getConfig() != Bitmap.Config.ARGB_8888) {\n\t\t\tthrow new IllegalArgumentException(\"Only Config.ARGB_8888 is supported. Current bitmap config: \" + buffer.getConfig());\n\t\t}\n\t}\n}\n","sourceCodeStart":147,"sourceCodeEnd":172,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDecoder.java#L147-L172","documentation":"checkBuffer requires the destination bitmap to be at least as large as the GIF's intrinsic width and height, because native rendering writes the full frame into it. A smaller bitmap would overflow/clip, so the library rejects it with IllegalArgumentException (message contains a typo 'ia too small').","triggerScenarios":"Calling seekToTime/seekToFrame on GifDecoder with a bitmap whose width or height is less than mGifInfoHandle.getWidth()/getHeight(), e.g. reusing a scaled-down thumbnail bitmap.","commonSituations":"Passing a downsampled bitmap to save memory without checking GIF dimensions; reusing a bitmap from a different (smaller) GIF after swapping sources; density-scaled bitmaps reported in different pixel units.","solutions":["Size the buffer from the decoder itself: Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), ARGB_8888) or use allocate() which does this","Before seeking, verify bitmap.getWidth() >= decoder.getWidth() && bitmap.getHeight() >= decoder.getHeight(), else recreate","Catch IllegalArgumentException and reallocate a correctly sized bitmap, then retry"],"exampleFix":"// before\nBitmap small = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);\ndecoder.seekToFrame(0, small);\n// after\nBitmap buffer = Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), Bitmap.Config.ARGB_8888);\ndecoder.seekToFrame(0, buffer);","handlingStrategy":"validation","validationCode":"if (buffer.getWidth() < decoder.getWidth() || buffer.getHeight() < decoder.getHeight()) { buffer = Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), Bitmap.Config.ARGB_8888); }","typeGuard":"Bitmap ensureBufferFits(Bitmap b, GifDecoder d) { return (b != null && b.getWidth() >= d.getWidth() && b.getHeight() >= d.getHeight()) ? b : Bitmap.createBitmap(d.getWidth(), d.getHeight(), Bitmap.Config.ARGB_8888); }","tryCatchPattern":"try { decoder.seekToTime(ms, buffer); } catch (IllegalArgumentException e) { buffer = Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), Bitmap.Config.ARGB_8888); decoder.seekToTime(ms, buffer); }","preventionTips":["Always allocate the buffer from decoder.getWidth()/getHeight()","Revalidate the buffer whenever the GIF source changes","Don't reuse downscaled thumbnails as seek buffers"],"tags":["android","gif","bitmap-size"],"backgroundTag":"invalid-argument-value","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}