Skip to content

Ignore JobService leak in InstrumentationTest for API23#6765

Merged
TimoPtr merged 5 commits intomainfrom
disable_leak_canary_tests_api23
Apr 24, 2026
Merged

Ignore JobService leak in InstrumentationTest for API23#6765
TimoPtr merged 5 commits intomainfrom
disable_leak_canary_tests_api23

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Apr 24, 2026

Summary

After #6720 we started to see failure on the CI while running the dumb InstrumentationTest on LaunchActivity on API23

Starting 4 tests on emulator-5554 - 6.0
emulator-5554 - 6.0 Tests 3/4 completed. (0 skipped) (0 failed)

io.homeassistant.companion.android.launch.LaunchActivityTest > launchActivity[emulator-5554 - 6.0] FAILED 
	leakcanary.NoLeakAssertionFailedError: Application memory leaks were detected:
	====================================
Tests on emulator-5554 - 6.0 failed: There was 1 failure(s).
Finished 4 tests on emulator-5554 - 6.0
Execute io.homeassistant.companion.android.launch.LaunchActivityTest.launchActivity: FAILED
leakcanary.NoLeakAssertionFailedError: leakcanary.NoLeakAssertionFailedError: Application memory leaks were detected:
====================================
HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

895 bytes retained by leaking objects
Signature: 6491376cfe66b1cac0d47b3ae180fd9027019aa5
┬───
│ GC Root: Global variable in native code
│
├─ android.app.job.JobService$1 instance
│    Leaking: UNKNOWN
│    Retaining 923 B in 20 objects
│    Anonymous subclass of android.app.job.IJobService$Stub
│    this$0 instance of androidx.work.impl.background.systemjob.SystemJobService
│    ↓ JobService$1.this$0
│                   ~~~~~~
╰→ androidx.work.impl.background.systemjob.SystemJobService instance
​     Leaking: YES (ObjectWatcher was watching this because androidx.work.impl.background.systemjob.SystemJobService received Service#onDestroy() callback and Service not held by ActivityThread)
​     Retaining 895 B in 19 objects
​     key = 34356ee8-4bed-48c5-9557-20b4007d973c
​     watchDurationMillis = 5147
​     retainedDurationMillis = 142
​     mApplication instance of io.homeassistant.companion.android.HomeAssistantApplication
​     mBase instance of android.app.ContextImpl

I don't think we can do much about it so I decided to ignore it when running on API 23.

Copilot AI review requested due to automatic review settings April 24, 2026 09:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes the LaunchActivity instrumentation test on API 23 by treating a known WorkManager SystemJobService/JobService$1 retention as a library leak, preventing LeakCanary from failing the test on that SDK level.

Changes:

  • Wrap the existing Compose instrumentation rule in a RuleChain alongside LeakCanary leak detection.
  • Temporarily adjust LeakCanary.config.referenceMatchers during the test to ignore the API 23 android.app.job.JobService$1 native-global leak pattern.

@jpelgrom
Copy link
Copy Markdown
Member

This very specifically says it's only on API 23, but that is just our test or did you test with multiple API versions to narrow it down? If not the comment should be updated to make that clear.

@TimoPtr
Copy link
Copy Markdown
Member Author

TimoPtr commented Apr 24, 2026

This very specifically says it's only on API 23, but that is just our test or did you test with multiple API versions to narrow it down? If not the comment should be updated to make that clear.

I didn't test yet on other emulator. I might do that next week if I have time to setup emulator.wtf to try all the APIs we target.

This PR is mostly to unlock the situation, I would say that it is not happening on API 33 with the automotive test we run.

…launch/LaunchActivityTest.kt

Co-authored-by: Joris Pelgröm <[email protected]>
@TimoPtr TimoPtr merged commit fe96040 into main Apr 24, 2026
13 of 23 checks passed
@TimoPtr TimoPtr deleted the disable_leak_canary_tests_api23 branch April 24, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants