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

setData might crash Safari iOS if dataset is too large even if just whitespace #1631

Open
drgarlic opened this issue Jul 5, 2024 · 0 comments

Comments

@drgarlic
Copy link

drgarlic commented Jul 5, 2024

Lightweight Charts™ Version: Latest

Steps/code to reproduce:

Create a chart
Add a line series
Create a large dataset, a size of 1 million is good enough, filled with whitespace data (but the last to be able to scroll)
Add it to the line series via setData

Actual behavior:

While just doing this, sometimes it loads fully, sometimes it crashes. (every third reload in my case on an iPhone 13 Pro)
When there are more things going on, like in an actual app, it pretty much crashes the page constantly.

I suspect it's due to some allocation. Since it's mostly whitespace data, maybe there are things that could be optimized or avoided.

I tried to take a look at the code and test some things, while there are some inefficiencies like:

const originalTimes = data.map((d: SeriesDataItemTypeMap<HorzScaleItem>[TSeriesType]) => d.time);

in data-layer.ts:180 which is not needed at all and can be replaced by a simple variable in the loop below, or things like pushing to an Array instead of creating with the right size and setting the value via an index, nothing seems to be good enough. A bigger change might be needed

Expected behavior:

To not crash Safari iOS.

Screenshots:
httpsjsfiddle nett37n82w1

CodeSandbox/JSFiddle/etc link: https://jsfiddle.net/t37n82w1/

@drgarlic drgarlic changed the title setData might crash Safari iOS if dataset is too large setData might crash Safari iOS if dataset is too large even if just whitespace Jul 7, 2024
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

1 participant