Pre loader

XyDataSeries.insertRange fails with "memory access out of bounds"

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

I have XyDataSeries with 50 data points and I’m trying to insert another 50 data points to index 5. The same values can be inserted as a range to the beginning of the data series or inserted one by one starting from index 5. But they fail with “RuntimeError: memory access out of bounds” whenever I try to insert them as a range from index 5.

Code snippet:

const { xValues, yValues } = generateData(50);
const dataSeries = new XyDataSeries(wasmContext, { xValues, yValues, isSorted: false });
sciChartSurface.renderableSeries.add(new FastLineRenderableSeries(wasmContext, { dataSeries }));

// this works
dataSeries.insertRange(0, xValues, yValues);
// this works
for (let i = 0; i < xValues.length; i++) {
  dataSeries.insert(i + 5, xValues[i], yValues[i]);
}
// this fails
dataSeries.insertRange(5, xValues, yValues);

Codesandbox link: https://codesandbox.io/s/scichart-js-boilerplate-forked-hokfcn

I wonder if I’m doing something wrong or if this is an actual issue?

Side note: Index 5 is just an example, because it seems I can use the insertRange method when inserting to index 0-2, but it fails when inserting to index 3+ (in case of a chart with 50 existing data points)

Version
3.0.284
  • You must to post comments
Best Answer
1
0

Hi Timo,

Thank you for the bug report & info. The codesandbox is very useful. Top marks!

Good news, we’ve found & fixed an issue in the low-level memory buffers for XyDataSeries which was causing this memory access out of bounds error.

This has been pushed to our production branch and will be fixed in the next release (version > 3.0.284). Timescale: probably about a week or two at the most.

In the meantime, if you add this workaround:

  // WORKAROUND. NOT FOR PRODUCTION
  // before xyDataSeries.insertRange(index), reserve extra memory 
  dataSeries
    .getNativeXValues()
    .reserve(dataSeries.count() + index + xValues.length);
  dataSeries
    .getNativeYValues()
    .reserve(dataSeries.count() + index + yValues.length);

  // Now do the last insert
  dataSeries.insertRange(index, xValues, yValues);

This should work until the release. You want to remove that as soon as we publish!

Best regards,
Andrew

  • You must to post comments
0
0

Hey Andrew,

That’s great! Thank you for fixing it and for letting me know about the workaround!

Best,
Timo

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.