> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.


# Trace

使用 Trace 可以获取 Lynx 页面详细的渲染流程，帮助你定位、分析和解决卡顿、长任务等性能问题。

## Trace 的核心能力

### 1. 渲染流水线可视化

Trace 以时间轴方式完整展示页面脚本执行、Element 构建、布局计算到最终渲染的全过程。你可以：

- 清晰查看各关键阶段（如排版、绘制）的耗时分布；
- 直观发现流程中的阻塞节点与性能瓶颈；
- 识别冗余或重复的渲染任务，优化页面结构。

![Trace Render Pipeline](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/trace_render_pipeline_latest.png)
### 2. 引擎执行流程追踪

Trace 深入 Lynx 引擎底层，详细记录：

- 任务调度与队列切换的时序；
- 事件处理链路的全貌；
- API 调用的具体耗时与调用关系。

这些数据帮助你定位异步任务拥塞、事件响应延迟等问题，实现精准优化。

![Trace Task Scheduling](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/trace-scheduling.png)
### 3. 丰富的性能分析能力

Trace 提供了多维度的性能分析能力：

- [Element](/next/zh/guide/spec.md#element) 分析：追踪 Element 树结构的变化，识别高频次或高成本的节点操作，帮助你发现页面结构设计上的性能隐患。

![Element](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/element-render-analysis-latest.png)
- [NativeModules](/next/zh/guide/spec.md#native-module) 调用分析：监控 NativeModules 的详细调用过程，直观显示每一次跨端调用的耗时与参数，定位潜在瓶颈。

![NativeModules](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/nativemodule-invoke-flow.png)
- 流畅度分析：通过任务耗时的火焰图，快速定位卡顿根源，辅助你优化动画和交互。

![Trace Frame](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/trace-frame.png)
## Next Steps

- [录制 Trace](/next/zh/guide/devtool/trace/record-trace): 了解如何录制 Trace


## 兼容性

**Compatibility Table**

**Query:** `devtool.trace`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/devtool/trace.json) · [API Reference](/next/guide/devtool)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| trace | Yes (3.4) | Yes (3.4) | Yes (3.4) | Unknown | Unknown | No |

**`trace`**

Trace Tool

**Specifications:**

