Tencent/matrix · error · RuntimeException

Unable to determine image dimensions.

Error message

Unable to determine image dimensions.

What it means

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.').

Solutions

  1. Upgrade matrix-resource-canary-analyzer to support the Android version of the hprof
  2. Re-capture the heap dump ensuring the bitmap is live and not recycled
  3. Verify width/height fields are not stripped by obfuscation in the analyzed app
Defensive patterns

Strategy: try-catch

Validate before calling

Dimension size = dataProvider.getDimension();
if (size == null) { skipDecoding(dataProvider); }

Type guard

boolean hasDimensions(BitmapDataProvider p) { return p.getDimension() != null; }

Try / catch

try { return BitmapDecoder.getBitmap(provider); } catch (RuntimeException e) { if (e.getMessage().contains("Unable to determine image dimensions")) { return null; } throw e; }

Prevention

When it happens

Trigger: The Bitmap object in the hprof lacks readable width/height fields (field layout mismatch, cleared bitmap, or analyzer version incompatible with the dumped OS).

Common situations: Heap dumps from newer Android versions where Bitmap stores dimensions in native side (mNativePtr-based layouts); recycled bitmaps; obfuscated builds.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/00463e93af1314ac. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer-cli/src/main/java/com/tencent/matrix/resource/analyzer/utils/BitmapDecoder.java:78

     * Maximum height or width of image beyond which we scale it on the device before retrieving.
     */
    private static final int MAX_DIMENSION = 1024;


    public static BufferedImage getBitmap(BitmapDataProvider dataProvider) {
        String config = dataProvider.getBitmapConfigName();
        if (config == null) {
            throw new RuntimeException("Unable to determine bitmap configuration");
        }

        BitmapExtractor bitmapExtractor = SUPPORTED_FORMATS.get(config);
        if (bitmapExtractor == null) {
            throw new RuntimeException("Unsupported bitmap configuration: " + config);
        }

        Dimension size = dataProvider.getDimension();
        if (size == null) {
            throw new RuntimeException("Unable to determine image dimensions.");
        }

        // if the image is rather large, then scale it down
        if (size.width > MAX_DIMENSION || size.height > MAX_DIMENSION) {
            boolean couldDownsize = dataProvider.downsizeBitmap(size);
            if (!couldDownsize) {
                throw new RuntimeException("Unable to create scaled bitmap");
            }

            size = dataProvider.getDimension();
            if (size == null) {
                throw new RuntimeException("Unable to obtained scaled bitmap's dimensions");
            }
        }

        return bitmapExtractor.getImage(size.width, size.height, dataProvider.getPixelBytes(size));
    }

View on GitHub (pinned to 3b8293bd65)