Have you ever encountered a situation where a Xiaomi smartphone starts to slow down, apps crash for no reason, or the battery runs out in a few hours? In such cases, engineers and experienced users often resort to system tracing, a powerful diagnostic tool that captures all the processes that occur in the Android operating system. But what is it in practice and how does it work on Xiaomi devices?
Tracing (or trailing) is the process of collecting detailed logs about the operation of the OS kernel, applications and hardware components. On Xiaomi smartphones, this mechanism is integrated deeper than on βpureβ Android, thanks to the branded shell. MIUI. It allows you to track everything from processor load to errors in the graphics driver, but not all users understand that enabling traces unnecessarily can lead to leakage of sensitive data through system logs if the device falls into the wrong hands.
In this article, we will discuss what types of tracing exist on Xiaomi, how to activate them (including through hidden developer menus), what risks this entails, and how to correctly interpret the collected logs.
What is a tracing system and why it is needed
System tracing is the process of recording events occurring in the operating system and hardware components of a smartphone. β The phone. β Version. MIUI β Error logs), tracer captures data with high detail and frequency, which allows you to detect:
- π Interface freezes - when MIUI slows down when swipes or opening applications.
- π Abnormal battery consumption - what processes "eat" the charge in the background.
- π¨ App crashes β why WhatsApp or Google Play suddenly shut down.
- π‘ Networking problems β why Wi-Fi or 4G/5G runaway.
On Xiaomi devices, tracing is implemented through several subsystems:
- Linux kernel β captures events at the processor, memory and driver level.
- Android Framework β monitors the operation of system services (for example, SurfaceFlinger for graphics).
- MIUI Layer adds logs to proprietary features such as Second Space or Game Turbo.
It's important to understand that tracing is not a magic wand. It generates huge amounts of data (up to 500 MB in a few minutes) that require special tools for analysis, such as the Kernel Trace Analyzer to read the kernel logs, and the Kernel Trace Analyzer to analyze. MIUI-specific events β utilities from Xiaomi that are not distributed publicly.
Types of tracing on Xiaomi smartphones
There are several types of tracing available on Xiaomi devices, each of which solves its own problems, and they can be divided into hardware (processor dependent) and software (implemented through Android and other devices). MIUI). Below is a comparative table of the main species:
| Type of tracing | What's fixing | How to turn it on | Limitations |
|---|---|---|---|
| ftrace | Linux kernel events (interruptions, task scheduler, driver operation). | Through the adb shell or the developer menu. | Requires root or unlocked bootloader on some models. |
| atrace | The work of Android applications and system services (graphics, audio, Binder) IPC). | Adb shell atrace command. | It does not record events at the core level. |
| MIUI Logger | Logs of proprietary functions (Theme Engine, Security App). | Enabled via the engineering menu (#4636##). | Data is encrypted, a decryptor from Xiaomi is required. |
| Perfetto | Unified Tracing (combines ftrace, atrace and user events) | Through adb shell perfetto. | High load on the processor during recording. |
The most versatile tool today is the Perfetto, which Xiaomi is actively integrating into new models (starting with the Redmi Note). 11 Xiaomi 12 It allows you to record traces from multiple sources at the same time, which makes it easier to diagnose complex problems, for example, if the smartphone overheats when playing, Perfetto will show the download and download. CPU/GPU, and activity of the SurfaceFlinger graphics stack, and temperature sensors.
But there's a downside to this: tracing can cause problems, such as log logging via ftrace on budget models (e.g. Redmi). 9A) capable of loading the processor 30-40%, This will cause additional heat and discharge of the battery, so you should only use it when you really need it.
π‘
If you need trace to send to Xiaomi Support, use the built-in log collection feature in the Settings menu. β The phone. β It's safer than manual activation of ftrace.
How to turn on tracing on Xiaomi: step-by-step instructions
Before you activate the trace, make sure that your device is allowed to develop mode.
- Go to Settings. β The phone.
- Tap 7 times on the MIUI version.
- Enter the password from your Mi Account if required.
Then on the Settings menu β And then there's a developer section, and then you can start setting up the tracing, and let's look at two basic ways:
Method 1: Through ADB (universalism)
This method works on all Xiaomi models, but requires a computer connection.
- π₯οΈ Computer with installed ADB-driver.
- π± USB-cable (preferably original).
- π§ Included debugging by USB developer-setting.
Steps:
- Connect your smartphone to your PC and open the terminal (or Command Prompt).
- Enter the command to check the connection: Adb devices Make sure the device appears in the list.
- To start the trace through ftrace, use: adb shell echo 1 > /sys/kernel/debug/tracing/tracing_on
- To save logs to file: adb shell cat /sys/kernel/debug/tracing/trace > trace.log
Battery charge > 50%|Debugging by USB included|USB-cable connected to port USB 3.0|PCs are installed. ADB-driver-->
Method 2: Through the Engineering Menu (without PC)
Some Xiaomi models, for example, POCO F3 or Mi 11) supports activation of tracing through hidden menus:
- Open the phone app and enter the combination: ##4636##
- In the menu that appears, select Usage statistics (or Usage Statistics).
- Click on the three dots in the top right corner and select Enable tracing.
- Enter the duration of the recording (not more than 30 seconds for the first test is recommended).
β οΈ Note: Some firmware (e.g. global version) MIUI 14) this method may not work due to manufacturer limitations, in which case only the option of c ADB.
What to do if the engineering menu is not opened?
Log analysis: how to read tracing
The tracing logs collected are text files with thousands of lines of data, which are almost impossible to understand without special knowledge, but there are a few key points to consider:
- β±οΈ Time stamps β indicate when an event occurred (e.g., [123.456789] means 123 milliseconds from the start of the recording).
- π Process identifiers (PID) β help track which application or service caused the event (e.g. pid)=1234).
- β οΈ Keywords: WARN or ERR β mistake. sched_switch β switching tasks (useful for analyzing lags). thermal - events associated with overheating.
For visualization of logs can be used:
- π Perfetto UI β Web interface from Google (ui.perfetto.dev).
- π₯οΈ Trace Compass β Desktop Software for Deep Analysis.
- π± Catlog β an application for viewing logs directly on a smartphone (suitable for basic analysis).
Example of decryption of a line from ftrace:
[ 123.456789] sched_switch: prev_comm=com.android.launcher/1234 prev_pid=1234 prev_prio=120 prev_state=S ==> next_comm=kworker/0:1/0 next_pid=0 next_prio=120You can see here that the process com.android.launcher MIUI) suspended (prev_state=S and control is transferred to the system worker (kworker.
π‘
If you see repeated errors in the same logs PID, It's probably an application that's the problem. Try clearing the cache or reinstall it.
Risks and safety: What you need to know
Tracing the system is a powerful tool, but it carries some serious risks:
- Leaked sensitive data. Logs may include: Application names (including banking) and location metadata (if enabled) GPS). Fragments of correspondence (if the work of messengers is traced).
System load
Conflicts with MIUI
MIUI 13
India
β οΈ Note: If you send trace logs to Xiaomi support or forums (e.g, 4PDA), You can delete personal information from them:
sed -i 's/[0-9]\{10,\}/[PHONE]/g' trace.logThis command will replace all long numerical sequences (such as phone numbers) with [PHONE].
Another important point: on devices with a locked bootloader (most Xiaomi smartphones are sold in this state), some traces may be limited, for example, the recording of kernel events (ftrace) will be available only for system applications. To circumvent this limitation, you will need to unlock the bootloader through the Mi Unlock Tool, but this will void the warranty.
Disabling tracing and cleaning the logs
Once the diagnosis is complete, it is important to disable the tracer to avoid unnecessary system loads, and this can be done in several ways:
- π Through ADB: adb shell echo 0 > /sys/kernel/debug/tracing/tracing_on
- π Through the engineering menu (if the tracing was included there).
- π± Reboot device β resets most types of tracing (except for MIUI Logger).
To delete the saved logs, do:
- For ftrace: adb shell echo > /sys/kernel/debug/tracing/trace
- For atrace, logs are stored in a temporary folder and deleted automatically after rebooting.
- For MIUI Logger β Cleaning through Settings β Memory. β Cleaning (not always effective).
β οΈ Note: On some models (e.g. Xiaomi Mi) A3 With Android One, trace logs can be saved in a hidden partition /data/log. In order to remove them completely, you will need to:
- Get root access.
- Use a file manager with superuser rights (e.g., Root Explorer).
- Manually delete the contents of the folder /data/log.
If you do not plan to continue working with tracing, it is recommended to disable the developer mode, as it opens up additional vectors for attacks (for example, through the use of tracing). ADB).
Frequent mistakes and their solutions
When working with tracing on Xiaomi, users often face typical problems, and here are the most common ones and how to solve them:
| Problem. | Possible cause | Decision |
|---|---|---|
| The adb shell command is not working. | No driver or debugging is installed on USB switched off. | Set up Mi. PC Suite and check the developer settings. |
| Logs are empty or not written down | Lack of rights or the tracing buffer is overflowing. | Clean the buffer with the adb shell echo command > /sys/kernel/debug/tracing/trace. |
| The device overheats when tracing | High CPU load (especially on Snapdragon) 4xx). | Reduce the recording frequency or use Perfetto with a limited CPU. |
| Engineering menu not open | Blocked by the manufacturer or firmware. | Try alternative codes (e.g. #284## for sensor test). |
If you encounter an error that is not in the table, check the logs for keywords:
- permission denied β problems with rights (root or unlock the bootloader is needed).
- No such file or directory is the wrong path to the trace file (relevant for custom firmware).
- device not found β ADB Does not see the device (check the cable and drivers).
To diagnose complex cases, you can use the Xiaomi Log Tool, which is sometimes provided by brand support, which automatically analyzes logs and gives recommendations. However, this tool is not officially distributed, it can only be found in specialized forums (for example, in the Internet, XDA Developers).
π‘
If tracing is needed for warranty repairs, do not edit logs manually. Xiaomi's service center may refuse repairs if it detects signs of interference.