请问在H5列表渲染多个PAG是否有好的优化方案? #2907
Answered
by
kevingpqi123
niuhangkai
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
kevingpqi123
Feb 2, 2026
Replies: 1 comment 1 reply
-
|
PAG Web SDK 不推荐同屏渲染多个 PAGView,主要原因:
推荐方案:使用 PAGComposition 合并渲染 将多个 PAG 文件添加到一个 PAGComposition 中,只用一个 Canvas 渲染: // 创建空的 PAGComposition
const composition = await PAG.PAGComposition.make(width, height);
// 添加多个 PAG 文件,通过 setMatrix 设置位置
for (const pagFile of pagFiles) {
pagFile.setMatrix(matrix);
composition.addLayer(pagFile);
}
// 只用一个 PAGView 渲染
const pagView = await PAG.PAGView.init(composition, canvas);
pagView.play();其他优化建议:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kevingpqi123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

PAG Web SDK 不推荐同屏渲染多个 PAGView,主要原因:
WebGL context lost推荐方案:使用 PAGComposition 合并渲染
将多个 PAG 文件添加到一个 PAGComposition 中,只用一个 Canvas 渲染:
其他优化建议:
destroy()回收无用的 PAGView 实例相关文档:https://pag.art/docs/web-…