Find which piece of code is causing your Android app's UI to freeze by seeing exact stack traces from freeze events.
Add UI freeze detection to debug builds with a single line of code in your app's startup class.
Configure a threshold in milliseconds so only operations slower than your defined limit are recorded and reported.
Include the no-op dependency in release builds to ensure zero performance overhead in production.
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.
← markzhai on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.