Skip to content

Commit cd658fe

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-instru-tests
* origin/main: Pin gradle/actions/wrapper-validation to commit SHA to satisfy code scanning Drop API 28 and 29 from instrumentation test matrix Fix LeakActivityTest on API 33+ by disabling notifications during test Fix INSTALL_FAILED_DEPRECATED_SDK_VERSION on API 28+ for leakcanary-android tests Upgrade wrapper-validation-action to gradle/actions/wrapper-validation@v4 Add recent Android API levels to instrumentation test matrix Fix pkill self-match: use qemu-syste[m] pattern Update changelog entry wording for ToastEventListener fix Fix emulator process hanging 20+ min after CI tests finish Add changelog entry for ToastEventListener race condition fix Fix ToastEventListener race condition retaining finished Toast
2 parents 1395f93 + fabd71f commit cd658fe

5 files changed

Lines changed: 27 additions & 12 deletions

File tree

.github/workflows/main.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14-
- uses: gradle/wrapper-validation-action@v1
14+
- uses: gradle/actions/wrapper-validation@48b5f213c81028ace310571dc5ec0fbbca0b2947 # v4
1515

1616
checks:
1717
runs-on: ubuntu-latest
@@ -39,7 +39,9 @@ jobs:
3939
- 21
4040
- 23
4141
- 26
42-
# - 29 flaky
42+
- 31
43+
- 33
44+
- 34
4345
include:
4446
- arch: x86
4547
api-level: 16
@@ -49,11 +51,6 @@ jobs:
4951
api-level: 19
5052
target: google_apis
5153
channel: stable
52-
# Failing (something about permissions maybe?
53-
# - arch: x86
54-
# api-level: 30
55-
# target: aosp_atd
56-
# channel: canary
5754
steps:
5855
- name: Enable KVM group perms
5956
run: |
@@ -102,6 +99,13 @@ jobs:
10299
chmod 777 emulator.log
103100
adb logcat >> emulator.log &
104101
./gradlew leakcanary:leakcanary-android-core:connectedCheck leakcanary:leakcanary-android:connectedCheck leakcanary:leakcanary-android-instrumentation:connectedCheck --no-build-cache --no-daemon --stacktrace
102+
# Force-kill the emulator before the action's post-step cleanup.
103+
# On API 26 google_apis, the emulator process can hang for 20+ minutes after
104+
# receiving adb emu kill, causing the job to hit its 30-minute timeout. Killing
105+
# the qemu-system process here ensures the post-cleanup kill check exits immediately.
106+
# The [m] bracket trick avoids pkill matching its own parent shell process
107+
# (whose cmdline contains the literal string "qemu-system" as an argument).
108+
pkill -9 -f "qemu-syste[m]" || true
105109
- name: Upload results
106110
if: ${{ always() }}
107111
uses: actions/upload-artifact@v4

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
Please thank our [contributors](https://github.com/square/leakcanary/graphs/contributors) 🙏 🙏 🙏.
55

6+
## Unreleased
7+
8+
* 🔨 [#2802](https://github.com/square/leakcanary/pull/2802) Fix `ToastEventListener` race condition leak where LeakCanary's toast was leaking and triggering LeakCanary
9+
610
## Version 3.0 Alpha 8 (2024-06-04)
711

812
* Added support for proper hprof handling on heap growth detection failures. Also inlined some public collaborators to achieve that. We now have a single class that's a bit larger but also a lot more obvious.

leakcanary/leakcanary-android-core/src/main/java/leakcanary/ToastEventListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ object ToastEventListener : EventListener {
5858
val inflater = LayoutInflater.from(resumedActivity)
5959
toast.view = inflater.inflate(R.layout.leak_canary_heap_dump_toast, null)
6060
toast.show()
61+
toastCurrentlyShown = toast
6162

6263
val toastIcon = toast.view!!.findViewById<View>(R.id.leak_canary_toast_icon)
6364
toastIcon.translationY = -iconSize.toFloat()
@@ -66,7 +67,6 @@ object ToastEventListener : EventListener {
6667
.translationY(0f)
6768
.setListener(object : AnimatorListenerAdapter() {
6869
override fun onAnimationEnd(animation: Animator) {
69-
toastCurrentlyShown = toast
7070
waitingForToast.countDown()
7171
}
7272
})

leakcanary/leakcanary-android/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ android {
2929

3030
defaultConfig {
3131
minSdk = libs.versions.androidMinSdk.get().toInt()
32+
// Avoid DeprecatedTargetSdkVersionDialog / INSTALL_FAILED_DEPRECATED_SDK_VERSION on API 28+
33+
targetSdk = libs.versions.androidCompileSdk.get().toInt()
3234
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3335
}
3436
buildFeatures.buildConfig = false

leakcanary/leakcanary-android/src/androidTest/java/leakcanary/LeakActivityTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ internal class LeakActivityTest {
4141
fun importHeapDumpFile() = tryAndRestoreConfig {
4242
val latch = CountDownLatch(1)
4343
LeakCanary.config = LeakCanary.config.run {
44-
copy(eventListeners = eventListeners + EventListener { event ->
45-
if (event is HeapAnalysisDone<*>) {
46-
latch.countDown()
44+
copy(
45+
// Disable notifications to prevent RequestPermissionActivity from launching on API 33+
46+
// (targetSdk >= 33 triggers POST_NOTIFICATIONS permission request which pauses LeakActivity)
47+
showNotifications = false,
48+
eventListeners = eventListeners + EventListener { event ->
49+
if (event is HeapAnalysisDone<*>) {
50+
latch.countDown()
51+
}
4752
}
48-
})
53+
)
4954
}
5055
val hprof = writeHeapDump {
5156
"Holder" clazz {

0 commit comments

Comments
 (0)