You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Cannot set style image to image of different dimensions #7618
mbgl::SpriteAtlas::_setSprite()disallows replacing an existing image with an image of different dimensions. I assume this is because the image would potentially no longer fit in the same location in the sprite sheet, but this behavior is confusing for anyone who isn’t familiar with how the sprite sheet works. Instead, if the new dimensions are larger than the original dimensions, this method should remove the old image and add the new image under the same name but in a new location within the sprite sheet.
We could allow in place updates where the image dimensions do not change. This case should not require reloading tiles, only updating the texture and repainting.
What if the new dimensions fit within the old dimensions?
What if the new dimensions fit within the old dimensions?
The only case where it's safe to update in place is if the dimensions don't change. Otherwise, existing buffers which use the prior dimensions may render incorrectly.
What I’m getting at is that e.g. -[MGLStyle setImage:forName:]’s documentation should have a note that calling it on any name that’s currently in use may result in undefined behavior (without mentioning dimensions). Then we can make it possible to resize an image, specifically for the not-in-use case (but without explicitly checking whether it’s in use). The fact that an image can be updated while in use when the dimensions stay the same would be a happy coincidence, but not something we’d officially support or document.
Per #4556 (comment), this issue also affects the annotation API, which implements custom point annotation images by removing the in-use style image and adding a new one under the same name.
Activity
jfirebaugh commentedon Jan 6, 2017
This is prohibited because it's a complex operation to support. The process would have to be:
jfirebaugh commentedon Jan 6, 2017
Previously: #6735 (comment).
1ec5 commentedon Jan 6, 2017
What if the new dimensions fit within the old dimensions?
jfirebaugh commentedon Jan 7, 2017
The only case where it's safe to update in place is if the dimensions don't change. Otherwise, existing buffers which use the prior dimensions may render incorrectly.
1ec5 commentedon Jan 7, 2017
The same caveat applies to code that calls
mbgl::Map::removeImage()andmbgl::Map::addImage()in quick succession with the same name, correct?jfirebaugh commentedon Jan 7, 2017
Calling
removeImageon an image that's in use is a no-no, just like callingremoveSourceon a source that's in use.1ec5 commentedon Jan 7, 2017
What I’m getting at is that e.g.
-[MGLStyle setImage:forName:]’s documentation should have a note that calling it on any name that’s currently in use may result in undefined behavior (without mentioning dimensions). Then we can make it possible to resize an image, specifically for the not-in-use case (but without explicitly checking whether it’s in use). The fact that an image can be updated while in use when the dimensions stay the same would be a happy coincidence, but not something we’d officially support or document.1ec5 commentedon Jan 14, 2017
Per #4556 (comment), this issue also affects the annotation API, which implements custom point annotation images by removing the in-use style image and adding a new one under the same name.