Skip to content
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

Optimizations #103

Open
martinRenou opened this issue Jun 28, 2019 · 1 comment
Open

Optimizations #103

martinRenou opened this issue Jun 28, 2019 · 1 comment

Comments

@martinRenou
Copy link
Member

I feel like there could be some optimizations concerning the image update.

  1. We should draw binary data directly on the canvas using:
context.putImageData(binary_data);

instead of creating a Blob that is png encoded. That would also allow the back-end to not waste time encoding into png (if that is possible).

  1. I feel like the "diff" computation should actually be slower than sending the full image, as it needs an extra computation of "which pixels actually needs a redraw?": https://github.com/matplotlib/matplotlib/blob/5fc44eea64a57ab1c6d236cf7c71906c9d40e6f6/lib/matplotlib/backends/backend_webagg_core.py#L190-L195.
    Plus, we are still sending a full image. Maybe the png encoding does some compression if lots of pixels are transparent? If that is not the case, we are still sending the same amount of data.
@tacaswell
Copy link
Member

iirc @mdboom did some bench marking on this to get to the current set up.

png will do run-length encoding so if you have many identical pixels in a row, you will get pretty extreme compression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants