-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Crash by initialize() of CombinedChartView #406
Comments
First, you should not delete 'weak', it is supposed to be weak I think. I checked let filled = generateFilledPath(
entries,
fillMin: delegate!.lineChartRendererFillFormatter(self).getFillLinePosition(
dataSet: dataSet,
data: delegate!.lineChartRendererData(self),
chartMaxY: delegate!.lineChartRendererChartYMax(self),
chartMinY: delegate!.lineChartRendererChartYMin(self)),
from: minx,
to: maxx,
matrix: trans.valueToPixelMatrix) So start from here. Next time you see a crash, remember to post the back trace here, with the top most ones, that can be used to identify the issue. |
I met the same problem , XCode7 swift 2.0 |
Same here, oddly enough on debug mode it works fine. |
I find the solution, CombinedChartView.swift, public override func initialize()
{
super.initialize()
_fillFormatter = BarLineChartFillFormatter(chart: self)
renderer = CombinedChartRenderer(chart: self, animator: _animator, viewPortHandler: _viewPortHandler)
} changed to following public override func initialize()
{
super.initialize()
let format = BarLineChartFillFormatter(chart: self)
_fillFormatter = format
renderer = CombinedChartRenderer(chart: self, animator: _animator, viewPortHandler: _viewPortHandler)
} |
@KerryJava I have checked the code, I have been using combined chart view all the time, and never see it crash here. Even now, I test it with ChartsDemo's combined chart view, no matter I change the optimization level from So, we need more info here, is it always crash on your side or how often? What's the configuration, like swift optimization level, Xcode, iOS version? BTW, |
I'm getting a very same crash after appstore upload. If I build for device or simulator from xcode it works fine. My crash is: The code optimalization is turned off. Xcode Version 7.0 (7A220), Swift 2.0, iOS 8 - iOS 9 |
@liuxuan30 , It crash every time , so if it were configuration problem , why I make code changed like that can avoid crash problem ? I try to user keyword 'var' , but the complier recommend using 'let'. I can reproduce the problem using demo project. demo project works fine on my mac , if I remove the charts.xcproject and drag back again , it crash when it runs. Chinese, demo工程没有问题,但是我重新手动配置就会复现这个问题。可以直接联系我啊,我的邮件是qq471723562@126.com |
@KerryJava It's quite interesting, since I never crashed like this on my side. And a few people are having the same issue here. That's what we need to dig deeper, and find out the difference. My app needs to support iOS 7, so I simply drag all the swift files into my project and start from there. Are you using the framework directly? Will this matter? I have tried with ChartsDemo, remove reference for charts.xcproject, and drag it back, on iOS simulator 9 and iPhone 6 plus model, nothing crashes for combined chart, debug mode. @danielgindi, have you seen this or any ideas? |
Error raise only in release mode. In Debug mode all right. Just set build configuration in scheme to Release and exception will be raised :) |
I've found a solution. I don't know why and also is it the right solution, but if I just drag and drop the .swift files in the project everything works fine. If I use embedded framework the release build crash every time... |
@pappzsolt100 that is exactly why I don't see such issue, I need to support iOS 7. I am able to reproduce, still trying to figure out what's the problem. |
I got this error message from console:
Looks like it has something to do with the release flag, the compiler is optimzing the code but has bugs. I think this also can explain, why @KerryJava use let format = BarLineChartFillFormatter(chart: self)
_fillFormatter = format can clean the crash is that the compiler optimized in another way and avoid the crash. So either use the files or add above code to workaround it. @danielgindi would you think accept above code? |
did some more debugging:
and check x8:
Look at the crash reason:
address=0xea8 is exactly [x8, #3752] I think.. Continue to figure out why $x8 is nil:
now check x19:
and $x19 is exactly self's address: Not sure if I am correct but looks like the compiler tried to read a wrong mem address. The reason is [$x19] has nothing at that moment, and computes a invalid mem address But this actually somewhat explained: |
frame #1: 0x00000001026f3235 gpxj`gpxj.ChartViewBase.init (self=<unavailable>)(frame : C.CGRect) -> gpxj.ChartViewBase + 1141 at ChartViewBase.swift:145
frame #2: 0x00000001026c1221 gpxj`gpxj.BarLineChartViewBase.init (self=0x00007fe79d8d39a0)(frame : C.CGRect) -> gpxj.BarLineChartViewBase + 673 at BarLineChartViewBase.swift:74 self= show everything |
I've seen the Don't know if its the same issue but I had a I don't remember where it would crash but it wasn't where I was setting the data so it was hard to track. Maybe try what I did and see if that fixes the issue. |
@petester42 , just like @cooler333 said, simply change the Run scheme's debug mode to release mode, and open the ChartsDemo's combined chart, it will crash the same way. So I am still guessing it's because of the compiler's optimization. |
I cannot avoid committing the fix into The compiler bug was reported to Apple..... Let's see when a compiler fix will be issued... |
Thank you guys for your efforts! @liuxuan30 you've provided a lot of information regarding the issue, The problem is not in the assignment, it seems, but in reading the pointer to the new variable. When trying to assign through |
@danielgindi One interesting thing is that I don't see this problem on my side, seems because I need to support iOS 7.0. I use source files and archive my app, which is also a release mode right? I am wondering why using source files has no problem. |
@danielgindi a little correction , is my solution , not @venice81 's solution. |
I don't speak English well.
CombinedChartView.initialize() -> () (CombinedChartView.swift:40)
CombinedChartView.initialize() -> () (CombinedChartView.swift:40)
ChartViewBase.init(frame : CGRect) -> ChartViewBase (ChartViewBase.swift:145)
BarLineChartViewBase.init(frame : CGRect) -> BarLineChartViewBase (BarLineChartViewBase.swift:75)
@objc CombinedChartView.init(frame : CGRect) -> CombinedChartView (CombinedChartView.swift:0)
-PDNoteBMIChangeWeightDetailView setupChartView
I found suspicious part in BarLineChartFillFormatter : 1650
private weak var _chart: BarLineChartViewBase!
I erased the 'weak'. so it's not crash anymore.
What right have I modified the way?
The text was updated successfully, but these errors were encountered: