Skip to content

Commit

Permalink
Bring in latest batch of known leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pyricau committed Jun 28, 2023
1 parent 437c872 commit 50d05a6
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 13 deletions.
8 changes: 8 additions & 0 deletions shark-android/api/shark-android.api
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public final class shark/AndroidMetadataExtractor : shark/MetadataExtractor {

public abstract class shark/AndroidObjectInspectors : java/lang/Enum, shark/ObjectInspector {
public static final field ACTIVITY Lshark/AndroidObjectInspectors;
public static final field ACTIVITY_THREAD Lshark/AndroidObjectInspectors;
public static final field ANDROIDX_FRAGMENT Lshark/AndroidObjectInspectors;
public static final field ANIMATOR Lshark/AndroidObjectInspectors;
public static final field APPLICATION Lshark/AndroidObjectInspectors;
Expand Down Expand Up @@ -78,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__A0 Lshark/AndroidReferenceMatchers;
public static final field AW_RESOURCE__SRESOURCES Lshark/AndroidReferenceMatchers;
public static final field BACKDROP_FRAME_RENDERER__MDECORVIEW Lshark/AndroidReferenceMatchers;
public static final field BIOMETRIC_PROMPT Lshark/AndroidReferenceMatchers;
Expand All @@ -91,11 +93,14 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field CONTROLLED_INPUT_CONNECTION_WRAPPER Lshark/AndroidReferenceMatchers;
public static final field Companion Lshark/AndroidReferenceMatchers$Companion;
public static final field DEVICE_POLICY_MANAGER__SETTINGS_OBSERVER Lshark/AndroidReferenceMatchers;
public static final field DREAM_SERVICE Lshark/AndroidReferenceMatchers;
public static final field EDITTEXT_BLINK_MESSAGEQUEUE Lshark/AndroidReferenceMatchers;
public static final field EVENT_RECEIVER__MMESSAGE_QUEUE Lshark/AndroidReferenceMatchers;
public static final field EXTENDED_STATUS_BAR_MANAGER Lshark/AndroidReferenceMatchers;
public static final field FINALIZER_WATCHDOG_DAEMON Lshark/AndroidReferenceMatchers;
public static final field FLIPPER__APPLICATION_DESCRIPTOR Lshark/AndroidReferenceMatchers;
public static final field GESTURE_BOOST_MANAGER Lshark/AndroidReferenceMatchers;
public static final field HMD_GLOBAL Ljava/lang/String;
public static final field HOST_ADPU_SERVICE_MSG_HANDLER Lshark/AndroidReferenceMatchers;
public static final field HUAWEI Ljava/lang/String;
public static final field IMM_CURRENT_INPUT_CONNECTION Lshark/AndroidReferenceMatchers;
Expand All @@ -104,6 +109,7 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field INPUT_METHOD_MANAGER_IS_TERRIBLE Lshark/AndroidReferenceMatchers;
public static final field INSTRUMENTATION_RECOMMEND_ACTIVITY Lshark/AndroidReferenceMatchers;
public static final field IREQUEST_FINISH_CALLBACK Lshark/AndroidReferenceMatchers;
public static final field JOB_SERVICE Lshark/AndroidReferenceMatchers;
public static final field LAYOUT_TRANSITION Lshark/AndroidReferenceMatchers;
public static final field LEAK_CANARY_HEAP_DUMPER Lshark/AndroidReferenceMatchers;
public static final field LEAK_CANARY_INTERNAL Lshark/AndroidReferenceMatchers;
Expand Down Expand Up @@ -156,6 +162,8 @@ public abstract class shark/AndroidReferenceMatchers : java/lang/Enum {
public static final field VIEW_GROUP__M_PRE_SORTED_CHILDREN 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;
public static final field XIAOMI Ljava/lang/String;
public synthetic fun <init> (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public static final fun buildKnownReferences (Ljava/util/Set;)Ljava/util/List;
public static final fun getAppDefaults ()Ljava/util/List;
Expand Down
8 changes: 8 additions & 0 deletions shark-android/src/main/java/shark/AndroidObjectInspectors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ enum class AndroidObjectInspectors : ObjectInspector {
}
},

ACTIVITY_THREAD {
override fun inspect(reporter: ObjectReporter) {
reporter.whenInstanceOf("android.app.ActivityThread") {
notLeakingReasons += "ActivityThread is a singleton"
}
}
},

APPLICATION {
override fun inspect(
reporter: ObjectReporter
Expand Down
98 changes: 85 additions & 13 deletions shark-android/src/main/java/shark/AndroidReferenceMatchers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ enum class AndroidReferenceMatchers {
InputMethodManager.mImeInsetsConsumer isn't set to null when the activity is destroyed.
""".trimIndent()
) {
sdkInt == 31
sdkInt >= 31
}
}
},
Expand Down Expand Up @@ -541,7 +541,7 @@ enum class AndroidReferenceMatchers {
" on the screen. TextView.ChangeWatcher and android.widget.Editor end up in spans and" +
" typically hold on to the view hierarchy"
) {
sdkInt in 24..30
sdkInt >= 24
}
}
},
Expand Down Expand Up @@ -814,15 +814,17 @@ enum class AndroidReferenceMatchers {
override fun add(
references: MutableList<ReferenceMatcher>
) {
references += instanceFieldLeak(
"android.app.AppOpsManager\$3", "this\$0",
references += nativeGlobalVariableLeak(
"android.app.AppOpsManager\$3",
description = """
AppOpsManager\$3 implements IAppOpsActiveCallback.Stub and is held by a native ref and
holds on to am AppOpsManager which references an activity context.
Report: https://issuetracker.google.com/issues/210899127
Fix: Update androidx.core:core to 1.10.0-alpha01 or greater as it includes an Android 12
fix for this leak on Android 12, see https://github.com/androidx/androidx/pull/435 .
AppOpsManager\$3 implements IAppOpsActiveCallback.Stub and is held by a native ref long
until the calling side gets GCed, which can happen long after the stub is no longer of
use.
""".trimIndent()
) {
sdkInt in 31..33
sdkInt in 31..32
}
}
},
Expand Down Expand Up @@ -895,6 +897,60 @@ enum class AndroidReferenceMatchers {
}
},

FLIPPER__APPLICATION_DESCRIPTOR {
override fun add(
references: MutableList<ReferenceMatcher>
) {
references += staticFieldLeak(
"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
""".trimIndent()
)
}
},

AW_CONTENTS__A0 {
override fun add(references: MutableList<ReferenceMatcher>) {
staticFieldLeak(
"org.chromium.android_webview.AwContents",
"A0",
description = """
WindowAndroidWrapper has a strong ref to the context key so this breaks the WeakHashMap
contracts and WeakHashMap is unable to perform its job of auto cleaning.
https://github.com/square/leakcanary/issues/2538
""".trimIndent()
)
}
},

JOB_SERVICE {
override fun add(
references: MutableList<ReferenceMatcher>
) {
AndroidReferenceMatchers.nativeGlobalVariableLeak(
className = "android.app.job.JobService\$1",
description = """
JobService used to be leaked via a binder stub.
Fix: https://cs.android.com/android/_/android/platform/frameworks/base/+/0796e9fb3dc2dd03fa5ff2053c63f14861cffa2f
""".trimIndent()
) { sdkInt < 24 }
}
},

DREAM_SERVICE {
override fun add(references: MutableList<ReferenceMatcher>) {
AndroidReferenceMatchers.nativeGlobalVariableLeak(
className = "android.service.dreams.DreamService\$1",
description = """
DreamService leaks a binder stub.
https://github.com/square/leakcanary/issues/2534
""".trimIndent()
) { sdkInt >= 33 }
}
},

// ######## Manufacturer specific known leaks ########

// SAMSUNG
Expand Down Expand Up @@ -1319,15 +1375,15 @@ enum class AndroidReferenceMatchers {
override fun add(
references: MutableList<ReferenceMatcher>
) {
references += staticFieldLeak(
"android.app.ExtendedStatusBarManager", "sInstance",
references += instanceFieldLeak(
"android.app.ExtendedStatusBarManager", "mContext",
description =
"""
ExtendedStatusBarManager is held in a static sInstance field and has a mContext
field which references a decor context which references a destroyed activity.
ExtendedStatusBarManager has a mContext field which references a decor context which
references a destroyed activity.
""".trimIndent()
) {
manufacturer == SHARP && sdkInt == 30
manufacturer == SHARP && sdkInt >= 30
}
}
},
Expand Down Expand Up @@ -1381,6 +1437,20 @@ enum class AndroidReferenceMatchers {
}
},

XIAMI__RESOURCES_IMPL {
override fun add(references: MutableList<ReferenceMatcher>) {
references += staticFieldLeak(
"android.content.res.ResourcesImpl", "mAppContext",
description = """
Both Nokia & Xiaomi added a static mAppContext field to the ResourcesImpl class and
that field ends up referencing lower contexts (e.g. service).
""".trimIndent()
) {
(manufacturer == XIAOMI || manufacturer == HMD_GLOBAL) && sdkInt >= 30
}
}
},

// ######## Ignored references (not leaks) ########

REFERENCES {
Expand Down Expand Up @@ -1479,6 +1549,8 @@ enum class AndroidReferenceMatchers {
const val VIVO = "vivo"
const val RAZER = "Razer"
const val SHARP = "SHARP"
const val XIAOMI = "Xiaomi"
const val HMD_GLOBAL = "HMD Global"

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

0 comments on commit 50d05a6

Please sign in to comment.