-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MGLAnnotationImage with scale greater than 1.0 causes crash. #2198
Comments
Great bug report, thanks for that. So far as we've seen (such as #1936), this error+crash happens when the image resources are not exactly sized in relation to each other. Check that the dimensions of your |
IMHO, app should not crash on size discrepancy. At worst, log a warning to console. Can the images just be padded with transparent pixels if they aren't exactly @2x? |
We should either pad or scale, but not crash. |
@friedbunny You are correct. Our graphics guy has designed the images in 2x and didn't notice their sizes were odd numbers. When generating the fallback 1x version, his software has automatically rounded their dimensions down. Padding all images with transparent pixels fixed the crash. FIY Here are all versions of the map pin which has caused the crash. Their sizes are: On the behavior of your library, I agree with @picciano and @1ec5 . Crashing the app with a mysterious C++ message is too brutal for me and it might cost others a lot of time and coffee to find this thread. Not to mention that other Apple components deal with similar issues a lot more often and manage to handle them gracefully. IMHO your library should pad (or crop) the image to the correct size since this is the behavior of Apple components (thus other developers might expect it from your map view as well). If that approach means a significant slowdown in your rendering engine, you can always print a console warning that the performance might be affected by the additional processing. |
Agreed, this should not crash and we should accommodate mismatched image dimensions. I'll reopen this so we can track a fix. |
Also if you generate the UIImage from CoreGraphics I had to make sure the UIImage CGSize for all pins was the same else it would crash. I wanted the annotation images to be text labels which resized to the name of the location. I got around it by having a large but fixed size UIImage.frame but with clear Background then filling an inner rect which resized to sizeWithAttributes |
|
#3008 should fix both examples above. @clearbrian, the issue is not that the annotation images had different sizes: rather, if you make |
On HiDPI screens, the logical dimensions of a sprite image can be non-integral. Fixes #2198.
Removing from the 3.0.0 milestone because there isn’t consensus on #3008. The workaround is to ensure that your sprite image’s width and height are both whole numbers. |
Still getting this is 3.0.1:
|
@lucacorti, the fix is only in version 3.1.0-pre.1 of the Mapbox iOS SDK. It is not fixed in version 3.0.1. |
Hello, I'm using MapboxGL 0.5 in my iOS map. When trying to annotate map with images of markers on retina displays, I got this error:
Here's my setup:
As I said in the comments, the crash occurs only when
image.scale > 1.0
. I've attempted to use the @1x version of the image only but that looks blurry and ugly on the retina display.To confirm that the error isn't caused by a malformed image file, I've also tried several other @2x images. All of them crashed the app.
I have even managed to prove that this bug is caused explicitly by the scale of the image. The following code works because I've manually tuned down the scale of the @2x image from 2.0 to 1.0. The annotation displays on the map view correctly but has double the size of the original image. You can try and substitute any other scale in the
let scaledUpImage...
line to see my point. If you use scale greater than 1.0, you get a crash.Are there any workarounds?
The text was updated successfully, but these errors were encountered: