Skip to content

fix(ffmpeg): serialize native FFmpegKit sessions - #1153

Open
3316891527 wants to merge 2 commits into
AAswordman:devfrom
3316891527:fix/ffmpeg-serialize-native-sessions
Open

fix(ffmpeg): serialize native FFmpegKit sessions#1153
3316891527 wants to merge 2 commits into
AAswordman:devfrom
3316891527:fix/ffmpeg-serialize-native-sessions

Conversation

@3316891527

@3316891527 3316891527 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

变更说明 / Description

视频剪辑闪退的崩溃栈在 libavcodec.so 对已销毁 mutex 再次 pthread_mutex_destroy,Android 17 FORTIFY 会直接 SIGABRT。FFmpegKit 自带 native 不保证并发 session 安全,这次把所有 execute/probe 收到一把进程锁里。

背景与动机 / Context and motivation

Fixes #1151. tombstone 四次都是:
FORTIFY: pthread_mutex_destroy called on a destroyed mutex,下一帧在 APK 自带 libavcodec.so。FFmpegKit 官方有同样的并发崩溃记录(arthenica/ffmpeg-kit#120)。应用里 ffmpeg_executeffmpeg_infoffmpeg_convertfile_info 探针和媒体转码都会直接进 native,没有排队。

改动范围 / Changes

  • FFmpegUtilsynchronized 串行化 FFmpegKit.execute / FFprobeKit.getMediaInformation
  • StandardFFmpegTool 不再直接调 FFmpegKit;转码成功后不再重复 probe 一次
  • 新增 FFmpegUtilTest 覆盖 scale filter 转义
  • 不重编 native libavcodec.so

兼容性与风险 / Compatibility and risks

重叠的 FFmpeg/FFprobe 会排队而不是并行,剪辑时间可能变长。这不修 native 里的双重 destroy 本身;若单 session 内部仍然会 abort,需要换 FFmpegKit 构建。

关联 Issue / Related issue

Fixes #1151

验证方式 / Verification

检查或命令:
- FFmpegUtilTest
- fork 上触发 android-tests.yml、android-build.yml (assembleDebug)

环境与变体:
- 本地没有 Android SDK,未跑 Gradle
- 未在 Android 17 真机重现视频剪辑
结果:
- 应用层再没有直接 FFmpegKit.execute / FFprobeKit.getMediaInformation
- 真机剪辑:未跑

检查清单 / Checklist

  • 已记录可复现验证和未运行项原因
  • 目标分支为 dev
  • 工作流已在工作分支上触发
  • diff 无无关/临时/敏感内容

Fixes AAswordman#1151. FFmpegKit's bundled libavcodec can abort on Android 17 when overlapping execute/probe calls destroy the same pthread mutex twice. Route all native sessions through one process lock.
FFprobeKit.getMediaInformation returns MediaInformationSession, not FFprobeSession. Keep the original two-backslash scale filter string so Kotlin compiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant