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

New EventListener + HeapDumper APIs #2237

Merged
merged 23 commits into from
Dec 28, 2021
Merged

New EventListener + HeapDumper APIs #2237

merged 23 commits into from
Dec 28, 2021

Conversation

pyricau
Copy link
Member

@pyricau pyricau commented Dec 22, 2021

Fixes #1682 (EventListener API)
Fixes #2192 (ForegroundServiceStartNotAllowedException)
Fixes #2214 (disable heap dumping toast)

// No cute canary toast (very sad!)
LeakCanary.config = LeakCanary.config.run {
  copy(
    eventListeners = eventListeners.filter {
      it !is ToastEventListener
    }
  )
}

HeapDumper API makes it possible to ship #2121 (fast native dump) outside the LeakCanary repo:

LeakCanary.config = LeakCanary.config.copy(
  heapDumper = HeapDumper {
    DumpWrapper.dumpHprofData(it.absolutePath)
  }
}

@pyricau pyricau changed the title API for customizing heap dumping New EventListener + HeapDumper APIs Dec 23, 2021
pyricau and others added 2 commits December 23, 2021 22:54
Inspired from #2197

Co-authored-by: itznotabug <itznotabug@gmail.com>
/**
* When receiving a [HeapDump] event, starts a WorkManager worker that performs heap analysis.
*/
object WorkManagerHeapAnalyzer : EventListener {
Copy link
Member Author

Choose a reason for hiding this comment

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

@ItzNotABug thanks for #2197 ! It was super helpful to get this done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! Happy to help. :)

- Support job cancelation for remote job
- Fix bug that led to job cancelation when :leakcanary starts
- Ensuring Events are all serializable
- Moved AndroidDebugHeapAnalyzer to internal
@pyricau pyricau merged commit c7a0ae9 into main Dec 28, 2021
@pyricau pyricau deleted the py/heap_dumper_api branch December 28, 2021 07:45
* }
* ```
*/
val eventListeners: List<EventListener> = listOf(

Choose a reason for hiding this comment

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

this is smart!

alhah added a commit to KwaiAppTeam/KOOM that referenced this pull request Feb 24, 2022
…ions

and support leakcanary custom dumper square/leakcanary#2237

Signed-off-by: xueqiushi <xueqiushi@kuaishou.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants