Skip to content

Commit

Permalink
Merge pull request #2600 from square/py/new_library_leak_dump
Browse files Browse the repository at this point in the history
Add new library leaks
  • Loading branch information
pyricau authored Jan 2, 2024
2 parents 2063657 + 2eba183 commit c772a41
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 20 deletions.
5 changes: 4 additions & 1 deletion shark/shark-android/api/shark-android.api
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field ACCESSIBILITY_ITERATORS Lshark/AndroidReferenceMatchers;
public static final field ACCESSIBILITY_NODE_ID_MANAGER Lshark/AndroidReferenceMatchers;
public static final field ACCESSIBILITY_NODE_INFO__MORIGINALTEXT Lshark/AndroidReferenceMatchers;
public static final field ACCOUNT_MANAGER Lshark/AndroidReferenceMatchers;
public static final field ACCOUNT_MANAGER__AMS_TASK__RESPONSE Lshark/AndroidReferenceMatchers;
public static final field ACTIVITY_CHOOSE_MODEL Lshark/AndroidReferenceMatchers;
public static final field ACTIVITY_MANAGER_MCONTEXT Lshark/AndroidReferenceMatchers;
public static final field ACTIVITY_THREAD__M_NEW_ACTIVITIES Lshark/AndroidReferenceMatchers;
Expand All @@ -79,6 +79,7 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field ASSIST_STRUCTURE Lshark/AndroidReferenceMatchers;
public static final field AUDIO_MANAGER Lshark/AndroidReferenceMatchers;
public static final field AUDIO_MANAGER__MCONTEXT_STATIC Lshark/AndroidReferenceMatchers;
public static final field AW_CONTENTS_POSTED_CALLBACK Lshark/AndroidReferenceMatchers;
public static final field AW_CONTENTS__A0 Lshark/AndroidReferenceMatchers;
public static final field AW_RESOURCE__SRESOURCES Lshark/AndroidReferenceMatchers;
public static final field BACKDROP_FRAME_RENDERER__MDECORVIEW Lshark/AndroidReferenceMatchers;
Expand Down Expand Up @@ -135,6 +136,7 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field PLAYER_BASE Lshark/AndroidReferenceMatchers;
public static final field RAZER Ljava/lang/String;
public static final field RAZER_TEXT_KEY_LISTENER__MCONTEXT Lshark/AndroidReferenceMatchers;
public static final field REALME Ljava/lang/String;
public static final field REFERENCES Lshark/AndroidReferenceMatchers;
public static final field RENDER_NODE_ANIMATOR Lshark/AndroidReferenceMatchers;
public static final field RESOURCES__MCONTEXT Lshark/AndroidReferenceMatchers;
Expand Down Expand Up @@ -162,6 +164,7 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field VIEW_CONFIGURATION__MCONTEXT Lshark/AndroidReferenceMatchers;
public static final field VIEW_GROUP__M_CURRENT_DRAG_CHILD Lshark/AndroidReferenceMatchers;
public static final field VIEW_GROUP__M_PRE_SORTED_CHILDREN Lshark/AndroidReferenceMatchers;
public static final field VIEW_TOOLTIP_CALLBACK Lshark/AndroidReferenceMatchers;
public static final field VIVO Ljava/lang/String;
public static final field WINDOW_ON_BACK_INVOKED_DISPATCHER__STUB Lshark/AndroidReferenceMatchers;
public static final field XIAMI__RESOURCES_IMPL Lshark/AndroidReferenceMatchers;
Expand Down
100 changes: 81 additions & 19 deletions shark/shark-android/src/main/java/shark/AndroidReferenceMatchers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ enum class AndroidReferenceMatchers {
InputMethodManager.mImeInsetsConsumer isn't set to null when the activity is destroyed.
""".trimIndent()
) {
sdkInt >= 31
sdkInt >= 30
}
}
},
Expand Down Expand Up @@ -368,24 +368,20 @@ enum class AndroidReferenceMatchers {
}
},

ACCOUNT_MANAGER {
ACCOUNT_MANAGER__AMS_TASK__RESPONSE {
override fun add(
references: MutableList<ReferenceMatcher>
) {
references += instanceFieldLeak(
"android.accounts.AccountManager\$AmsTask\$Response", "this$1",
description =
"AccountManager\$AmsTask\$Response is a stub and is held in memory by native code,"
+ " probably because the reference to the response in the other process hasn't been"
+ " cleared."
+ " AccountManager\$AmsTask is holding on to the activity reference to use for"
+ " launching a new sub- Activity."
+ " Tracked here: https://code.google.com/p/android/issues/detail?id=173689"
+ " Fix: Pass a null activity reference to the AccountManager methods and then deal"
+ " with the returned future to to get the result and correctly start an activity"
+ " when it's available."
references += nativeGlobalVariableLeak(
"android.accounts.AccountManager\$AmsTask\$Response",
description = """
AccountManager.AmsTask.Response is a stub, and as all stubs it's held in memory by a
native ref until the calling side gets GCed, which can happen long after the stub is no
longer of use.
https://issuetracker.google.com/issues/318303120
""".trimIndent()
) {
sdkInt <= 27
sdkInt >= 5
}
}
},
Expand Down Expand Up @@ -867,6 +863,30 @@ enum class AndroidReferenceMatchers {
}
},

VIEW_TOOLTIP_CALLBACK {
override fun add(
references: MutableList<ReferenceMatcher>
) {
// Note: the lambda order changes every release, so ideally we'd pull the dex code for
// every release and look at the exact class name for the this::showHoverTooltip and the
// this::hideTooltip lambda references in View.java . That's too much work, so we'll just
// rely on reports from the field:
// - API 33: android.view.View$$ExternalSyntheticLambda3.f$0
references += instanceFieldLeak(
"android.view.View\$\$ExternalSyntheticLambda3", "f\$0",
description = """
When a View has tooltip text set, every hover event will fire a callback
to hide the tooltip after a 15 second timeout. Since the callback holds
a reference to the View, it will leak the View for that duration after
the Activity is finished or the View is removed.
https://cs.android.com/android/_/android/platform/frameworks/base/+/708dbe80902b963388c412f670c56ae00953273a
""".trimIndent()
) {
sdkInt in 26..34
}
}
},

ACTIVITY_TRANSITION_STATE__M_EXITING_TO_VIEW {
override fun add(
references: MutableList<ReferenceMatcher>
Expand Down Expand Up @@ -905,7 +925,8 @@ enum class AndroidReferenceMatchers {
references: MutableList<ReferenceMatcher>
) {
references += staticFieldLeak(
"com.facebook.flipper.plugins.inspector.descriptors.ApplicationDescriptor", "editedDelegates",
"com.facebook.flipper.plugins.inspector.descriptors.ApplicationDescriptor",
"editedDelegates",
description = """
Flipper's ApplicationDescriptor leaks root views after they've been detached.
https://github.com/facebook/flipper/issues/4270
Expand All @@ -928,6 +949,38 @@ enum class AndroidReferenceMatchers {
}
},

AW_CONTENTS_POSTED_CALLBACK {
override fun add(references: MutableList<ReferenceMatcher>) {
val description = "Android System WebView leak: " +
"https://bugs.chromium.org/p/chromium/issues/detail?id=1499154"
instanceFieldLeak(
"WV.R9",
"e",
description
)
instanceFieldLeak(
"WV.a6",
"c",
description
)
instanceFieldLeak(
"WV.H5",
"c",
description
)
instanceFieldLeak(
"WV.Y9",
"e",
description
)
instanceFieldLeak(
"WV.U4",
"c",
description
)
}
},

JOB_SERVICE {
override fun add(
references: MutableList<ReferenceMatcher>
Expand Down Expand Up @@ -1445,11 +1498,19 @@ enum class AndroidReferenceMatchers {
references += staticFieldLeak(
"android.content.res.ResourcesImpl", "mAppContext",
description = """
A few device manufacturers added a static mAppContext field to the ResourcesImpl class
and that field ends up referencing lower contexts (e.g. service).
A fork of Android added a static mAppContext field to the ResourcesImpl class
and that field ends up referencing lower contexts (e.g. service). Several Android
manufacturers seem to be using the same broken Android fork sources.
""".trimIndent()
) {
listOf(HMD_GLOBAL, INFINIX, LENOVO, XIAOMI, TES).contains(manufacturer) &&
listOf(
HMD_GLOBAL,
INFINIX,
LENOVO,
XIAOMI,
TES,
REALME
).contains(manufacturer) &&
sdkInt >= 30
}
}
Expand Down Expand Up @@ -1557,6 +1618,7 @@ enum class AndroidReferenceMatchers {
const val HMD_GLOBAL = "HMD Global"
const val INFINIX = "INFINIX"
const val TES = "TES"
const val REALME = "realme"

/**
* Returns a list of [ReferenceMatcher] that only contains [IgnoredReferenceMatcher] and no
Expand Down

0 comments on commit c772a41

Please sign in to comment.