explaingit

markzhai/androidperformancemonitor

6,730JavaAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

An Android library (BlockCanary) that detects when your app's UI freezes, records the stack trace and device state at the time, and shows the details in a notification, helping you find the exact code causing slowdowns.

Mindmap

mindmap
  root((androidperformancemonitor))
    What it does
      UI freeze detection
      Stack trace capture
    How it works
      Main thread monitoring
      Configurable threshold
    Output
      In-app report screen
      Notification on freeze
    Integration
      One-line setup
      Maven Central Gradle
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Find which piece of code is causing your Android app's UI to freeze by seeing exact stack traces from freeze events.

USE CASE 2

Add UI freeze detection to debug builds with a single line of code in your app's startup class.

USE CASE 3

Configure a threshold in milliseconds so only operations slower than your defined limit are recorded and reported.

Tech stack

JavaAndroidGradleMaven Central

Getting it running

Difficulty · easy Time to first run · 30min

Include the no-op dependency in release builds to ensure zero performance overhead in production.

Use freely in any project, including commercial ones, as long as you keep the copyright notice (Apache 2.0 license).

In plain English

AndroidPerformanceMonitor, also known as BlockCanary, is an Android library that helps developers find out why their app's user interface occasionally freezes or feels sluggish. On Android, all UI updates happen on a single main thread. If any piece of code running on that thread takes too long, the screen stops responding until it finishes. Users experience this as a stutter or brief hang. BlockCanary detects when this happens, records the details, and shows them in a notification and a built-in screen inside your app. Setup takes one line of code placed in your app's startup class. When a block is detected, the library captures a stack trace of what the main thread was doing at the time, along with the device's CPU and network state and any user ID or version information you configure. This information is saved locally and displayed in a list so you can see which operations are causing slowdowns. You can configure how sensitive the detection is by setting a threshold in milliseconds. Any operation that takes longer than that threshold is recorded as a block. The default is one second. You can also provide a list of packages you care about so the stack traces are filtered to show only your own code, and a white list of packages like browser components that you want to ignore. The library is available through Maven Central and is added to an Android project via a Gradle dependency. There is also a no-op version that compiles in release builds without any overhead, which means you can keep the detection active only during development and testing. The name is a tribute to LeakCanary, another popular Android diagnostic tool. BlockCanary is released under the Apache 2.0 license.

Copy-paste prompts

Prompt 1
How do I add BlockCanary to an Android project via Gradle and configure it so it only runs in debug builds, not production?
Prompt 2
I see a BlockCanary freeze notification in my Android app. Walk me through reading the stack trace and device state report to find the root cause.
Prompt 3
How do I set BlockCanary's detection threshold to 500ms and filter the stack traces to only show my own app's code packages?
Prompt 4
Show me how to use BlockCanary's no-op release variant so freeze detection compiles out in production builds with zero runtime overhead.
Open on GitHub → Explain another repo

← markzhai on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.