Pre loader

Occassional crashes with SciChartLegend (IndexOutOfBOundsException)

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

Closed
0
0

I am working on the CreateMultiPaneStockChartFragment example. I modified the example, like showing legend checkboxes and some other stuff. I am getting the following exception, but just sometimes (like 30% of time). It happens as soon as I open the fragment.

2019-02-19 12:32:59.551 12534-12534/com.yyyyy.xxxE/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.yyyyy.xxxE, PID: 12534
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.get(ArrayList.java:437)
        at com.scichart.charting.visuals.legend.SciChartLegend$d.a(SourceFile:278)
        at com.scichart.charting.visuals.legend.SciChartLegend$c.run(SourceFile:338)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6944)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Obviously there is some problem with get() on an empty ArrayList, but I am having a hard time to debug where exactly this happens.

I have reviewed my source code multiple times and can not find the cause. What could be the problem?

I am using v2.2.1.2391.

Version
2.2.1.2391
  • Yura Khariton
    It looks like it could be some race condition or maybe result of some exception. Do you see any other errors in logcat except IndexOutOfBoundsException which you reported? Can you reproduce this exception in example without your modifications? Can you provide a modified version of CreateMultiPaneStockChartFragment class?
  • Primoz
    Hi Yura, sorry for delay. It took me some time to pinpoint the issue. I found out that this crash happens if you add LegendModifier to surface BEFORE any model has been added. It is reproducable with the example; just move all addModel() after addinf modifiers and it will crash. You can also check my simplified code here: https://www.scichart.com/questions/question/zoomextents-not-always-working
  • Primoz
    I would like to add that I have modified the example such that I first initialize “fixed, non changeable” chart elements, such as x axis, y axes (I have different Y axes for price, macd, rsi, vol), modifiers. I do this in onViewCreated(). Then I have a runnable that runs every 10 sec which retrieves latest price data, and replaces the series and refresh annotations (I always clear renderableseries and annotation before this call and then add new).
  • Primoz
    I think the problem here was that I set LegendModifier before adding any model (series). This was with older version and I have now rewritten my code and it works, so I will not bother with this anymore.
  • You must to post comments
Showing 0 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies