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

Features disappear after adding icons to style. #1307

Closed
imurashov-belkacar opened this issue Apr 29, 2022 · 6 comments
Closed

Features disappear after adding icons to style. #1307

imurashov-belkacar opened this issue Apr 29, 2022 · 6 comments
Labels
bug 🪲 Something is broken!

Comments

@imurashov-belkacar
Copy link

imurashov-belkacar commented Apr 29, 2022

Environment

  • Xcode version: 13.3.1 (13E500a)
  • iOS version: 13.3, 15.4
  • Devices affected: iPhone 6S, iPhone 13 mini
  • Maps SDK Version: 10.4.3, 6.4.0

Observed behavior and steps to reproduce

I have a layer with a approximately 1500 features on it. Application get icons for these features from network (~40-50 icons) and then I add them to the style one by one. After first start of app, part of icons disappear, then they can appear and disappear again. It's going on not in 100% of cases, but often enough.

Expected behavior

Icons not disappear from viewport.

Notes / preliminary analysis

When it started, Mapbox emits StyleImageRemoveUnused event and in log I see repeated message like this with different icon id.
[Mapbox] [Warning, maps-core]: {}[Style]: Unused image 'some unique icon key' will be removed. Subscribe to StyleImageRemoveUnused event to control removal of unused images.

But icons are used. They are on screen.

Additional links and references

I can attach video if it would be helpful.

@imurashov-belkacar imurashov-belkacar added the bug 🪲 Something is broken! label Apr 29, 2022
@imurashov-belkacar
Copy link
Author

Looks like this issue mapbox/mapbox-gl-native-ios#627 still exist in Mapbox 10.

@ZiZasaurus
Copy link
Contributor

@imurashov-belkacar thank you for reporting. If you can add a video, as well as any additional information/ code snippets pertaining to how you're adding your icons, that would be most appreciated.

@imurashov-belkacar
Copy link
Author

Hi, @ZiZasaurus
Sure here is the code:

 imageRequestConfigs.forEach { imageRequestConfig in
            if let urlString = imageRequestConfig.url, let url = URL(string: urlString) {
                
                let imageProcessor = ImageProcessors.Resize(
                    size: imageRequestConfig.size,
                    unit: .points,
                    contentMode: .aspectFit,
                    crop: false,
                    upscale: true
                )
                
                let request = ImageRequest(
                    url: url,
                    processors: [imageProcessor],
                    priority: .veryHigh,
                    options: options,
                    userInfo: [.imageIdKey: imageRequestConfig.id]
                )
                
                nukeImageLoader?.loadImage(with: request) { [weak self] result in
                    switch result {
                    case .success(let response):
                        self?.mapView.mapboxMap.style.addImage(response.image, id: imageRequestConfig.id)
                    case .failure(_):
                        self?.mapView.mapboxMap.style.addImage(imageRequestConfig.defaultImage, id: imageRequestConfig.id)
                    }
                }
                
            } else {
                mapView.mapboxMap.style.addImage(imageRequestConfig.defaultImage, id: imageRequestConfig.id)
            }
        }

Here I load images with Nuke library, but it's doesn't matter, with other image loading libraries the same.

@imurashov-belkacar
Copy link
Author

@ZiZasaurus This is how it's looking on device. Images, are blinked and missed.
It's going on only on first launch.
Keys for icons on map are unique, of course.

bug.mp4

@ZiZasaurus
Copy link
Contributor

@imurashov-belkacar Thank you for the snippet and the video. When are you making your request for the images? Are you requesting them when the map loads, goes idle or at another time?

@imurashov-belkacar
Copy link
Author

@ZiZasaurus Hi. Thank you for your responses.
I think, I found the reason of issue. Sometimes, while icons adds to map, I'm remove the layer with this icons, and than add it again. Looks like, this two events leads to implicitly removing icons, related to features from removed layer.
So, after fixing this part of my code issue with missing icons is gone.

OdNairy pushed a commit that referenced this issue Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something is broken!
Projects
None yet
Development

No branches or pull requests

2 participants