Skip to content

Use URL.createObjectURL during Plotly.downloadImage - #4008

Merged
etpinard merged 7 commits into
masterfrom
createObjectURL
Jul 3, 2019
Merged

Use URL.createObjectURL during Plotly.downloadImage#4008
etpinard merged 7 commits into
masterfrom
createObjectURL

Conversation

@etpinard

Copy link
Copy Markdown
Contributor

... to not hit the 2MB URL-length limit in Chrome - which resolves#3771 - and improve downloadImage performance.

before: https://codepen.io/anon/pen/WWZBOB
after: https://codepen.io/etpinard/pen/MMGGVW (click to "Download plot as a png" modebar button)

All-format playground: https://codepen.io/etpinard/pen/QXraeW

@plotly/plotly_js

... to workaround Chrome URL length limit (#3771) and
probably (not tested) have a perf boost.
N.B. createObjectURL expects Blob object which itself
expect data string w/o data:image prefix, so use
imageDataOnly in the Plotly.toImage call
- so that when we can fallback to window.webkitURL if
window.URL isn't defined
- which speeds up things for loooong SVG strings
- must (still) use encodeSVG in Safari and IE9
@etpinardetpinard added this to the v1.49.0 milestone Jul 2, 2019
@antoinerg

Copy link
Copy Markdown
Contributor

Looks good to me! Thanks for the improvement 💃

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugsomething broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Failed - network error" when downloading large png using toImage button

2 participants

@etpinard@antoinerg