{"record":{"id":"4b37aafb5678528f","repo":"Tencent/matrix","slug":"unable-to-determine-bitmap-configuration","errorCode":null,"errorMessage":"Unable to determine bitmap configuration","messagePattern":"Unable to determine bitmap configuration","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer-cli/src/main/java/com/tencent/matrix/resource/analyzer/utils/BitmapDecoder.java","lineNumber":68,"sourceCode":"\n    protected static final Map<String, BitmapExtractor> SUPPORTED_FORMATS = new HashMap<>();\n\n    static {\n        SUPPORTED_FORMATS.put(\"\\\"ARGB_8888\\\"\", new ARGB8888_BitmapExtractor());\n        SUPPORTED_FORMATS.put(\"\\\"RGB_565\\\"\", new RGB565_BitmapExtractor());\n        SUPPORTED_FORMATS.put(\"\\\"ALPHA_8\\\"\", new ALPHA8_BitmapExtractor());\n    }\n\n    /**\n     * Maximum height or width of image beyond which we scale it on the device before retrieving.\n     */\n    private static final int MAX_DIMENSION = 1024;\n\n\n    public static BufferedImage getBitmap(BitmapDataProvider dataProvider) {\n        String config = dataProvider.getBitmapConfigName();\n        if (config == null) {\n            throw new RuntimeException(\"Unable to determine bitmap configuration\");\n        }\n\n        BitmapExtractor bitmapExtractor = SUPPORTED_FORMATS.get(config);\n        if (bitmapExtractor == null) {\n            throw new RuntimeException(\"Unsupported bitmap configuration: \" + config);\n        }\n\n        Dimension size = dataProvider.getDimension();\n        if (size == null) {\n            throw new RuntimeException(\"Unable to determine image dimensions.\");\n        }\n\n        // if the image is rather large, then scale it down\n        if (size.width > MAX_DIMENSION || size.height > MAX_DIMENSION) {\n            boolean couldDownsize = dataProvider.downsizeBitmap(size);\n            if (!couldDownsize) {\n                throw new RuntimeException(\"Unable to create scaled bitmap\");\n            }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer-cli/src/main/java/com/tencent/matrix/resource/analyzer/utils/BitmapDecoder.java#L50-L86","documentation":"BitmapDecoder.getBitmap reads the bitmap's config name from the heap dump via BitmapDataProvider.getBitmapConfigName(); if it returns null, the decoder cannot know the pixel format and cannot render the leaked bitmap, so it throws RuntimeException. Matrix throws this because bitmap decoding depends entirely on knowing the Bitmap.Config.","triggerScenarios":"The hprof contains a Bitmap whose mBitmap/mConfig field chain is missing or unresolvable, so getBitmapConfigName() returns null.","commonSituations":"Heap dumps from Android versions where the Bitmap field layout differs from what the analyzer expects; recycled or already-cleared bitmaps in the dump; obfuscated/renamed Bitmap fields.","solutions":["Upgrade matrix-resource-canary to match the Android SDK level of the hprof being analyzed","Re-capture the heap dump and confirm the bitmap is still valid (not recycled) at dump time","Check that no obfuscation stripped Bitmap config fields in the dumped app"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"String config = dataProvider.getBitmapConfigName();\nif (config == null) { skipDecoding(dataProvider); }","typeGuard":"boolean hasBitmapConfig(BitmapDataProvider p) { return p.getBitmapConfigName() != null; }","tryCatchPattern":"try { BufferedImage img = BitmapDecoder.getBitmap(provider); } catch (RuntimeException e) { if (e.getMessage().contains(\"Unable to determine bitmap configuration\")) { reportNoPreview(); } }","preventionTips":["Capture hprofs with an analyzer matching the target Android version","Avoid decoding recycled bitmaps","Prevent obfuscation of Bitmap fields in analyzed builds"],"tags":["heap-dump","bitmap-decoding","android"],"backgroundTag":"unsupported-operation","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}