question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use OffScreenCanvas API for big data live charts

See original GitHub issue

One-line summary [问题简述]

I am creating an application which shows years of historic data and also keeps plotting new live data from a web socket connection, I am facing real performance issues and UI thread goes blocking, I have been searching on it and I think the solution is this. Make use of OffScreenCanvas API to render live charts with big data smoothly. It is really easy to use with just one line amendment. canvasElement.transferControlToOffscreen()

Expected behaviour [期望结果]

Live charts with big data should work smoothly.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:14
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
timothymaroiscommented, Jun 28, 2020

Has this been implemented in the source yet? I would also like the performance to be improved on large data sets, was there any progress on this aside from @CarterLi forked version? Forgive me if I misunderstood this thread, but it seems very useful as I’ve been testing large data sets with dozens of series lines, it starts to drop FPS pretty quick.

8reactions
skortchmark9commented, Feb 9, 2019

I was able to get drawing working in a web worker using this feature:

// main.js
const offscreen = elt.transferControlToOffscreen();
const worker = new Worker('worker.js');
worker.postMessage({ canvas: offscreen }, [offscreen]);

// worker.js
onmessage = function(evt) {
	const canvas = evt.data.canvas;

	echarts.setCanvasCreator(function () {
		return new OffscreenCanvas(32, 32);
	});

	const plot = echarts.init(canvas);
        plot.setOption(...);
}

Certain features didn’t work, but it’s a good start.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use OffScreenCanvas API for big data live charts · Issue #9232
Make use of OffScreenCanvas API to render live charts with big data smoothly. It is really easy to use with just one line...
Read more >
Rendering charts with OffscreenCanvas - Scott Logic Blog
First off we request an OffscreenCanvas from the canvas element using the new transferControlToOffscreen() method. We then call worker.
Read more >
Performance | Chart.js
Web workers can use the OffscreenCanvas API (opens new window) to render from a web worker onto canvases in the DOM. Chart.js is...
Read more >
Rendering 3d offscreen: Getting max performance using ...
The OffscreenCanvas Web API enables us to transfer the ownership of Canvas DOM elements into workers. Since workers run inside a separate ...
Read more >
Real-Time High Performance Rendering with the Offscreen ...
Offscreen Canvas is an up and coming API that allows a developer to offload canvas rendering from the main JS thread in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found