Shows your current framerate (fps) in the status bar of your iOS app

Overview

WatchdogInspector

Shows your current framerate (fps) in the status bar of your iOS app

Be a good citizen! Don't block your main thread!

Build Status Cocoapods Version CocoaPods Platform Carthage Compatible Twitter

WatchdogInspector counts your app's framerate and displays the fps in the status bar. The coloured status bar lets you know when your framerate drops below 60 fps. If everything is fine your status bar gets happy and will stay green. To detect unwanted main thread stalls you can set a custom watchdog timeout.

Features

  • Status bar displays the current framerate in fps (measured every 2 seconds)
  • Colours the status bar from green (good fps) to red (bad fps)
  • Custom watchdog timeout: Exception when main thread stalls for a defined time

screencast

Install

CocoaPods

pod "WatchdogInspector"

and run pod install You can see the example project how to setup and run WatchdogInspector Make sure that you don't use WatchdogInspector in production.

Carthage

You can use Carthage. Specify in Cartfile:

github "tapwork/WatchdogInspector"

Usage

Objective-C | Swift

Start

After launch or whenever you want.

import WatchdogInspector
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        TWWatchdogInspector.start()
        return true
}

####Stop To stop it just call

TWWatchdogInspector.stop()

Main Thread Stalling Exceptions

You can set a custom watchdog timeout for stalling exceptions (Default: 3 seconds)

TWWatchdogInspector.setStallingThreshhold(10.0)

You could also disable the Main Thread exceptions

TWWatchdogInspector.setEnableMainthreadStallingException(false)

####Logging To log all measured framerates you can log them in the console by calling (Default: on)

TWWatchdogInspector.setUseLogs(true)

How it works

There are basically two timers running to measure the framerate.

  1. The background thread timer fires every 2 seconds to count how many frames were set by the main thread. Ideally the result would be 120 frames in 2 seconds to get 60 fps. The background timer resets the frames counter every event. He also sends the measured fps to the status bar on the main thread.

  2. The main thread timer should fire every 1/60 second (60 fps is optimum for a smooth animation) to increment the frames counter. If the main thread is blocked and can't run every 1/60 second the framerate will drop the 60 fps.

There is also a run loop observer running to detect main thread stalls for a defined timeout. If the timeout has been reached an exception will be thrown.

Related projects

Author

License

MIT

Comments
  • port to tvOS

    port to tvOS

    I have ported the framework to tvOS. I didn't touch the cocoapods or other additional stuff. I tested it in app I ported to tvOS as well, just adding the framework in a workspace, and it looks fine. There are no warnings either (I had issues with the umbrella headers but I fixed them changing the headers from "project" to "public").

    opened by Michelasso 18
  • Port to tvOS

    Port to tvOS

    I don't know if you're interested, but I made it working on tvOS. At least I get a "status bar" (just a CGRect) showing on top of the screen. This is the code modified, file "TWWatchdogInspector.m"

    #pragma mark - UI Updates
    
    + (void)setupStatusView
    {
    #if TARGET_OS_IOS
        CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
    #elif TARGET_OS_TV
        CGRect statusBarFrame = CGRectMake(0, 0, 1920, 20);
    #endif
        CGSize size =  statusBarFrame.size;
        CGRect frame = CGRectMake(0, 0, size.width, size.height);
        UIWindow *window = [[UIWindow alloc] initWithFrame:frame];
        window.rootViewController = [[TWWatchdogInspectorViewController alloc] init];
        [window setHidden:NO];
    #if TARGET_OS_IOS
        window.windowLevel = UIWindowLevelStatusBar + 50;
    #elif TARGET_OS_TV
        window.windowLevel = UIWindowLevelNormal + 50;
    #endif
        kInspectorWindow = window;
    }
    

    I tested it in (yet another) port to tvOS of this git on my Apple TV 4K. It compiles just fine (well.. after messing up with the project configuration to manage to actually make it compiling and importing as a tvOS framework - not an Objective C guy, here) and runs beautifully:

    screen shot 2018-08-06 at 11 16 43

    Although I am not sure if the fps text is supposed to overlap the chart.

    opened by Michelasso 8
  • Allow to customize kUpdateWatchdogInterval

    Allow to customize kUpdateWatchdogInterval

    2 seconds is a bit high to my liking — I would've preferred the status bar to update more frequently. (I'm more concerned about FPS drops rather than general FPS trends...)

    opened by radex 5
  • Getting `TWWatchdogInspectorStallingTimeout` after doing a start > stop > start

    Getting `TWWatchdogInspectorStallingTimeout` after doing a start > stop > start

    I'm toggling whether Watchdog is running via a button, i.e not programatically. When I tap that button 3 times - start > stop > start - the library invariably crashes with the TWWatchdogInspectorStallingTimeout. Should that be expected? And, if so, hoping to understand better why that's the case.

    Thanks!

    opened by hkellaway 4
  • Add ability to disable throwing TWWatchdogInspectorStallingTimeout exception

    Add ability to disable throwing TWWatchdogInspectorStallingTimeout exception

    Would be good if it can add ability to disable throwing TWWatchdogInspectorStallingTimeout exception. While debugging the app, this will always be thrown and crash the app.

    opened by caoer 3
  • Private API usage - confirmation needed.

    Private API usage - confirmation needed.

    HI!

    In readme you wrote:

    Make sure that you don't use WatchdogInspector in production.

    I would like to keep Watchdoginspector for sometime for my development and staging build. Hence,

    #if ENV_DEVELOPMENT || ENV_STAGING
        TWWatchdogInspector.setEnableMainthreadStallingException(false)
        TWWatchdogInspector.start()
    #endif
    

    and so my question is: is it enough to protect myself from app rejection? Does Watchdoginspector use any private API? I'm asking because in release mode Watchdoginspector framework is bundled inside *.ipa.

    Best, Pikor

    opened by pikor 2
  • Add TWWatchdogInspector.h as public library to fix Carthage issue

    Add TWWatchdogInspector.h as public library to fix Carthage issue

    While I was trying to use your library in our project with Carthage I found out some public headers were missing in order to make it work. This PR fix the issue.

    opened by andresBrunFever 1
  • Updated Podfile to fix WatchdogInspector (from ) error for cocoapod v…

    Updated Podfile to fix WatchdogInspector (from ) error for cocoapod v…

    …ersion 1.0.0.beta.4

    When i tried to run example project i got [!] The dependencyWatchdogInspector (from ../WatchdogInspector.podspec)is not used in any concrete target. and i am using cocoapods with version 1.0.0.beta.4` adding these lines into Podfile fixed the issue.

    opened by eraydiler 0
  • Status bar text stays on top of the FPS bar on iOS 13

    Status bar text stays on top of the FPS bar on iOS 13

    Hey 👋 Thanks for the awesome library! Sadly, since iOS 13 apple decided to disallow windows appearing on top of the statusbar text:

    bar

    Some references:

    • https://github.com/SwiftKickMobile/SwiftMessages/issues/335
    • https://developer.apple.com/forums/thread/124649

    Seems that there isn't any workaround for this 😞

    opened by acecilia 0
Releases(1.3.0)
  • 1.3.0(Aug 15, 2018)

  • 1.0.0(Aug 10, 2016)

  • 0.3(May 30, 2016)

  • 0.2.1(Mar 10, 2016)

    • Does not log (Start and Stop) if logging is disabled
    • Adds some more Tests
    • Updates the example projects (Swift)
    • Uses iOS 7 as CocoaPods deployment target (instead of iOS 8)
    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Mar 6, 2016)

    • Exposes updateWatchdogInterval + (void)setUpdateWatchdogInterval:(NSTimeInterval)time;
      • Change the update interval for the background thread timer to count the main thread frames
    • Adds getter to check activity + (BOOL)isRunning;
    • Fixes wrong behaviour when start/stop/start via a button or toggle function
    Source code(tar.gz)
    Source code(zip)
Owner
Christian Menschel
Christian Menschel
In-App iOS Debugging Tool With Enhanced Logging, Networking Info, Crash reporting And More.

The debugger tool for iOS developer. Display logs, network request, device informations, crash logs while using the app. Easy accessible with its bubble head button ?? . Easy to integrate in any apps, to handle development or testing apps easier. First version, there is plenty of room for improvement.

Remi ROBERT 1.8k Dec 29, 2022
Stock tradings Logger app for iOS

Stock Logger Contributor: Name: Prof. Darren Takaki Author: Name: Ibrahim (Wusiman Yibulayin) Student ID: 0728356 Table of contents Description Gettin

null 2 Jul 28, 2022
Tap to swap out words with emojis. Inspired by Messages.app on iOS 10.

EmojiTextView Tap to swap out words with emojis. Works with any UITextView. Heavily inspired by Messages.app on iOS 10. Created by Arkadiusz Holko (@a

Arek Holko 339 Dec 24, 2022
A simple iOS app to simulate a laser level using built-in camera and gyroscope.

Laser Level A simple iOS app to simulate a laser level using built-in camera and gyroscope. Demo https://youtu.be/aB03EtQ5zsU Usage Download Open .xco

Pavel Trusov 2 Oct 30, 2022
Styling and coloring your XCTest logs on Xcode Console

XLTestLog Notes with Xcode 8 and XLTestLog Since Xcode 8 killed XcodeColors, the current way using XCTestLog on Xcode 8 is just plain texts with emoji

Xaree Lee 58 Feb 2, 2022
Allow users to easily share Diagnostics with your support team to improve the flow of fixing bugs.

Example mail composer Example Report Diagnostics is a library written in Swift which makes it really easy to share Diagnostics Reports to your support

WeTransfer 768 Dec 22, 2022
A simple logger for your swift applications.

AHQSLogger A simple logging system. Usage import AHQSLogger Use the following methods for loggging. Logging an information / debug You can log a simp

André Henrique da Silva 0 Dec 29, 2021
XCLog is a Swift extension that helps you print something in console when debugging your projects.

XCLog XCLog is a Swift extension that helps you print something in console when debugging your projects. Installation Open Xcode > File > Add Packages

null 1 Jan 9, 2022
BadgeLog - A light lib that helps and centralize logs in your application

BadgeLog BadgeLog is an iOS Swift library that helps you manage logs within your

Daniele 1 Feb 2, 2022
Tracker - A simple location logger app written in Swift and MVVM architecture

Tracker - A simple location logger app written in Swift and MVVM architecture

Loay Ashraf 1 Mar 12, 2022
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.

TinyConsole TinyConsole is a tiny log console to display information while using your iOS app and written in Swift. Usage Wrap your Main ViewControlle

Devran Cosmo Uenal 2k Jan 3, 2023
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.

Please star this github repository to stay up to date. TraceLog Introduction TraceLog is a highly configurable, flexible, portable, and simple to use

Tony Stone 52 Oct 28, 2022
🍯 Awesome log aggregator for iOS

?? Awesome log aggregator for iOS

Cookpad 204 Oct 24, 2022
Bugfender SDK for iOS, a remote logger tailor-made for mobile

Bugfender SDK for iOS Bugfender is a cloud service to collect mobile application logs. Developers can control log sending programmatically and manuall

Bugfender 69 Dec 4, 2022
Monitor and terminate/throttle CPU hogging processes in iOS

Vedette Monitor and terminate/throttle CPU hogging processes in iOS Vedette is a CPU usage monitoring tweak for processes in iOS like apps and daemons

null 13 Dec 22, 2022
A fast & simple, yet powerful & flexible logging framework for Mac and iOS

CocoaLumberjack CocoaLumberjack is a fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS. How to get started Fir

null 12.9k Jan 9, 2023
Elegant and extensive logging facility for OS X & iOS (includes database, Telnet and HTTP servers)

Overview XLFacility, which stands for Extensive Logging Facility, is an elegant and powerful logging facility for OS X & iOS. It was written from scra

Pierre-Olivier Latour 315 Sep 7, 2022
A Simple iOS Testing Framework

LumberMill Stupidly Simple Logging for iOS. LumberMill is a simple logging library for iOS 10 and Swift 3.0. It allows users to Log files with 5 diffe

UBC Launch Pad 2 Nov 2, 2017
Easy to use and lightweight logger for iOS, macOS, tvOS, watchOS and Linux in Swift.

Lighty Easy to use and lightweight logger for iOS, macOS, tvOS, watchOS and Linux in Swift. Screenshots Requirements Lighty Version Minimum iOS Target

Abdullah Selek 51 Dec 21, 2022