Takt is Android library for measuring the FPS using Choreographer.

Overview

Android Arsenal License Maven Central

Takt is Android library for measuring the FPS using Choreographer.

Takt

Screenshot

How do I use it?

Setup

Dependencies
repositories {
  mavenCentral()
}

dependencies {
  releaseImplementation 'jp.wasabeef:takt-no-op:2.1.1'
  debugImplementation 'jp.wasabeef:takt:2.1.1'
}

Functions

There is a simple initialization step which occurs in your Application class:
Simple

class MyApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    Takt.stock(this)
  }
}

Options

  • seat(Seat seat) is a position
  • interval(int ms) is a interval
  • color(int color) is a text color.
  • size(int size) is a text size
  • alpha(float alpha) is a text alpha
  • listener(Audience audience) is a Listener
  • useCustomControl to manually start/stop Takt (disabled by default)
  • showOverlaySetting to enable/disable showing system overlay setting (enabled by default)
Takt.stock(this)
  .seat(Seat.BOTTOM_RIGHT)
  .interval(250)
  .color(Color.WHITE)
  .size(14f)
  .alpha(.5f)
  .listener { fps ->
    Log.d("Excellent!", fps.toString() + " fps")

    // Logcat
    // jp.wasabeef.example.takt D/Excellent!﹕ 59.28853754940712 fps
    // jp.wasabeef.example.takt D/Excellent!﹕ 59.523809523809526 fps
    // jp.wasabeef.example.takt D/Excellent!﹕ 59.05511811023622 fps
    // jp.wasabeef.example.takt D/Excellent!﹕ 55.33596837944664 fps
    // jp.wasabeef.example.takt D/Excellent!﹕ 59.523809523809526 fps
  }

Position

Takt.stock(this)
  .seat(Seat.RIGHT_CENTER)

  /**
   * TOP_RIGHT,
   * TOP_LEFT,
   * TOP_CENTER,
   *
   * CENTER,
   * RIGHT_CENTER,
   * LEFT_CENTER,
   *
   * BOTTOM_RIGHT,
   * BOTTOM_LEFT,
   * BOTTOM_CENTER
   */

Hide fps label

Takt.stock(this)
  .hide()
  .listener { fps -> Log.d("Excellent!", fps.toString() + " fps") }

Requirements

Android 4.1+ (using the Choreographer)

Developed By

Daichi Furiya (Wasabeef) - [email protected]

Follow me on Twitter

License

Copyright (C) 2020 Wasabeef

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • added no-op artifact

    added no-op artifact

    What does this change?

    no-op artifact was added.

    What is the value of this and can you measure success?

    As we know this library is for staging/debug mode. also requires some permission to draw on apps that are not reasonable to be on production. This pull-request will make safer to use this library and can handle it from gradle implementation commands. such as :

    productionImplemetation 'jp.wasabeef:takt-no-op:2.0.1'
    stagingImplemetation 'jp.wasabeef:takt:2.0.1'
    

    Screenshots

    No need.

    Note

    I'm not familiar with bintray configs to release this artifact. and just copy and paste build.gradle from the original module. You should edit it.

    opened by beigirad 1
  • Update Takt api to be more simple and work correctly on 8.1

    Update Takt api to be more simple and work correctly on 8.1

    Hello!

    Proposed changes fix behaviors described in #11 and readme inaccuracies described in #12

    When I first tried to use Takt, I stumbled upon few behaviors that weren't described in readme, and decided to fix them by making api more understandable and easier to use.

    opened by aleien 1
  • Broken on 8.1

    Broken on 8.1

    Hello! Is library currently not supported? It looks like it doesn't work all good on 8.1 (didn't check other os versions). Also "how to use" is misleading.

    1. You have to use '.showOverlaySetting(true)', otherwise it won't prompt you to enable setting (and without it it doesn't show
    2. You have to add android.permission.SYSTEM_ALERT_WINDOW to your manifest, otherwise you won't be able to enable setting
    3. Misleading guide: onTerminate won't be called ever, so Takt won't be finished until system kills your process, so you need to move Takt.finish() to some other place.

    Also it may be only my problem, but it somehow duplicates one over other, even when launched only once, so it's essentially impossible to see current fps :(

    opened by aleien 1
  • Use TYPE_APPLICATION_OVERLAY on Android8.0

    Use TYPE_APPLICATION_OVERLAY on Android8.0

    TYPE_TOAST is deprecated on Android8.0. If the TargetSdkVersion of the application is 26 or higher and it runs on Android 8.0 or later, an exception will be thrown.

    https://developer.android.com/preview/behavior-changes.html#cwt

    Its need replaced to use TYPE_APPLICATION_OVERLAY, and this type is required SYSTEM_ALERT_WINDOW permission.

    It is the default behavior that this permission was not granted to application via adb. It requires cumbersome user operation to grant permission :(

    So, I added optional api showOverlaySetting. This API is show the overlay settings if needed.

    opened by YukiMatsumura 1
  • Release 2.1.0

    Release 2.1.0

    What does this change?

    Update:

    • Kotlin 1.3.41 -> 1.3.72
    • Compile & Target SDK Version 28 -> 30

    Feature:

    opened by wasabeef 0
  • Leak memory

    Leak memory

    The library has memory leak. I found it with leak canary.

    ┬─── │ GC Root: Local variable in native code │ ├─ android.os.HandlerThread instance │ Leaking: NO (PathClassLoader↓ is not leaking) │ Thread name: 'LeakCanary-Heap-Dump' │ ↓ Thread.contextClassLoader ├─ dalvik.system.PathClassLoader instance │ Leaking: NO (Takt↓ is not leaking and A ClassLoader is never leaking) │ ↓ ClassLoader.runtimeInternalObjects ├─ java.lang.Object[] array │ Leaking: NO (Takt↓ is not leaking) │ ↓ Object[].[3001] ├─ jp.wasabeef.takt.Takt class │ Leaking: NO (a class is never leaking) │ ↓ static Takt.program │ ~~~~~~~ ├─ jp.wasabeef.takt.Takt$Program instance │ Leaking: UNKNOWN │ Retaining 5.4 kB in 109 objects │ app instance of com.zbs.android.App │ ↓ Takt$Program.stageView │ ~~~~~~~~~ ╰→ android.widget.RelativeLayout instance ​ Leaking: YES (ObjectWatcher was watching this because android.widget. ​ RelativeLayout received View#onDetachedFromWindow() callback) ​ Retaining 1.7 kB in 37 objects ​ key = f8ab425e-a992-47fd-8b92-4b209925b054 ​ watchDurationMillis = 5262 ​ retainedDurationMillis = 224 ​ key = bfb77bf7-2c19-430a-8b3a-049ced24122f ​ key = 2383ccf8-6ff7-4f82-82ab-16aba79fc564 ​ watchDurationMillis = 5263 ​ key = 125a0c09-786f-4d1a-8414-81d3d81a695b ​ retainedDurationMillis = 225 ​ View not part of a window view hierarchy ​ View.mAttachInfo is null (view detached) ​ View.mWindowAttachCount = 4 ​ mContext instance of com.zbs.android.App

    METADATA

    Build.VERSION.SDK_INT: 29 Build.MANUFACTURER: Xiaomi LeakCanary version: 2.6 App process name: com.zbs.android Stats: LruCache[maxSize=3000,hits=5711,misses=65587,hitRate=8%] RandomAccess[bytes=3694801,reads=65587,travel=27211795232,range=22255045,size=26 931632] Heap dump reason: 4 retained objects, app is not visible Analysis duration: 6717 ms

    • Device: Xiaomi mi 9 lite
    • OS: Android 10
    opened by dmkenza 0
  • App crashes on startup on Samsung device on Android 7

    App crashes on startup on Samsung device on Android 7

    Bug Reporting

    Steps to Reproduce

    Open app on Samsung device on Android version 7.1.1, app crashes

    Actual Results

    2020-01-08 16:16:34.919 E/AndroidRuntime: FATAL EXCEPTION: main
        Process: package_name, PID: 29421
        java.lang.RuntimeException: Unable to start activity ComponentInfo{activity_name}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3003)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
            at android.app.ActivityThread.-wrap14(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:154)
            at android.app.ActivityThread.main(ActivityThread.java:6823)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
         Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
            at android.view.ViewRootImpl.setView(ViewRootImpl.java:922)
            at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:377)
            at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:105)
            at jp.wasabeef.takt.Takt$Program.play(Takt.java:131)
            at jp.wasabeef.takt.Takt$Program.onAppForeground(Takt.java:110)
            at jp.wasabeef.takt.LifecycleListener.onActivityStarted(LifecycleListener.java:28)
            at android.app.Application.dispatchActivityStarted(Application.java:231)
            at android.app.Activity.onStart(Activity.java:1275)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:614)
            at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1256)
            at android.app.Activity.performStart(Activity.java:6994)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2956)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064) 
            at android.app.ActivityThread.-wrap14(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:154) 
            at android.app.ActivityThread.main(ActivityThread.java:6823) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451) 
    

    OS details

    • Device: Samsung Galaxy Note 8
    • OS: Android 7.1.1
    opened by Lorenzo45 0
  • Takt.finish() will never be called

    Takt.finish() will never be called

    Hi, ReadMe says that finish() methos should be call in onTerminate. But this method is only used in emulated process environments and it will never be called on production device.

    I suppose you can just remove this part from ReadMe or add a comment that finish() will be called only in emulated process environments.

    opened by bracadabra 0
  • FPS text only shows for a few seconds (then disappears) in Android 7.1

    FPS text only shows for a few seconds (then disappears) in Android 7.1

    opened by arshcaria 3
  • Not working on Mi Redmi Note device OS 4.4

    Not working on Mi Redmi Note device OS 4.4

    Getting following exception after adding Takt. android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@420f9140 -- permission denied for this window type

    opened by anil-k-s 2
Owner
Daichi Furiya
Google Developers Expert for Android
Daichi Furiya
Road Runner is a library for android which allow you to make your own loading animation using a SVG image

Road Runner Road Runner is a library for android which allow you to make your own loading animation using a SVG image Sample video View in Youtube Dem

Adrián Lomas 1.2k Nov 18, 2022
A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.

PhotoEditor A Photo Editor library with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories. Features D

Burhanuddin Rashid 3.6k Jan 9, 2023
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API

What is Postman? Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API Usage P

Cafer Mert Ceyhan 129 Dec 24, 2022
How to improve the user experience using animated icons with vector drawables on Android

Android Animated Icons How to improve the user experience using animated icons with vector drawables on Android English version https://medium.com/@an

André Mion 116 Nov 25, 2022
AXrLottie (Android) Renders animations and vectors exported in the bodymovin JSON format. (Using rLottie)

AXrLottie (Android) Renders animations and vectors exported in the bodymovin JSON format. (Using rLottie)

AmirHosseinAghajari 128 Nov 26, 2022
PassCode is the Android app made by using Jetpack Compose. Created for the test task submission.

PassCode PassCode is the Android app made by using the Jetpack Compose. Created for the test task submission. Showcase Dark Theme Light Theme ACs The

Basil Miller 1 May 25, 2022
🌠 Transform into a different view or activity using morphing animations.

TransformationLayout ?? Transform into a different view or activity using morphing animations. Using Transformation motions of new material version. D

Jaewoong Eum 2k Jan 3, 2023
Smoothen rx value streams for e.g. sensor data using kalman filter.

KalmanRx Introduction Removes the noise from float streams using Kalman Filter. Useful to smoothen sensory data e.g.: gps location, or Accelerometer.

Jan Rabe 98 Nov 23, 2022
Animated-splash-screen - Animate your Splash Screen using Lottie files.

Animated Splash Screen This small project shows how you can add animation into your android projects or create beautiful looking Splash Screen or Laun

Aashish Ace 0 Jan 2, 2022
Portfolio-kobweb - A sample project for portfolio built using Kobweb project bootstrapped with the site template

This is a sample project for portfolio built using Kobweb project bootstrapped w

Khalid 6 Mar 26, 2022
Backarrow-animation-example - Animate back arrow to close button in Compose using animated drawables

Animate Back Arrow to Close Icon in Compose This is a simple demo for animated v

Jose Mateo 3 Feb 17, 2022
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
Android library for swipable gestures

Swipper Android Library for custom views to control brightness , volume and seek through swipable gestures . These views could easily replace the conv

Mobile Development Group 105 Dec 30, 2022
Android Library that lights items for tutorials or walk-throughs etc...

Spotlight Gradle dependencies { implementation 'com.github.takusemba:spotlight:x.x.x' } Usage val spotlight = Spotlight.Builder(this) .setTarg

TakuSemba 3.4k Jan 4, 2023
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022
Android Rubber Picker Library

RubberPicker RubberPicker library contains the RubberSeekBar and RubberRangePicker, inspired by Cuberto's rubber-range-picker. Getting started Setting

Chrisvin Jem 547 Jan 5, 2023
EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the Etsy app.

EtsyBlur EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the past Etsy app. Try out the sa

Manabu S. 755 Dec 29, 2022
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023