EXC_BAD_ACCESS in generateMipmapsForTexture: nil texture during render while MtlGpuUploader is uploading

未关闭
#2,453 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
ios, swift

调研方向

Start with the frames the report names: MetalView.draw(_:) at MetalView.swift:75 and MapView.updateFromDisplayLink(displayLink:) at MapView.swift:741, plus the setCustomRasterSourceTileData calls that add the CustomRasterSource layers. The root cause sits in MapboxCoreMaps and the MtlGpuUploader thread, so a fix needs a reproducer and a Metal-level explanation of why the texture is nil. Done means a repro that no longer crashes, or a maintainer-confirmed diagnosis of the nil texture.

由索引模型根据 Issue 内容生成。

描述

auto-triaged bug :beetle: p1

Environment

  • Maps SDK: 11.34.1 (MapboxCoreMaps 11.34.1, MapboxCommon 24.34.1), but also reproduced on 11.33.0 and 11.32.2
  • iOS: 27.2
  • Device: iPhone 18 Pro (AGX G19 GPU)
  • Xcode: 27.2, debugger attached, Metal GPU Frame Capture enabled. Also reproduced in release build with no debugger attached.

Observed behavior and steps to reproduce

EXC_BAD_ACCESS (code=1, address=0x248) on the main thread in -[AGXG19FamilyBlitContext generateMipmapsForTexture:], called from MapboxCoreMaps during a normal frame. The texture passed to generateMipmapsForTexture: is nil. It happened ~300 ms after the style finished loading, with ~2.7 GB still available to the process, so it isn't an allocation failure under memory pressure.

Several CustomRasterSource raster layers (tileSize 256 × display scale, set via setCustomRasterSourceTileData) are added to our map after the style loads, and it seems to only happen when one of these layers are enabled.

Crashed thread

MapboxCoreMaps 11.34.1 (arm64)
UUID: 9FFE71C2-5754-37B7-993B-968869BF026C
Load address: 0x1078a8000

thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x248)
frame #0: AGXMetalG19P -[AGXG19FamilyBlitContext generateMipmapsForTexture:] + 104
frame #1: GPUToolsCapture -[CaptureMTLBlitCommandEncoder generateMipmapsForTexture:] + 116
frame #2: MapboxCoreMaps 0x107dd32e8 MapboxCoreMaps + 0x52b2e8
frame #3: MapboxCoreMaps 0x107e90e90 MapboxCoreMaps + 0x5e8e90
frame #4: MapboxCoreMaps 0x10803edf0 MapboxCoreMaps + 0x796df0
frame #5: MapboxCoreMaps 0x108085fd8 MapboxCoreMaps + 0x7ddfd8
frame #6: MapboxCoreMaps 0x10804ec34 MapboxCoreMaps + 0x7a6c34
frame #7: MapboxCoreMaps 0x10804473c MapboxCoreMaps + 0x79c73c
frame #8: MapboxCoreMaps 0x107c1fc18 MapboxCoreMaps + 0x377c18
frame #9: MapboxCoreMaps 0x107c12adc MapboxCoreMaps + 0x36aadc
frame #11: MapboxMaps MetalView.draw(_:) (MetalView.swift:75)
frame #13: MetalKit -[MTKView draw] + 148
frame #14: MapboxMaps MapView.updateFromDisplayLink(displayLink:) (MapView.swift:741)

Uploader thread at crash time

thread #37, name = 'com.mapbox.common.MtlGpuUploader'
frame #0: AGXMetalG19P AGX::AppleCompressionGen2::Compressor<…>::compressMacroblock(…) + 344
frame #1: AGXMetalG19P AGX::Texture<…>::processCompressedRegion2D<…>(…) + 1908
frame #2: AGXMetalG19P AGX::Texture<…>::writeRegionCommon(…) + 1672
frame #3: AGXMetalG19P -[AGXG19FamilyTexture replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:] + 96
frame #4: IOGPU -[IOGPUMetalTexture replaceRegion:mipmapLevel:withBytes:bytesPerRow:] + 56

主要语言
Swift
星标
601
派生
198
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mapbox/mapbox-maps-ios 的其他 Issue

查看 mapbox/mapbox-maps-ios 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。