{"record":{"id":"99f059685d78b2aa","repo":"Tencent/matrix","slug":"visit-bmp-instance-failed-lost-type-def-of-typeid","errorCode":null,"errorMessage":"visit bmp instance failed, lost type def of typeId: ","messagePattern":"visit bmp instance failed, lost type def of typeId: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/HprofBufferShrinker.java","lineNumber":268,"sourceCode":"            super(null);\n        }\n\n        @Override\n        public HprofHeapDumpVisitor visitHeapDumpRecord(int tag, int timestamp, long length) {\n            return new HprofHeapDumpVisitor(null) {\n\n                @Override\n                public void visitHeapDumpInstance(ID id, int stackId, ID typeId, byte[] instanceData) {\n                    try {\n                        if (mBmpClassId != null && mBmpClassId.equals(typeId)) {\n                            ID bufferId = null;\n                            Boolean isRecycled = null;\n                            final ByteArrayInputStream bais = new ByteArrayInputStream(instanceData);\n                            for (Field field : mBmpClassInstanceFields) {\n                                final ID fieldNameStringId = field.nameId;\n                                final Type fieldType = Type.getType(field.typeId);\n                                if (fieldType == null) {\n                                    throw new IllegalStateException(\"visit bmp instance failed, lost type def of typeId: \" + field.typeId);\n                                }\n                                if (mMBufferFieldNameStringId.equals(fieldNameStringId)) {\n                                    bufferId = (ID) IOUtil.readValue(bais, fieldType, mIdSize);\n                                } else if (mMRecycledFieldNameStringId.equals(fieldNameStringId)) {\n                                    isRecycled = (Boolean) IOUtil.readValue(bais, fieldType, mIdSize);\n                                } else if (bufferId == null || isRecycled == null) {\n                                    IOUtil.skipValue(bais, fieldType, mIdSize);\n                                } else {\n                                    break;\n                                }\n                            }\n                            bais.close();\n                            final boolean reguardAsNotRecycledBmp = (isRecycled == null || !isRecycled);\n                            if (bufferId != null && reguardAsNotRecycledBmp && !bufferId.equals(mNullBufferId)) {\n                                mBmpBufferIds.add(bufferId);\n                            }\n                        } else if (mStringClassId != null && mStringClassId.equals(typeId)) {\n                            ID strValueId = null;","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/HprofBufferShrinker.java#L250-L286","documentation":"While visiting a Bitmap class instance in the parsed hprof heap dump, HprofBufferShrinker resolves each field's type via Type.getType(field.typeId). If the hprof does not contain a type definition for that typeId, Type.getType returns null and the library throws IllegalStateException, because it cannot correctly read the field values (mBuffer / mRecycled) needed to determine whether the bitmap was recycled.","triggerScenarios":"Parsing an hprof where mBmpClassInstanceFields contains a Field whose typeId has no corresponding Type definition — typically a malformed, truncated, or version-mismatched heap dump.","commonSituations":"Hprof produced by a newer/older ART or JVM version than the parser expects; truncated hprof transfered off-device; custom bitmap class fields with unusual type ids.","solutions":["Re-capture the hprof from the device to replace a possibly truncated/corrupted dump.","Ensure the hprof file is transferred in binary mode / fully copied before parsing.","Update Matrix to a version whose HprofConstants/Type table matches the runtime that produced the dump.","Wrap parsing in try-catch and fall back to skipping malformed instances."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (hprofFile.length() == 0) {\n    throw new IOException(\"empty hprof: \" + hprofFile);\n}","typeGuard":null,"tryCatchPattern":"try {\n    shrinker.shrink(hprof, out);\n} catch (IllegalStateException e) {\n    Log.e(TAG, \"hprof parse failed, falling back to raw upload\", e);\n}","preventionTips":["Transfer hprof files in binary mode and verify size/checksum after pull.","Keep Matrix updated to match the ART versions of target devices.","Re-capture dumps rather than retrying a known-corrupted file."],"tags":["android","hprof","memory-analysis","type-mismatch"],"backgroundTag":"type-mismatch","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"}