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

LineChartRenderer.drawHighlighted crash #5154

Open
abbottkilroy opened this issue Mar 4, 2024 · 2 comments
Open

LineChartRenderer.drawHighlighted crash #5154

abbottkilroy opened this issue Mar 4, 2024 · 2 comments

Comments

@abbottkilroy
Copy link

abbottkilroy commented Mar 4, 2024

What did you do?

We've been seeing A LOT of crashes reported in LineChartRenderer.drawHighlighted.

What did you expect to happen?

No crashes

What happened instead?

It crashes. We've finally got a stack trace that is the probable cause (invalid index in getting lineData[high.dataSetIndex]). We've been unable to reproduce this "on demand".

DGCharts Environment

DGCharts 5.0.0
Xcode version: 15.2
Platform(s) running DGCharts: iOS

Screenshot 2024-03-04 at 11 55 51 AM
@y2ducky
Copy link

y2ducky commented Apr 8, 2024

Same here. DGCharts 5.1.0
Lots of crash reports but I cannot reproduce it.

EXC_BREAKPOINT 0x0000000102cb0b54
Crashed: com.apple.main-thread
0  DGCharts                       0x84b54 $s8DGCharts17LineChartRendererC15drawHighlighted7context7indicesySo12CGContextRefa_SayAA9HighlightCGtF + 1336
1  DGCharts                       0x84c20 $s8DGCharts17LineChartRendererC15drawHighlighted7context7indicesySo12CGContextRefa_SayAA9HighlightCGtFTo + 88
2  DGCharts                       0x242fc $s8DGCharts20BarLineChartViewBaseC4drawyySo6CGRectVF + 2116
3  DGCharts                       0x246fc $s8DGCharts20BarLineChartViewBaseC4drawyySo6CGRectVFTo + 64

@y2ducky
Copy link

y2ducky commented Apr 8, 2024

I've found a workaround that seems to solve the issue. The solution involves calling chartView.highlightValues(nil) every time the chartView's data is changed. This approach seems to prevent crashes by ensuring that any previous highlight indices are cleared before attempting to use them again, which could be the source of the error. Here's an example of how to apply this workaround:

lineChartView.data = newData
lineChartView.highlightValues(nil) // Added line
...
lineChartView.highlightValue(highlight)

I came across this solution by referencing a similar issue discussed here: #4024.
It appears that the crashes may be related to attempts to use highlight indices from previous data sets, and resetting the highlight values upon data update prevents this issue.

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

2 participants