Skip to content

fix(mp4/box): 修 CreateContainerBox/WriteTo 的 typed-nil 子 box panic#3

Merged
eanfs merged 2 commits into
developfrom
feature/trailer-fmp4-bypass
May 22, 2026
Merged

fix(mp4/box): 修 CreateContainerBox/WriteTo 的 typed-nil 子 box panic#3
eanfs merged 2 commits into
developfrom
feature/trailer-fmp4-bypass

Conversation

@eanfs

@eanfs eanfs commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

box.goCreateContainerBox / WriteToreflect.ValueOf(child).IsNil() 判空 —— 对「纯 nil 接口」(zero Value)和值类型会 panic。新增 isNil() helper 安全判定:纯 nil 接口、可空 Kind(指针/接口/slice 等)的 nil 值返回 true,其余返回 false。新增 box_test.go 单测覆盖。

这是 2026-05-21-trailer-zero-rewrite plan 阶段 B 执行时发现的独立 bug 修复。

关于阶段 B

执行阶段 B 时核实发现:monibuca 当前 fMP4 muxer 不写 init moov box(WriteInitSegment fragment 分支只写 ftyp,WriteMoov/MakeMoov 在 fMP4 路径零调用),产物 [ftyp][moof][mdat]...[mfra] 非合法 fMP4。plan 阶段 B「fMP4 moov 已在头部」的前提不成立 —— fMP4 完整实现需先补全 muxer(新增 B0),工作量大于 plan 设想。

阶段 A 已把 trailer 磁盘 IO 降 99%+,fMP4 边际收益较小,B0/B1/B3/B4 暂停留作后续专项(plan 已标注修订)。本 PR 仅含 B2 这个独立 panic 修复 + plan 修订说明。

Test plan

  • box 包单测 3/3 PASS(TestIsNil / TestCreateContainerBox_SkipsNilChildren / TestWriteTo_SkipsNil)
  • plugin/mp4/... darwin + linux 编译通过
  • 对 progressive MP4 路径零行为变化(正常 box 走指针分支,与原 IsNil() 等价)

eanfs added 2 commits May 21, 2026 18:21
box.go 的 CreateContainerBox / WriteTo 用 reflect.ValueOf(child).IsNil()
判空, 对「纯 nil 接口」(zero Value)和值类型会 panic。加 isNil() helper
安全判定: 纯 nil 接口 / 可空 Kind 的 nil 值返回 true, 其余返回 false。
加 box_test.go 单测覆盖。

trailer 零重写 plan 阶段 B 的 B2;fMP4 完整实现(需先补 muxer init moov)
暂停, 本 panic 修复独立可用。
执行阶段 B 时发现: monibuca fMP4 muxer 不写 init moov box, 产物
[ftyp][moof][mdat]...[mfra] 非合法 fMP4。plan 阶段 B "moov 已在头部"
前提不成立。本次仅完成 B2(box typed-nil panic 修复), B0/B1/B3/B4
(fMP4 完整实现)暂停, 标注为后续专项。
@eanfs
eanfs merged commit 6e541f5 into develop May 22, 2026
1 check failed
@eanfs
eanfs deleted the feature/trailer-fmp4-bypass branch May 22, 2026 02:02
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