Crash with secondary Y axis and crosshair


#1

Hello,

ShinobiCharts - Version: 2.8.5-3, Edition: Premium, Release Date: Nov 10 2015

Having single LineSeries displayed AND crosshair displayed.

If we try to display another LineSeries, which will use secondary Y axis - application will crash.

If second lineseries use the same Y axis, app will not crash.

If there is no crosshair displayed, app will not crash.

I believe this bug was not present in Shinobi 2.7

Basically, I prepare datasource and once it is ready (i.e. contains 2 series, info about axes etc) I call

             [self reloadData];
             [_lineChart redrawChartIncludePlotArea:YES];

The program crashes inside redrawChartIncludePlotArea:

2015-11-18 15:06:46.992 bi[20500:4199300] ShinobiCharts: Couldn't find axis for series "<SChartLineSeries: 0x7872d000>"
From: ShinobiChart at 0x7d98c660
(lldb) bt
* thread #1: tid = 0x401384, 0x043e462a libsystem_kernel.dylib`__pthread_kill + 10, name = '1.4 rv:15', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x043e462a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x043ad664 libsystem_pthread.dylib`pthread_kill + 101
    frame #2: 0x0415b39d libsystem_c.dylib`abort + 156
    frame #3: 0x0052956e bi`+[ShinobiChartLog fatalLogMessage:fromSource:] + 78
    frame #4: 0x005296cc bi`-[ShinobiChartLog handleFatalErrorWithMessage:fromSource:] + 76
    frame #5: 0x004f2462 bi`-[ShinobiChart axesForSeries:storeX:andStoreY:] + 1506
    frame #6: 0x005614b9 bi`-[SChartPixelToPointMapper distanceInfoForSeries:binProvider:toPixelPoint:isOnlySeries:chart:] + 265
    frame #7: 0x00562e2f bi`-[SChartPixelToPointMapper mappingForPoint:lockedToSeries:binProvider:onChart:] + 271
    frame #8: 0x00513193 bi`+[SChartCrosshairSharedUtility mappingForTrackedSeries:locationInChart:isInterpolating:chart:] + 323
    frame #9: 0x0047a232 bi`-[SChartCrosshair moveToPoint:inChart:] + 354
    frame #10: 0x0050681b bi`-[SChartCrosshairController repositionCrosshairInChart:] + 139
    frame #11: 0x004ddaf0 bi`-[SChartCanvasOverlay positionCrosshairIfVisible] + 144
    frame #12: 0x004f371a bi`-[ShinobiChart redrawChartIncludePlotArea:recalcTickLabels:] + 1882
    frame #13: 0x0045ee4f bi`-[SChartAxis animateRangeChange] + 2415
    frame #14: 0x00469b67 bi`-[SChartAxis cancelGestures] + 423
    frame #15: 0x0046a5c8 bi`-[SChartAxis resetZoomLevelWithAnimation:] + 56
    frame #16: 0x0045de26 bi`-[SChartAxis setupInitialRange] + 214
    frame #17: 0x004f5b8b bi`-[ShinobiChart updateChartWithNewChartSeries:newSeriesGroups:] + 2459
    frame #18: 0x004f690f bi`-[ShinobiChart layoutSubviews] + 895
    frame #19: 0x01c5eeb7 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
    frame #20: 0x033d3059 libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70
    frame #21: 0x0193080a QuartzCore`-[CALayer layoutSublayers] + 144
    frame #22: 0x019244ee QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 388
    frame #23: 0x01924352 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26
    frame #24: 0x01916e8b QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 317
    frame #25: 0x0194ae03 QuartzCore`CA::Transaction::commit() + 561
    frame #26: 0x0194c674 QuartzCore`CA::Transaction::flush_transaction() + 50
    frame #27: 0x01bc5c8a UIKit`_afterCACommitHandler + 197
    frame #28: 0x0381761e CoreFoundation` __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    frame #29: 0x0381757e CoreFoundation`__CFRunLoopDoObservers + 398
    frame #30: 0x0380cefc CoreFoundation`__CFRunLoopRun + 1340
    frame #31: 0x0380c706 CoreFoundation`CFRunLoopRunSpecific + 470
    frame #32: 0x0380c51b CoreFoundation`CFRunLoopRunInMode + 123
    frame #33: 0x062ac664 GraphicsServices`GSEventRunModal + 192
    frame #34: 0x062ac4a1 GraphicsServices`GSEventRun + 104
    frame #35: 0x01b951eb UIKit`UIApplicationMain + 160
  * frame #36: 0x002d150a bi`main(argc=9, argv=0xbff088e8) + 138 at main.m:16
    frame #37: 0x040b4a21 libdyld.dylib`start +

Interesting thing is that

SChartLineSeries: 0x7872d000

was not created by me, but somehow exists in the chart.seriesGroups


#2

Found another case when the same crash would happen.

Assuming you have 2 line series, each mapped to its own Y-axis and when one of the series has crosshair shown.

If you remove one series from the chart it would crash with the following stacktrace:

2015-11-20 17:49:37.312 bi[35370:4789624] ShinobiCharts: Couldn't find axis for series "<SChartLineSeries: 0x7b6ebf80>"
From: ShinobiChart at 0x80d93f40
(lldb) bt
* thread #1: tid = 0x491578, 0x043b462a libsystem_kernel.dylib`__pthread_kill + 10, name = '1.4 rv:16', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x043b462a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x0437d664 libsystem_pthread.dylib`pthread_kill + 101
    frame #2: 0x0412b39d libsystem_c.dylib`abort + 156
    frame #3: 0x004f856e bi`+[ShinobiChartLog fatalLogMessage:fromSource:] + 78
    frame #4: 0x004f86cc bi`-[ShinobiChartLog handleFatalErrorWithMessage:fromSource:] + 76
    frame #5: 0x004c1462 bi`-[ShinobiChart axesForSeries:storeX:andStoreY:] + 1506
    frame #6: 0x005304b9 bi`-[SChartPixelToPointMapper distanceInfoForSeries:binProvider:toPixelPoint:isOnlySeries:chart:] + 265
    frame #7: 0x00531e2f bi`-[SChartPixelToPointMapper mappingForPoint:lockedToSeries:binProvider:onChart:] + 271
    frame #8: 0x004e2193 bi`+[SChartCrosshairSharedUtility mappingForTrackedSeries:locationInChart:isInterpolating:chart:] + 323
    frame #9: 0x00449232 bi`-[SChartCrosshair moveToPoint:inChart:] + 354
    frame #10: 0x004d581b bi`-[SChartCrosshairController repositionCrosshairInChart:] + 139
    frame #11: 0x004acaf0 bi`-[SChartCanvasOverlay positionCrosshairIfVisible] + 144
    frame #12: 0x004c271a bi`-[ShinobiChart redrawChartIncludePlotArea:recalcTickLabels:] + 1882
    frame #13: 0x0042de4f bi`-[SChartAxis animateRangeChange] + 2415
    frame #14: 0x00438b67 bi`-[SChartAxis cancelGestures] + 423
    frame #15: 0x004395c8 bi`-[SChartAxis resetZoomLevelWithAnimation:] + 56
    frame #16: 0x0042ce26 bi`-[SChartAxis setupInitialRange] + 214
    frame #17: 0x004c4b8b bi`-[ShinobiChart updateChartWithNewChartSeries:newSeriesGroups:] + 2459
    frame #18: 0x004c590f bi`-[ShinobiChart layoutSubviews] + 895
    frame #19: 0x01c2eeb7 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
    frame #20: 0x033a3059 libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70
    frame #21: 0x0190080a QuartzCore`-[CALayer layoutSublayers] + 144
    frame #22: 0x018f44ee QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 388
    frame #23: 0x018f4352 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26
    frame #24: 0x018e6e8b QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 317
    frame #25: 0x0191ae03 QuartzCore`CA::Transaction::commit() + 561
    frame #26: 0x0191c674 QuartzCore`CA::Transaction::flush_transaction() + 50
    frame #27: 0x01b95c8a UIKit`_afterCACommitHandler + 197
    frame #28: 0x037e761e CoreFoundation` __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    frame #29: 0x037e757e CoreFoundation`__CFRunLoopDoObservers + 398
    frame #30: 0x037dcefc CoreFoundation`__CFRunLoopRun + 1340
    frame #31: 0x037dc706 CoreFoundation`CFRunLoopRunSpecific + 470
    frame #32: 0x037dc51b CoreFoundation`CFRunLoopRunInMode + 123
    frame #33: 0x0627c664 GraphicsServices`GSEventRunModal + 192
    frame #34: 0x0627c4a1 GraphicsServices`GSEventRun + 104
    frame #35: 0x01b651eb UIKit`UIApplicationMain + 160
  * frame #36: 0x0029fa7a bi`main(argc=9, argv=0xbff398e8) + 138 at main.m:16
    frame #37: 0x04084a21 libdyld.dylib`start + 1

#3

Hello,

I have tried to replicate the issue you raised with our MultipleAxes sample by changing both series to SChartLineSeries and enabling the crosshair on both. This seems to work perfectly fine, if you do this and compare this to your own example this may help you find the solution to your problem.

If you need any further help, please do get in touch.

Matt 


#4

Hello Matt,Thank you for the tip, we managed to resolve the issue by putting chart updates into the serial NSOperationQueue.

But we have another problem with crosshair. I prepared an xCode project and will send it by email.