-
Notifications
You must be signed in to change notification settings - Fork 126
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
[BUG] Offsets, translations, and other properties that accept arrays get crash on iOS. #480
Comments
I tried to solve this problem by making a few attempts. private class func interpretExpression(propertyName: String, expression: String) -> NSExpression? {
let isColor = propertyName.contains("color");
let isDashArray = propertyName.contains("dasharray");
do {
let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: .fragmentsAllowed)
// this is required because NSExpression.init(mglJSONObject: json) fails to create
// a proper Expression if the data of is a hexString
if isColor {
if let color = json as? String {
return NSExpression(forConstantValue: UIColor(hexString: color))
}
}
// this is required because NSExpression.init(mglJSONObject: json) fails to create
// a proper Expression if the data of a literal is an array
if let offset = json as? [Any]{
if offset.count == 2 && offset.first is String && offset.first as? String == "literal" {
if let vector = offset.last as? [Any]{
if(vector.count == 2) {
if let x = vector.first as? Double, let y = vector.last as? Double {
if isDashArray {
return NSExpression(forConstantValue: [NSNumber(value: x), NSNumber(value: y)])
}
return NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: x, dy: y)))
}
}
}
}
}
return NSExpression.init(mglJSONObject: json)
} catch {
}
return nil
} There are two changes I made:
Obviously, these are just attempts and I know that this isn't the correct and generic solution, but now at least we know that the assignment of NSExpression is the cause of the crash (thus the CGVector in NSValue). |
As I investigated the problem further, I found that this was useful for the “Offset” and “Translation” properties because of the CGVector used for two-dimensional structures. Let me know what you think about it :) |
The bug evolves with new findings: |
Platforms
Version of flutter maplibre_gl
main branch
Bug Description
The property line-dasharray for Line layers doesn't correctly work on iOS Platform.
When attempting to assign the property with an expression as a value, upon Line creation, the app crashes.
Actually, this issue is only on iOS, on Android correctly works. I don't know for web platform.
Steps to Reproduce
Expected Results
Actual Results
Code Sample
The text was updated successfully, but these errors were encountered: