{"record":{"id":"00463e93af1314ac","repo":"Tencent/matrix","slug":"unable-to-determine-image-dimensions","errorCode":null,"errorMessage":"Unable to determine image dimensions.","messagePattern":"Unable to determine image dimensions\\.","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":78,"sourceCode":"     * 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            }\n\n            size = dataProvider.getDimension();\n            if (size == null) {\n                throw new RuntimeException(\"Unable to obtained scaled bitmap's dimensions\");\n            }\n        }\n\n        return bitmapExtractor.getImage(size.width, size.height, dataProvider.getPixelBytes(size));\n    }\n","sourceCodeStart":60,"sourceCodeEnd":96,"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#L60-L96","documentation":"BitmapDecoder.getBitmap calls dataProvider.getDimension(); if the width/height cannot be resolved from the heap dump it returns null and decoding cannot proceed, so Matrix throws RuntimeException('Unable to determine image dimensions.').","triggerScenarios":"The Bitmap object in the hprof lacks readable width/height fields (field layout mismatch, cleared bitmap, or analyzer version incompatible with the dumped OS).","commonSituations":"Heap dumps from newer Android versions where Bitmap stores dimensions in native side (mNativePtr-based layouts); recycled bitmaps; obfuscated builds.","solutions":["Upgrade matrix-resource-canary-analyzer to support the Android version of the hprof","Re-capture the heap dump ensuring the bitmap is live and not recycled","Verify width/height fields are not stripped by obfuscation in the analyzed app"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"Dimension size = dataProvider.getDimension();\nif (size == null) { skipDecoding(dataProvider); }","typeGuard":"boolean hasDimensions(BitmapDataProvider p) { return p.getDimension() != null; }","tryCatchPattern":"try { return BitmapDecoder.getBitmap(provider); } catch (RuntimeException e) { if (e.getMessage().contains(\"Unable to determine image dimensions\")) { return null; } throw e; }","preventionTips":["Ensure bitmaps are live (not recycled) when the hprof is captured","Match analyzer version to the OS version of the dump","Avoid obfuscation stripping Bitmap width/height fields"],"tags":["heap-dump","bitmap-decoding","android"],"backgroundTag":"unexpected-api-response-shape","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"}