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
- 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
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
- 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
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
- Unable to determine bitmap configuration
- Unsupported bitmap configuration
- Unable to create scaled bitmap
- Unable to obtained scaled bitmap's dimensions
- Could not find char array in
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)