在低端机型上有很多崩溃XR、XS、XSMAX等,最近升级到4.5.98更严重了
【版本信息】
4.5.98
【平台信息】
iOS 原生
【预期的表现】
正常运行
【实际的情况】
崩溃 Crashed: com.apple.main-thread 0 libpag 0x12d2d8 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 483948 1 libpag 0x12cb64 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 482040 2 libpag 0x12dcc0 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 486484 3 libpag 0x1319cc pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 502112 4 libpag 0xeee68 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 228860 5 libpag 0xeca48 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 219612 6 libpag 0x64bb8 pag::PAGSurface::draw(pag::RenderCache*, std::__1::shared_ptrpag::Graphic, pag::BackendSemaphore*, bool) + 676 7 libpag 0x6325c pag::PAGPlayer::flushInternal(pag::BackendSemaphore*) + 152 8 libpag 0x63190 pag::PAGPlayer::flush() + 52 9 libpag 0x59980 pag::PAGFont::~PAGFont() + 50328 10 libpag 0x59918 pag::PAGFont::~PAGFont() + 50224 11 libpag 0x60e38 pag::PAGDecoder::renderFrame(std::__1::shared_ptrpag::PAGComposition, int, std::__1::shared_ptrpag::BitmapBuffer) + 172 12 libpag 0x60888 pag::PAGDecoder::readFrameInternal(int, std::__1::shared_ptrpag::BitmapBuffer) + 596 13 libpag 0x60b04 pag::PAGDecoder::readFrame(int, __CVBuffer*) + 100 14 libpag 0xaee8c pag::PathData::~PathData() + 23196 15 libpag 0xb1b48 pag::PathData::~PathData() + 34648 16 libpag 0xc407c pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 53264 17 libpag 0xe677c pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 194320 18 libpag 0xc3f08 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 52892 19 libpag 0x133f74 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 511752 20 libpag 0x1320b4 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 503880 21 libpag 0xeedc4 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 228696 22 libpag 0xeca48 pag::PAGVideoDecoder::SetMaxHardwareDecoderCount(int) + 219612 23 libpag 0x64bb8 pag::PAGSurface::draw(pag::RenderCache*, std::__1::shared_ptrpag::Graphic, pag::BackendSemaphore*, bool) + 676 24 libpag 0x6325c pag::PAGPlayer::flushInternal(pag::BackendSemaphore*) + 152 25 libpag 0x63190 pag::PAGPlayer::flush() + 52 26 libpag 0x54ed4 pag::PAGFont::~PAGFont() + 31212 27 libpag 0x49354 pag::MergePathsElement::type() const + 79408 28 libpag 0x5e6a0 pag::PAG::SDKVersion() + 5432 29 libpag 0x5e1a0 pag::PAG::SDKVersion() + 4152 30 libpag 0x5db4c pag::PAG::SDKVersion() + 2532 31 libpag 0x5ed9c pag::PAG::SDKVersion() + 7220 32 QuartzCore 0x29328 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 820 33 QuartzCore 0x392d0 display_timer_callback(__CFMachPort*, void*, long, void*) + 372 34 CoreFoundation 0x79d54 __CFMachPortPerform + 176 35 CoreFoundation 0x97148 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 60 36 CoreFoundation 0x98e38 __CFRunLoopDoSource1 + 520 37 CoreFoundation 0x7a658 __CFRunLoopRun + 2240 38 CoreFoundation 0x7f3ec CFRunLoopRunSpecific + 612 39 GraphicsServices 0x135c GSEventRunModal + 164 40 UIKitCore 0x39cf58 -[UIApplication _run] + 888 41 UIKitCore 0x39cbbc UIApplicationMain + 340 42 Lita 0x10eef08 main + 33 (AppDelegate.swift:33) 43 ??? 0x1ef44cdec (缺失)
感谢反馈,我们已用 4.5.98 官方发布的 dSYM 对崩溃堆栈完成了符号化,定位到根因,修复 PR 见 Tencent/tgfx#1590。
符号化后的真实堆栈
堆栈中的 SetMaxHardwareDecoderCount、PAGFont::~PAGFont 等符号是静态库 strip 后符号错位所致,真实调用链为:
0 tgfx::HardwareRenderTargetProxy::onMakeTexture() HardwareRenderTargetProxy.cpp:40 <- 崩溃点
1 tgfx::DefaultTextureProxy::getTextureView()
2 tgfx::TextureRenderTargetProxy::getRenderTarget()
3 tgfx::OpsRenderTask::execute()
4 tgfx::DrawingManager::flush()
5 tgfx::Context::flush()
6 pag::PAGSurface::draw() PAGSurface.cpp:233
7 pag::PAGPlayer::flush()
9 pag::CompositionReader::renderFrame() CompositionReader.cpp:72
11 pag::PAGDecoder::renderFrame() PAGDecoder.cpp:250
12 pag::PAGDecoder::readFrameInternal()
13 pag::PAGDecoder::readFrame() PAGDecoder.cpp:189
14 pag::DiskSequenceReader::onMakeBuffer() <- 磁盘缓存序列帧解码
15 pag::SequenceReader::readBuffer()
17 tgfx::Task::wait() <- 主线程同步等待解码任务
19 tgfx::TextureUploadTask::onMakeResource()
21 tgfx::DrawingManager::flush()
23 pag::PAGSurface::draw() <- 外层 PAGView 渲染
25 pag::PAGPlayer::flush()
26 -[PAGView onAnimationFlush:]
32 CADisplayLink
即:PAGView 播放含序列帧的 PAG 文件时,渲染主线程在 flush 中同步等待磁盘缓存序列帧解码,解码内部经由 PAGDecoder 的离屏渲染链路(EAGL/OpenGL ES + HardwareBuffer)绘制帧,最终在 tgfx 内部崩溃。
根因
tgfx 的 HardwareRenderTargetProxy::onMakeTexture() 中存在空指针解引用:
auto renderTarget = RenderTarget::MakeFrom(context, hardwareBuffer, _sampleCount);
if (renderTarget == nullptr) {
LOGE("... Failed to create the render target!"); // 只记录了日志
}
return renderTarget->asTextureView(); // <- renderTarget 为 nullptr 时崩溃
RenderTarget::MakeFrom() 在纹理导入失败时返回 nullptr。在 XR/XS/XS MAX 等机型上,内存压力较大时 EAGL 从 HardwareBuffer(CVPixelBuffer)导入纹理(CVOpenGLTextureCacheCreateTextureFromImage)会失败,随即触发崩溃。该问题自 4.5.84 起的版本均存在,并非 4.5.98 新引入;升级后“更严重”可能与素材中带序列帧的 PAG 使用量增加、磁盘缓存重建更频繁有关。
修复
Tencent/tgfx#1590 在错误分支补上 return nullptr,与兄弟实现 TextureRenderTargetProxy 的处理保持一致。修复后纹理导入失败会沿调用链安全降级:该帧渲染被跳过、readFrame() 返回失败,由已有的解码失败恢复逻辑接管,不再崩溃。tgfx 合并后我们会更新依赖并在下个 libpag 版本发布。
非常感谢🙏,我是从4.4.35 升级到 4.5.98的,前几天发现崩溃较多,又回退到了4.4.35,随后我们再升级到最新版本再观察一下,感谢!
从堆栈看,崩溃点与 #2374 一致(PAGVideoDecoder::SetMaxHardwareDecoderCount 相关路径),且同样集中在 iPhone 老机型上。#2374 中已有多个业务反馈类似崩溃,我们后续排查会一并跟进,此 issue 先与 #2374 关联跟踪,感谢反馈。
预计什么时候有新的修复包呢?4.5.98版本有快两个月未更新了
7. 预计什么时候有新的修复包呢?4.5.98版本有快两个月未更新了
本周会更新一个版本
- 预计什么时候有新的修复包呢?4.5.98版本有快两个月未更新了
本周会更新一个版本
不是说这周更新一个版本嘛?难道是周末吗?
今天发,请您再耐心等等
抱歉,本次发布需要顺延到本周末。
原因是 CocoaPods 官方本周将 trunk 置为只读(read-only test week,为 12 月 2 日的永久只读做预演),期间不接受新的 podspec。官方说明见: https://blog.cocoapods.org/CocoaPods-Specs-Repo/
等 trunk 恢复接收后,我们会第一时间完成新版本的发布。
给大家带来的不便非常抱歉,也感谢各位的耐心等待。
新版本已发布,您可以更新到最新版本试试,有问题请反馈