btrace(AKA RheaTrace) is a high performance Android trace tool which is based on Systrace

btrace is a high performance trace tool for Android which was developed for use in the smartphone industry. It supports both native and Java applications and provides powerful features such as: Layer-7 packet capture, detailed application profiling, advanced TCP/IP analysis, deep memory dumps of process stacks with support to detect processes/threads on all cores

android trace log” is a high performance Android trace tool which is based on Systrace. The tool allows users to take screenshots of the application and view the traces.

btrace(AKA RheaTrace) is a high performance Android trace tool which is based on Systrace

btrace

README.md

btraceAKA-RheaTrace-is-a-high-performance-Android-trace-tool-which 1640064870_604_btraceAKA-RheaTrace-is-a-high-performance-Android-trace-tool-which 1640064871_811_btraceAKA-RheaTrace-is-a-high-performance-Android-trace-tool-which

btrace (RheaTrace) is a high-performance Android trace tool based on Systrace that allows you to generate custom events automatically when generating an apk and use bhook to give additional native events such as IO.

Characteristics

Support for automatically defining custom events, as well as injecting Trace#beginSection(String) and Trace.endSection() into app functions during apk development.

Provider adds native events like IO to make it easier to figure out why methods take so long.

Support for just capturing main thread trace events on demand.

It’s simple to use, has a good level of reliability, and has a shorter latency than systrace.

Starting at the beginning

Import rhea-gradle-plugin as a dependency in your project’s main build.gradle file.

mavenCentral()… dependencies… buildscript repositories allprojects repositories… mavenCentral()… classpath ‘com.bytedance.btrace:rhea-gradle-plugin:1.0.1’

Then, in your app/build.gradle, “apply” the plugin and import dependencies by adding the following lines.

dependencies /com.bytedance.btrace:rhea-core:1.0.1″ /rheatrace core lib implementation rheaTrace compilation /use method id to trace custom events to reduce apk size, default false. traceWithMethodID = false /choose which methods you don’t want to be traced, the default is null. /keep name of custom event with specified method id, default null. traceFilterFilePath = “$project.rootDir/rhea-trace/traceFilter.txt” applyMethodMappingFilePath = “$project.rootDir/rhea-trace/keep-method-id.txt” applyMethodMappingFilePath = “$project.rootDir/rhea-trace/keep-method-id.txt” runtime /capture just main thread trace events, default false mainThreadOnly true /when you begin the program, it starts capturing trace events by default. startWhenAppLaunch true /specify the size of the ring buffer that will be used to keep the atrace data in memory. atraceBufferSize “500000” atraceBufferSize “500000” atraceBufferSize “500000” atraceBufferS … use the ‘com.bytedance.rhea-trace’ plugin.

Learn more about rheaTrace by looking at the RheaTrace Gradle Config.

Finally, verify your computer’s python version; RheaTrace only supports Python 2.7 due to systrace, and then configure the systrace environment in the /.bash profile file.

$PATH:/Users/$user name/Library/Android/sdk/platform-tools/systrace export PATH=$PATH:/Users/$user name/Library/Android/sdk/platform-tools/systrace

Usage

Open a terminal window, go to RheaTrace/scripts/python/rheatrace, and run the command shown below.

The output will then be shown below.

The current version of rheatrace is 1.0.0.

RheaTrace keeps the Systrace command parameters, so if you’ve used Systrace previously, you’ll be able to pick up RheaTrace easily.

Syntax

Run rheatrace from the command line using the following syntax to create the HTML report for app:

rheatrace.py in Python [options] [categories]

The following command, for example, uses rheatrace to record device activity and create an HTML report entitled mynewtrace.html. This category list is a good starting point for most devices.

python rheatrace.py -a rhea.sample.android -t 5 -o./output/mynewtrace.html python rheatrace.py -a rhea.sample.android -t 5 -o./output/mynewtrace.html hal dalvik camera input res sched freq idle am wm gfx view binder driver hal dalvik camera input res sched freq idle am wm gfx view binder driver hal dalvik camera

Options on a global scale

Options on a global scale Description
–help | -h Display the assistance message.
-l | –categories-list Your linked device’s tracing categories are listed here.

Options and commands for commands

Commands and options Description
-o file The HTML trace report will be saved to the selected file. If you don’t provide this option, rheatrace stores your report as systrace.html in the same directory as rheatrace.py.
–time=N | –t N For N seconds, record the device’s activities. If this option is not specified, rheatrace will ask you to stop the trace by hitting the Enter key from the command line.
–buf-size=N | –b N N kilobytes is the size of the trace buffer. This option allows you to set a limit on how much data is captured during a trace.
–ktrace=functions –k functions –k functions –k functions –k functions –k functions –k Trace the activities of a comma-separated list of individual kernel functions.
–app=app-name –a app-name This option must be set to enable tracing for the selected program. The Trace class’s tracing instrumentation calls must be included in the program. When you profile your app, you should mention this option because many libraries, like as RecyclerView, provide tracing instrumentation functions that offer helpful information when app-level tracing is enabled.
–from-file=file-path Instead of conducting a live trace, create an interactive HTML report from a file, such as a TXT file containing raw trace data.
–serial=device-serial|–e device-serial Carry out the trace on a single connected device that may be recognized by its serial number.
categories Include tracing information for the system processes you specify, such as gfx for graphics-rendering system processes. The -l command in rheatrace displays a list of services accessible to your connected device.

Options abound.

Options on a global scale Description
–restart | -r Force the app to stop and restart before tracking its activity.
–version | –version Make sure you’re using the most recent version of rheatrace.
–advanced-sys-time | –advanced-sys-time –advanced-sys-time –advanced- The default number for how far in advance systrace should be opened is 2 seconds.
| –debug –debug Whether or not debug log output should be enabled.

Featured Easter Egg

RheaTrace offers Gradle compilation settings to modify the App’s tracking behavior while it’s running, however it requires repackaging every time, which is inefficient. As a result, we provide file configuration options for changing tracking behavior.

Create a Properties format file called rheatrace.config with the following configurations:

class io=true io=true io=true I mainThreadOnly=true atrace=true load=true memory=true atrace=true atrace=true atrace=true atrace=true atrace=true at BufferSize=100000 startWhenAppLaunch=true

Then, to take effect, copy the file to the device directory sdcard/rhea-trace/$application package name and restart the program.

options defaults description
io true Whether or not monitoring io native methods should be enabled.
classLoad fasle If you want to monitor class loading events, you’ll need Android 8.0 or above, and the app build type is debugable.
memory fasle Only Android 8.0 and above are supported, and the app build type may be debugged.
mainThreadOnly fasle Whether to only record trace events on the main thread; if you only care about trace events on the main thread, set this to true.
atraceBufferSize 100000 To save atrace data in memory, provide the size of the ring buffer. If the value is too low, the trace data will be written incorrectly. It is advised that you set the value to about one million if you are capturing multi-threaded trace data; the lowest number is 10,000. The maximum amount is $5,000,000.00.
startWhenAppLaunch true Begin recording tracking events as soon as the app is launched. If you’re doing startup optimization, it’s best to retain the value as-is.

Issues that have been identified

  1. RheaTrace only works with Python 2.7, so make sure your Python environment is up to date.
  2. RheaTrace does not support Windows at this time.
  3. Only the primary process trace events are supported by RheaTrace.
  4. RheaTrace requires read and write rights on external storage, which must be granted explicitly.
  5. Please use perfetto to load the output file systrace.html if you can’t access it directly.

Support

  1. Use GitHub issues to communicate.
  2. Investigate the source code.
  3. For assistance, use the wiki or FAQ.
  4. Please contact us at [email protected].
  5. Participate in a QQ group conversation.

Contributing

Contribution Instructions

License

Apache Software Foundation License

GitHub

Visit Github for further information.

Watch This Video-

btrace(AKA RheaTrace) is a high performance Android trace tool which is based on Systrace. It can be used to find performance bottlenecks in an app and also helps with debugging. Reference: is system tracing spyware.

Related Tags

  • what is system tracing on android
  • what is system tracing in developer options
  • what is system tracing on my phone
  • what is system tracing used for
  • does system tracing improve performance