-
Notifications
You must be signed in to change notification settings - Fork 148
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 under iOS 12 in mapView.mapboxMap.style.localizeLabels() #954
Comments
My guess is that |
Typically, text-field is an expression, which seems to avoid this issue since expressions serialize to arrays. So this crash would require being on iOS 11 or 12 and having a symbol layer with text-field set to a constant. |
* Style.localizeLabels(into:forLayerIds:) crashed on iOS 11 and 12 if any of the symbol layers had text-field set to a constant. Fixes #954
Actually, text-field seems to always return an expression. Even if you set it with a constant string, that gets interpreted as a Formatted, and returned as such. So the crash criteria are actually iOS 11 or 12 and symbol layer with text-field == nil |
* Style.localizeLabels(into:forLayerIds:) crashed on iOS 11 and 12 if any of the symbol layers had text-field set to nil. Fixes #954
* Style.localizeLabels(into:forLayerIds:) crashed on iOS 11 and 12 if any of the symbol layers had text-field set to nil. Fixes #954
* Style.localizeLabels(into:forLayerIds:) crashed on iOS 11 and 12 if any of the symbol layers had text-field set to nil. Fixes #954
Environment
Observed behavior and steps to reproduce
After the map style has loaded I call the localize method to get localized map labels (I’ve loaded the „outdoor“ map style):
self.mapView.mapboxMap.style.localizeLabels(into: Locale.current)
This works fine under iOS 15 (probably also other iOS releases) but crashes under iOS 12 on my iPhone 5s (where I checked my App how it works on the tiny screen).
Expected behavior
The Map applies the localization if available, if not available it uses the default (as documented).
Notes / preliminary analysis
According to the debugger output, the crash occurs in "Style+Localization.swift“ at line 28 because of the „try!“ which can not be catched for the call "convertExpressionForLocalization()“. Further analysis reveals that within "convertExpressionForLocalization()" in line 86 the „symbolLayer.textField“ is nil under iOS 12 (at least for one of the layers), which has the result that the JSONEncoder throws an error. I have no idea why the textField of one of the layers is nil under iOS 12 but not under iOS 15. But by changing the non-catchable "try!“ (line 28) into „try“ or "try?“ so that the App won’t crash with a runtime error anymore, the Map shows fine even under iOS 12 perfectly localized.
I have just made my first steps with the mapBox SDK, so I’m not that familar with all the details. Therefore I'm not really sure if the not-catchable „try!“ has a special purpose here. But it seems that if certain layers might not have all data set under all (older) iOS releases, this „try“ should be better „catchable“ to avoid such crashes.
The text was updated successfully, but these errors were encountered: