0

My team is in the process of updating to Mapbox v10. We have several tile map layers that are all crashing immediately upon loading.

One weird thing I've noticed is that the crash only happens when connected to Xcode debugger. If I launch the app directly from the device, everything works as expected.

It looks like the crash is Metal-related, but Mapbox is supposed to abstract away all of the Metal code, so I'm not sure if this is a me bug or a Mapbox bug.

The error:

[MTLDebugBlitCommandEncoder generateMipmapsForTexture:]:1109: failed assertion `Generate Mipmaps For Texture Validation [tex mipmapLevelCount](1) must be > 1.'

The code:

private func prepareFrames() {
  // Array of String
  for frame in tileFrameProvider.frames {
    let currentTimeString = "\(Date().timeIntervalSince1970))"
    let layerID = frame + mapOverlay.name + currentTimeString
    let sourceID = frame + mapOverlay.name + "source" + currentTimeString
    let url = urlTemplate.replacingOccurrences(of: "{t}", with: frame)
    
    var source = RasterSource()
    source.tiles = [url]
    source.tileSize = Double(tileSize)
    sources.append(source)
    
    var rasterLayer = RasterLayer(id: layerID)
    rasterLayer.source = sourceID
    rasterLayer.rasterOpacity = .constant(Double(initialAlpha))
    rasterLayers.append(rasterLayer)
  }

  guard tileFrameProvider.frames.count != 0 else { return }
    
  for (index, source) in self.sources.enumerated() {
        if let layer = self.rasterLayers[safeIndex: index] {
            try? self.mapView.mapboxMap.style.addSource(source, id: layer.source ?? "")
            try? self.mapView.mapboxMap.style.addLayer(layer, layerPosition: .above("building-line"))
        }
    }
}
swiftyboi
  • 2,965
  • 4
  • 25
  • 52

1 Answers1

0

Looks like it is a Mapbox bug. My app doesn't use Metal and disabling Metal API Validation stops the crash from happening. enter image description here

swiftyboi
  • 2,965
  • 4
  • 25
  • 52
  • 1
    It's not really a crash, it's an developer assertion. You can see `man MetalValidation` for pointers on how to change the validation error mode from assert to logging. But yes, if you aren't calling Metal directly, this is a Mapbox bug and you should probably make a ticker for them. – JustSomeGuy Mar 16 '22 at 00:25
  • @swiftyboi I can confirm this is an issue on the side of Mapbox. I work on the rendering engine of the map and would be happy help you with this case. There's at least one known edge case that's not handled yet: if the image size is 1x1 pixel. Make sure that the image in the raster source contains data and it's larger than that. And feel free to open a ticket in the following repo: https://github.com/mapbox/mapbox-maps-ios/ – Endanke Aug 23 '22 at 11:19