I have created a SciChartSurface with a ColumnSeries. I update the series data every second with new values. I have turned on GPU profiling in Android developer options. After running the application I get the image shown in the attachment “SciChart_noCursor”. There are no new columns from the profiler drawn on each update of the chart’s data series. However when I add a VerticalLineAnnonation (which I use as a cursor) I get the image shown in the attachment “SciChart_withCursor”. On every update of the chart’s data series, the SciChartSurface is remeasured and redrawn and a lot of the frames take longer than 16.6 ms to redraw. I have also attached the source code of my example project.
My question is, is there a way to have a cursor line that won’t cause the whole surface to redraw on every update? In my production code I update the chart’s data 5 times per second and I have a much more complex layout. And causing layout measure on SciChartSurface is causing lots of janky frames. The reason I used a vertical line annotation as cursor is because I have have cursor info drawn outside of the SciChartSurface in my own TextView and with the built in cursor I wasn’t able to achieve that.
I don’t think that it’s possible with current implementation of Annotations API. Current implementation updates annotation’s position on every chart redraw to ensure that it’s placed correctly. Theoretically we can skip some annotation updates if nothing changes but in case which you described (when you change data series which triggers redrawing of series ) you still need to redraw annotation because it’s drawn on top of series and after redrawing of series Android OS needs to draw annotation on top it.
Regarding profiling results – there are no columns in GPU profiler when you don’t use line annotation because by default chart is rendered on separate thread ( unless you use RenderSurface which uses Canvas to draw chart ) using OpenGL and built-in profiler can’t track this. However line annotation is another case. It’s View and when we change its position or content it schedules redrawing of entire application window because that how Android works.
Please login first to submit.