-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: optimize canvas renderer performance #1810
Conversation
06af76e
to
7167936
Compare
… context matrix updates
packages/g-plugin-canvas-renderer/src/shapes/styles/OptimizedDefault.ts
Outdated
Show resolved
Hide resolved
这个开启后有多少的优化效果? |
在我的设备上测试:
发个版本后可以先验证下 s2 和 g6 的效果。 目前从性能数据来看,每一帧的耗时 30% 分布在属性解析和事件分发,70% 分布在元素渲染流程上。目前主要优化的是渲染流程,开启优化策略后该阶段耗时可以降低 50%~70% |
@@ -220,52 +223,62 @@ export class RenderingService { | |||
canvasConfig: Partial<CanvasConfig>, | |||
renderingContext: RenderingContext, | |||
) { | |||
const self = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个目的是?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
内部方法需要
// console.log('canvas renderer fcp...', renderingContext.root.childNodes); | ||
renderByZIndex(renderingContext.root, context); | ||
// console.time('renderByZIndex'); | ||
if (enableRenderingOptimization) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里啥情况
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
优化不是默认开启的
if (enableRenderingOptimization) {
context.save();
renderByZIndex(renderingContext.root, context);
context.restore();
} else {
renderByZIndex(renderingContext.root, context);
}
🤔 This is a ...
🔗 Related issue link
see #1712
💡 Background and solution
Currently, there is not much optimization in the core process of G's canvas renderer, resulting in poor performance under large data volumes. The following strategies can be introduced to optimize performance:
save()
andrestore()
calls to the canvas context state during the rendering process📝 Changelog
☑️ Self Check before Merge