libpag icon indicating copy to clipboard operation
libpag copied to clipboard

libpag 4.5.27 iOS 崩溃

Open yongge007 opened this issue 7 months ago • 1 comments

【版本信息】

4.5.27

【平台信息】

iOS 原生

【崩溃堆栈】

Code Type: ARM-64 Parent Process: [1]

Date/Time: 2026-04-17 03:29:42 +0000 OS Version: iPhone OS 26.3 (23D127) Report Version: 104

Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0x2c Crashed Thread: 0

Thread 0 Crashed: 0 libpag 0x000000010698ede4 0x106858000 + 1273316 1 libpag 0x000000010699110c 0x106858000 + 1282316 2 libpag 0x000000010699119c 0x106858000 + 1282460 3 libpag 0x000000010685f588 0x106858000 + 30088 4 libpag 0x00000001068baf4c 0x106858000 + 405324 5 libpag 0x000000010685f588 0x106858000 + 30088 6 libpag 0x00000001068ca6cc 0x106858000 + 468684 7 libpag 0x000000010685f588 0x106858000 + 30088 8 libobjc.A.dylib 0x000000018c31e1f8 0x18c314000 + 41464 9 libobjc.A.dylib 0x000000018c319f20 0x18c314000 + 24352 10 libobjc.A.dylib 0x000000018c3194a4 0x18c314000 + 21668 11 libpag 0x00000001068b95e8 0x106858000 + 398824 12 libpag 0x00000001068b9838 0x106858000 + 399416 13 libobjc.A.dylib 0x000000018c31e1f8 0x18c314000 + 41464 14 libobjc.A.dylib 0x000000018c319f20 0x18c314000 + 24352 15 libobjc.A.dylib 0x000000018c3194a4 0x18c314000 + 21668 16 UIKitCore 0x0000000194e398f8 0x194dd2000 + 424184 17 UIKitCore 0x0000000194e39364 0x194dd2000 + 422756

yongge007 avatar Apr 17 '26 03:04 yongge007

你好,已经用 4.5.27 的 dSYM 符号化了堆栈,完整调用链如下:

0  tgfx::GLState::reset()  (GLState.cpp:224)              ← 真正崩溃点
1  GLGPU::resetGLState() / _state->reset()                 (栈帧 1-2 dSYM 误标到
2  同上                                                       EAGLHardwareTexture::MakeFrom,
                                                              Release inline 后行号映射不准)
3  trampoline
4  GPUDrawable::getDevice()                                (GPUDrawable.mm:72)
5  trampoline
6  PAGSurface::readPixels(...)                             (PAGSurface.cpp:177)
7  trampoline
8-10  libobjc release/dispatch
11-12  应用层入口(dSYM 误标到 PAGImageView::setComposition / setCurrentFrame,
       实际可能是其它方法或调用点被 inline)
16-17  UIKit runloop

崩溃地址 0x2c 是访问 GLState 实例某成员(unordered_map 内部偏移)时段错误,说明 _state 已经是悬挂指针/野指针——底层 GLGPU 或它持有的 GLState 已经被释放。

完整调用路径还原:

应用代码
  → [PAGSurfaceImpl makeSnapshot] 或 [copyPixelsTo:rowBytes:] 或类似截图 API
  → PAGSurface::readPixels
  → drawable->getDevice() / device->lockContext()
  → tgfx::Surface::readPixels
  → context->flushAndSubmit() → context->submit()
  → GLCommandQueue::submit
  → gpu->resetGLState() → _state->reset()    ← 崩溃

最可能的根因是 readPixels 流程中底层 GPU device 已被释放或正在被释放。常见触发场景:

  1. 在 view/composition 销毁过程中(dealloc 链里)调用了 PAGSurface 截图或读像素相关 API;
  2. 多线程同时操作同一个 PAGImageView/PAGSurface(一侧 release/setComposition,另一侧 makeSnapshot/readPixels 等)。

为精确定位,麻烦补充:

  1. 应用是否调用过 [PAGSurface makeSnapshot]、[copyPixelsTo:rowBytes:]、或 PAGImageView 的 currentImage 等截图/读像素 API?
  2. 崩溃是否发生在 view 销毁、切换 PAG 文件或应用进入后台等时机?
  3. 是否多线程同时访问同一个 PAGImageView/PAGSurface 实例?
  4. 是否能稳定复现?如果能,麻烦提供大致复现步骤。

另外建议升级到最新版本(v4.5.52 / v4.4.53)后再观察。最新版本对 iOS 平台 GPU 资源生命周期有多处加固,例如 4630f06c "Fix crash caused by null layerTexture in EAGLWindow destructor" 等修复均不在 4.5.27 范围内。

leiyue123 avatar May 13 '26 09:05 leiyue123