> 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.

# LoadBundleEntry

APISummary
_LoadBundle_ 是指 [LynxView](/next/zh/guide/spec.md#lynxview) 加载执行 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 引发的首屏渲染流水线，`LoadBundleEntry` 用来记录该次渲染流水线的性能数据，继承自 [`PipelineEntry`](/next/zh/api/lynx-api/performance-api/performance-entry/pipeline-entry.md)。

LoadBundle 流程图如下：

![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/load-bundle-entry-3-7-compressed.png)
:::tip

若无法接收到 `LoadBundleEntry` 性能数据，可能由以下原因导致：

**1. 未触发渲染**

渲染流水线未执行，通常是因为：

- **LynxView 容器状态问题**：宽高为 0、不在视口内、或未添加到窗口。
- **业务逻辑未渲染内容**：例如数据未就绪导致组件的 `render()` 函数返回 `null`。

**2. 监听注册过晚**

`LoadBundleEntry` 仅在首屏渲染完成时触发一次。建议尽早注册监听：

- 类组件在 `constructor` 中注册。
- 函数式组件在 `useMemo` 中注册。

:::

## 示例

该示例展示了如何获取 `LoadBundleEntry`。

**下面是一个示例: performance-api**

**Entry:** `src/load-bundle-entry`
**Bundle:** `dist/load-bundle-entry.lynx.bundle`

```tsx {10-20}
import { root, useMemo, useState } from "@lynx-js/react";
import type { LoadBundleEntry, PerformanceEntry } from "@lynx-js/types";
import { ScrollItem } from "../common/scroll-item/index.jsx";
import "./index.scss";

export default function LoadBundleEntryExample(this: any) {
  const [loadBundleEntry, setLoadBundleEntry] = useState("");

  useMemo(() => {
    "background-only";
    // 1. Create a performance observer.
    const observer = lynx.performance.createObserver((entry: PerformanceEntry) => {
      if (entry.entryType == "pipeline" && entry.name == "loadBundle") {
        // 3. Received "pipeline.loadBundle" event.
        const loadBundleEntry = entry as LoadBundleEntry;
        setLoadBundleEntry(JSON.stringify(loadBundleEntry, null, 4));
      }
    });
    // 2. Register to listen to the "pipeline" event.
    observer.observe(["pipeline"]);
  }, []);

  return (
    <view className="container">
      <text className="title">Hello LoadBundleEntry~</text>
      <ScrollItem title="LoadBundleEntry" value={loadBundleEntry} />
    </view>
  );
}

root.render(<LoadBundleEntryExample />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.8.0



## 实例属性

### [entryType](/next/zh/api/lynx-api/performance-api/performance-entry.md#entrytype)

```ts
entryType: string;
```

性能事件的类型，当前类所有实例的值均固定为 `pipeline`。

### [name](/next/zh/api/lynx-api/performance-api/performance-entry.md#name)

```ts
name: string;
```

性能事件的具体名称，当前类所有实例的值均固定为 `loadBundle`。

### identifier

```ts
identifier: string;
```

某条渲染流水线的标记, 当前类所有实例的值均固定为空字符串：

### loadBundleStart

```ts
loadBundleStart: number;
```

加载执行 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### loadBundleEnd

```ts
loadBundleEnd: number;
```

加载执行 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### parseStart

```ts
parseStart: number;
```

解析 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### parseEnd

```ts
parseEnd: number;
```

解析 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### loadBackgroundStart

```ts
loadBackgroundStart: number;
```

加载执行 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 中[后台线程脚本](/next/zh/guide/spec.md#background-thread-script-or-bts)的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### loadBackgroundEnd

```ts
loadBackgroundEnd: number;
```

加载执行 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 中[后台线程脚本](/next/zh/guide/spec.md#background-thread-script-or-bts)的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### pipelineStart

```ts
pipelineStart: number;
```

渲染流水线的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### pipelineEnd

```ts
pipelineEnd: number;
```

渲染流水线的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### mtsRenderStart

```ts
mtsRenderStart: number;
```

执行[主线程脚本](/next/zh/guide/spec.md#main-thread-script-or-mts)构建 Element Tree 的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### mtsRenderEnd

```ts
mtsRenderEnd: number;
```

执行[主线程脚本](/next/zh/guide/spec.md#main-thread-script-or-mts)构建 Element Tree 的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### resolveStart

```ts
resolveStart: number;
```

计算 [Element](/next/zh/guide/spec.md#element) 样式的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### resolveEnd

```ts
resolveEnd: number;
```

计算 [Element](/next/zh/guide/spec.md#element) 样式的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### layoutStart

```ts
layoutStart: number;
```

[布局](/next/zh/guide/spec.md#layout)计算的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### layoutEnd

```ts
layoutEnd: number;
```

[布局](/next/zh/guide/spec.md#layout)计算的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### paintingUiOperationExecuteStart

```ts
paintingUiOperationExecuteStart: number;
```

执行绘制相关 [UI 操作](/next/zh/guide/spec.md#ui-op)的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### paintingUiOperationExecuteEnd

```ts
paintingUiOperationExecuteEnd: number;
```

执行绘制相关 [UI 操作](/next/zh/guide/spec.md#ui-op)的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### layoutUiOperationExecuteStart

```ts
layoutUiOperationExecuteStart: number;
```

执行布局相关 [UI 操作](/next/zh/guide/spec.md#ui-op)的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### layoutUiOperationExecuteEnd

```ts
layoutUiOperationExecuteEnd: number;
```

执行布局相关 [UI 操作](/next/zh/guide/spec.md#ui-op)的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### paintEnd

```ts
paintEnd: number;
```

基于 UI 和 UITree，完成最终像素化的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### frameworkPipelineTiming

```ts
frameworkPipelineTiming:  FrameworkPipelineTiming[keyof FrameworkPipelineTiming];
```

[框架渲染](/next/zh/guide/spec.md#framework-rendering)中关键阶段的性能数据. 类型为 [`FrameworkPipelineTiming`](/next/zh/api/lynx-api/performance-api/framework-pipeline-timing.md)。

### hostPlatformTiming

```ts
hostPlatformTiming: AndroidHostPlatformTiming |
  HarmonyHostPlatformTiming |
  IOSHostPlatformTiming;
```

[Lynx Pipeline](/next/zh/guide/spec.md#lynx-pipeline) 中不同平台特有的关键阶段的性能数据， 类型为 [`AndroidHostPlatformTiming`](/next/zh/api/lynx-api/performance-api/host-platform-timing/android-host-platform-timing.md) | [`HarmonyHostPlatformTiming`](/next/zh/api/lynx-api/performance-api/host-platform-timing/harmony-host-platform-timing.md) | [`IOSHostPlatformTiming`](/next/zh/api/lynx-api/performance-api/host-platform-timing/ios-host-platform-timing.md)。

### loadCoreStart

```ts
loadCoreStart: number;
```

初始化[后台线程运行时](/next/zh/guide/spec.md#background-thread-runtime)环境的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### loadCoreEnd

```ts
loadCoreEnd: number;
```

初始化[后台线程运行时](/next/zh/guide/spec.md#background-thread-runtime)环境的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### openTime

```ts
openTime?: number;
```

容器开始打开 Lynx 页面的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### containerInitStart

```ts
containerInitStart?: number;
```

容器初始化开始的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### containerInitEnd

```ts
containerInitEnd?: number;
```

容器初始化完毕的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### prepareTemplateStart

```ts
prepareTemplateStart?: number;
```

容器开始准备 [TemplateBundle](/next/zh/guide/spec.md#app-bundle-aka-template-bundle) 的时间。“准备”指容器通过网络下载、加载本地缓存等任意方式获得 TemplateBundle。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### prepareTemplateEnd

```ts
prepareTemplateEnd?: number;
```

容器准备完 [TemplateBundle](/next/zh/guide/spec.md#app-bundle-aka-template-bundle) 的时间。“准备”指容器通过通过网络下载、加载本地缓存等任意方式获得 TemplateBundle。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### createLynxStart

```ts
createLynxStart: number;
```

LynxView 开始创建的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### createLynxEnd

```ts
createLynxEnd: number;
```

LynxView 创建完毕的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### fcp

```ts
fcp?: PerformanceMetric;
```

从准备 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 至首次渲染完成的耗时，数据类型为 [`PerformanceMetric`](/next/zh/api/lynx-api/performance-api/performance-metric.md)。

计算公式为：`fcp = LoadBundleEntry.paintEnd - InitContainerEntry.prepareTemplateStart`。

### lynxFcp

```ts
lynxFcp: PerformanceMetric;
```

从加载 [TemplateBundle](/next/zh/api/lynx-native-api/template-bundle.md) 至首次渲染完成的耗时，数据类型为 [`PerformanceMetric`](/next/zh/api/lynx-api/performance-api/performance-metric.md)。

计算公式为：`lynxFcp = LoadBundleEntry.paintEnd - LoadBundleEntry.loadBundleStart`。

### totalFcp

```ts
totalFcp?: PerformanceMetric;
```

从用户打开页面至首次渲染完成的耗时，数据类型为 [`PerformanceMetric`](/next/zh/api/lynx-api/performance-api/performance-metric.md)。

计算公式为：`totalFcp = LoadBundleEntry.paintEnd - InitContainerEntry.openTime`。

## 兼容性

**Compatibility Table**

**Query:** `lynx-api.performance-api.performance-entry.load-bundle-entry`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/performance-api/performance-entry/load-bundle-entry.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| load-bundle-entry | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| entryType | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| name | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| identifier | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| loadBundleStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| loadBundleEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| parseStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| parseEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| loadBackgroundStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| loadBackgroundEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| pipelineStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| pipelineEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| mtsRenderStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| mtsRenderEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| resolveStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| resolveEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| layoutStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| paintingUiOperationExecuteEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| layoutUiOperationExecuteStart | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| layoutUiOperationExecuteEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| paintEnd | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| frameworkPipelineTiming | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |
| loadCoreStart | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| loadCoreEnd | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| openTime | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| containerInitStart | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| containerInitEnd | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| prepareTemplateStart | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| prepareTemplateEnd | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| createLynxStart | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| createLynxEnd | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| fcp | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| lynxFcp | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |
| totalFcp | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | Yes (3.7) | No |

