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

Label on Limit Lines cause crash #181

Closed
DarkInsight85 opened this issue Jul 1, 2015 · 8 comments
Closed

Label on Limit Lines cause crash #181

DarkInsight85 opened this issue Jul 1, 2015 · 8 comments

Comments

@DarkInsight85
Copy link

ChartLimitLine *line1 = [[ChartLimitLine alloc] initWithLimit:40.6f];
This works fine,
however if I put a label on my limit lines like this
ChartLimitLine *line1 = [[ChartLimitLine alloc] initWithLimit:40.6f label:@"test"];

My app will crash at ChartUtils.swift drawText function. And my Xcode is subsequently shutdown.

@DarkInsight85
Copy link
Author

P.S: My app supports iOS 7, so I dragged the swift files into my project instead of importing framework.

@liuxuan30
Copy link
Member

You should really edit your stack trace, yours is loosing the focus. Paste only helpful log.
Your main thread stack trace seems irrelevant to drawText. It seems crashes at a very early phase?

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff9138a4de mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff9138964f mach_msg + 55
2 com.apple.CoreGraphics 0x00007fff8b823c09 _CGSSetRegisteredCursor + 190
3 com.apple.CoreGraphics 0x00007fff8b823b2c CGSSetRegisteredCursor + 100
4 com.apple.HIServices 0x00007fff925e3c38 CoreCursorSetAndReturnSeed + 61
5 com.apple.AppKit 0x00007fff929fe9e6 -[NSCursor _reallySet] + 654
6 com.apple.AppKit 0x00007fff929fe6f9 -[NSCursor set] + 223
7 com.apple.AppKit 0x00007fff92b7bcb8 handleCursorRect + 1228
8 com.apple.AppKit 0x00007fff92a2619c -[NSApplication sendEvent:] + 2130
9 com.apple.dt.IDEKit 0x0000000111185c14 -[IDEApplication sendEvent:] + 924
10 com.apple.AppKit 0x00007fff9294fc68 -[NSApplication run] + 711
11 com.apple.AppKit 0x00007fff928cc354 NSApplicationMain + 1832
12 libdyld.dylib 0x00007fff897775c9 start + 1

Add some breakpoints to try.

My app also supports iOS 7 and on my side, my project is also Objective-C based, and ios-charts works fine. So it should be your project issue. Could you try turning off swift optimization and re-compile?

@DarkInsight85
Copy link
Author

Hi Xuan,

I have set optimization level to none and re-compile. The code still crash but now at least my Xcode isn't shut down.

The crash happened in ChartUtils line 133, the error in console is "fatal error: value failed to bridge from Swift type to a Objective-C type"

@liuxuan30
Copy link
Member

hmm, never see such issue. But I guess stack overflow can provide more help?

At least you should edit your post... delete useless logs.

This is how it bridge on my side:

- (SWIFT_NULLABILITY(nonnull) instancetype)initWithLimit:(double)limit label:(NSString * __nonnull)label OBJC_DESIGNATED_INITIALIZER;

I am wondering, it's a double type, and you are giving 40.6f as float type? Just try 40.6

@DarkInsight85
Copy link
Author

Hi I have narrowed down the cause of the crash:

line1.valueFont = [UIFont fontWithName:[NSString stringWithFormat:@"%@-Regular", CLAppFontFamily] size:10.0f];

If I comment out the line above, or replace it with:

line1.valueFont = [UIFont systemFontOfSize:10.0f];

My code would run just fine.

@liuxuan30
Copy link
Member

what is CLAppFontFamily... You may need to check if you have the font. I am no expert on this.

@danielgindi
Copy link
Collaborator

Your font does not exist, and it returns nil. You cannot pass nil to valueFont as it is defined as non-nullable, and you can see that in your original post.

@DarkInsight85
Copy link
Author

Thanks for the help, have resolved this crash.

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

3 participants