Flash3001 / iOSCharts.Xamarin

A Xamarin port by Lucas Teixeira for Charts (ios-charts) by Daniel Cohen Gindi, inspired by Philipp Jahoda
Other
68 stars 20 forks source link

Crash with custom ChartXAxisRenderer #42

Closed softeip closed 5 years ago

softeip commented 6 years ago

Trying to set custom renderer It crashes even if i just create an empty subclass with ctors public class XAxisRendererWithTicks : ChartXAxisRenderer { public XAxisRendererWithTicks(ChartViewPortHandler viewPortHandler, ChartXAxis xAxis, ChartTransformer transformer) : base(viewPortHandler, xAxis, transformer) { } protected XAxisRendererWithTicks(NSObjectFlag t) : base(t) { } protected internal XAxisRendererWithTicks(IntPtr handle) : base(handle) { } }

_lineChartView = new LineChartView(View.Bounds); _lineChartView.XAxisRenderer = new XAxisRendererWithTicks(_lineChartView.ViewPortHandler, _lineChartView.XAxis, _lineChartView.XAxisRenderer.Transformer);

Log from hockey app: Exception Type: SIGSEGV Exception Codes: SEGV_MAPERR at 0x87000001ff Crashed Thread: 0

Thread 0 Crashed: 0 ??? 0x00000087000001ff 0x0 + 0 1 Charts 0x000000011610f839 0x1160e3000 + 182329 2 Charts 0x000000011610c848 0x1160e3000 + 170056 3 MyApp 0x000000010cd020e9 0x10c65d000 + 6967529 4 ??? 0x00000001416c614f 0x0 + 0

Is any fix for it? Xamarin.iOS

softeip commented 6 years ago

Crash log from device:

Exception Type: SIGBUS Exception Codes: BUS_ADRALN at 0x100000003 Crashed Thread: 0

Application Specific Information: Selector name found in current argument registers: retain

Flash3001 commented 6 years ago

Hey @softeip,

Unfortunately this is an issue I yet don't fully understand, but here is what I can tell: It is not possible to inherit from any Swift class on C# code, but you can implement interfaces, that is the solution to this problem.

The most interesting part is that it works on the simulator, but not on a real device. On the device, as soon as the Swift object is created it is already collected. When working with Objective-C code you also can't inherit from Swift classes, but in that case Xcode will prevent the compilation.

It is not the same class, but on this comment EugeneUr show how to go around the problem: https://github.com/Flash3001/iOSCharts.Xamarin/issues/11#issuecomment-319378791

Here are other thread on the subject:

https://github.com/Flash3001/iOSCharts.Xamarin/issues/11 https://github.com/Flash3001/iOSCharts.Xamarin/issues/28 https://github.com/Flash3001/iOSCharts.Xamarin/issues/33