You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "Srajan-Sanjay-Saxena (via GitHub)" <gi...@apache.org> on 2025/11/03 19:54:53 UTC

[PR] test: add performance optimization verification test [echarts]

Srajan-Sanjay-Saxena opened a new pull request, #21339:
URL: https://github.com/apache/echarts/pull/21339

   <!-- Please fill in the following information to help us review your PR more efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Fixes canvas laggy rendering for geo maps with many labels by optimizing ZRender refresh cycles to prevent unnecessary re-renders.
   
   ### Fixed issues
   
   - #21331: Canvas laggy rendering with geo maps containing many labels
   
   ## Details
   
   ### Before: What was the problem?
   
   Geo maps with many data points and labels caused performance issues due to excessive refresh cycles in ZRender:
   - Multiple refresh() calls restarted animation loop unnecessarily (8 animation starts for 5 refresh calls)
   - Fixed 10-frame sleep threshold wasn't optimal for complex scenes
   - Redundant hover refresh requests wasted resources
   - Demo showing issue: https://www.makeapie.cn/echarts_content/xVNl_-jjok.html
   
   ### After: How does it behave after the fixing?
   
   Performance optimizations in ZRender prevent unnecessary re-renders:
   - ✅ Duplicate refresh prevention: 8 → 1 animation starts
   - ✅ Adaptive sleep threshold: Complex scenes sleep sooner (3-5 frames vs 10)
   - ✅ Hover refresh optimization: Prevents redundant flag setting
   - ✅ Automated test verification: `test/test-optimizations.html`
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   ## Misc
   
   ### Security Checking
   
   - [x] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [x] This PR depends on ZRender changes (ecomfe/zrender#1142).
   
   ### Related test cases or examples to use the new APIs
   
   - `test/test-optimizations.html` - Automated verification of all performance optimizations
   - Tests duplicate refresh prevention (8 → 1 animation starts)
   - Tests adaptive sleep threshold functionality  
   - Tests hover refresh optimization
   - Provides automated verification of zrender performance improvements
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   
   Performance improvements verified with automated tests showing significant reduction in unnecessary animation restarts and better resource management for complex visualizations.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] test: add performance optimization verification test [echarts]

Posted by "Ovilia (via GitHub)" <gi...@apache.org>.
Ovilia commented on code in PR #21339:
URL: https://github.com/apache/echarts/pull/21339#discussion_r2541044746


##########
test/test-optimizations.html:
##########
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Test Optimizations</title>
+    <script src="../dist/echarts.js"></script>
+</head>
+<body>
+    <div id="chart" style="width: 800px; height: 600px;"></div>
+    <div id="tests">
+        <h3>Test Results:</h3>
+        <div id="test1">Test 1 - Duplicate Refresh Prevention: <span id="result1">Running...</span></div>
+        <div id="test2">Test 2 - Adaptive Sleep Threshold: <span id="result2">Running...</span></div>
+        <div id="test3">Test 3 - Hover Refresh Prevention: <span id="result3">Running...</span></div>
+    </div>
+
+    <script>
+        const chart = echarts.init(document.getElementById('chart'));
+        const zr = chart.getZr();
+        
+        // Simple chart
+        chart.setOption({
+            xAxis: { type: 'category', data: ['A', 'B', 'C'] },
+            yAxis: { type: 'value' },
+            series: [{ type: 'bar', data: [1, 2, 3] }]
+        });
+
+        // TEST 1: Duplicate Refresh Prevention
+        function test1() {
+            let animationStartCount = 0;
+            const originalStart = zr.animation.start;
+            
+            zr.animation.start = function() {
+                animationStartCount++;
+                return originalStart.call(this);
+            };
+            
+            // Reset refresh state first
+            zr._needsRefresh = false;
+            
+            // Call refresh multiple times rapidly
+            zr.refresh();

Review Comment:
   It doesn't seem to make sense calling `zr.refresh();` multiple times. First of all, zrender should be a black-box when using ECharts and developers are not expected to call this function manually. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] test: add performance optimization verification test [echarts]

Posted by "Srajan-Sanjay-Saxena (via GitHub)" <gi...@apache.org>.
Srajan-Sanjay-Saxena commented on PR #21339:
URL: https://github.com/apache/echarts/pull/21339#issuecomment-3492733715

   i have upgraded the package of zrender to nightly in commit 5af7efd322e2ae17a574dce44e83e159b4512cd1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] test: add performance optimization verification test [echarts]

Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #21339:
URL: https://github.com/apache/echarts/pull/21339#issuecomment-3482282445

   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
   
   This PR depends on [ZRender](https://github.com/ecomfe/zrender) changes. Please update the ZRender dependency to the latest nightly version including this change, which takes place everyday at 8:00 UTC (16:00 Beijing Time).
   You can use `npm i zrender@npm:zrender-nightly@dev` to update package.json.
   If you have any question about this, please leave a comment and we will give you extra help on this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org