Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.35 KB

README.md

File metadata and controls

36 lines (28 loc) · 1.35 KB

YESAnrDetector

Test coverage Twitter: @protspace

ANRDetector - is a simple framework for detecting cases when application is not responsive (Main thread is blocked). Using a timer it measures how much time was spend on a test operation. It notifies about changes within delegate pattern.

Usage

  1. Drag-and-drop Framework/ANRDetector.framework to your project. Make sure it is present under ‘Link binary with libraries” section in Build Phases of your project.
  2. Import ANRDetector in your class
import ANRDetector
  1. Implement delegate methods (if needed)
extension YourClass: ANRDetectorDelegate {

        func didDetectANR() {
            print("⛔️ ANR DETECTED")
        }

        func didBackToNormal(anrDuration: TimeInterval) {
            print("✅ Back to normal. ANR duration: \(anrDuration) sec.")
        }
}

Problems/difficulties I’ve met:

  1. The ANR duration time calculated is not very precise - this could be improved.
  2. Preparing universal framework that supports x86_64 / arm64 (lipo). I wish there were simple checkbox for this.