Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug: Unabled to find destroy activity info class with name: com.t… #506

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.tencent.matrix.resource.analyzer.utils.ShortestPathFinder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import static com.squareup.haha.perflib.HahaHelper.asString;
Expand Down Expand Up @@ -84,24 +85,31 @@ private ActivityLeakResult checkForLeak(HeapSnapshot heapSnapshot, String refKey
}

private Instance findLeakingReference(String key, Snapshot snapshot) {
final ClassObj infoClass = snapshot.findClass(DESTROYED_ACTIVITY_INFO_CLASSNAME);
if (infoClass == null) {
final Collection<ClassObj> infoClassList = snapshot.findClasses(DESTROYED_ACTIVITY_INFO_CLASSNAME);
if (infoClassList == null || infoClassList.isEmpty()) {
throw new IllegalStateException("Unabled to find destroy activity info class with name: "
+ DESTROYED_ACTIVITY_INFO_CLASSNAME);
}
List<String> keysFound = new ArrayList<>();
for (Instance infoInstance : infoClass.getInstancesList()) {
final List<ClassInstance.FieldValue> values = classInstanceValues(infoInstance);
final String keyCandidate = asString(fieldValue(values, ACTIVITY_REFERENCE_KEY_FIELDNAME));
if (keyCandidate.equals(key)) {
final Instance weakRefObj = fieldValue(values, ACTIVITY_REFERENCE_FIELDNAME);
if (weakRefObj == null) {
continue;
for(ClassObj infoClass : infoClassList) {
for (Instance infoInstance : infoClass.getInstancesList()) {
final List<ClassInstance.FieldValue> values = classInstanceValues(infoInstance);
final String keyCandidate = asString(fieldValue(values, ACTIVITY_REFERENCE_KEY_FIELDNAME));
if (keyCandidate.equals(key)) {
final Instance weakRefObj = fieldValue(values, ACTIVITY_REFERENCE_FIELDNAME);
if (weakRefObj == null) {
continue;
}
final List<ClassInstance.FieldValue> activityRefs = classInstanceValues(weakRefObj);
Instance instance = fieldValue(activityRefs, "referent");
if(null != instance) {
return instance;
} else {
break;
}
}
final List<ClassInstance.FieldValue> activityRefs = classInstanceValues(weakRefObj);
return fieldValue(activityRefs, "referent");
keysFound.add(keyCandidate);
}
keysFound.add(keyCandidate);
}
throw new IllegalStateException(
"Could not find weak reference with key " + key + " in " + keysFound);
Expand Down