Streaming sample access gives other tracks the first track's defaults
perfloop-oss/mp4ff · Identity Collision
https://perfloop.ai/t/oss/case_en5wq2qy6d
Verdict
VALIDATED BY A DIFFERENT CHANGE · settled 2026-11-12
What happened: The check passes with this change.
Hypothesis
Streaming callers can receive another track's sample metadata and shortened sample data. This requires a multi-track init segment, unequal track defaults, and a field omitted from the fragment's track header and sample run. It can happen even when the fragment contains only the second track. Consumer prevalence is unmeasured.
StreamFile.processFragment binds fragmentSampleAccessor.trex to sf.Moov.Mvex.Trex. MvexBox.AddChild defines that field as the first trex, while GetTrex(trackID) selects the matching one. The sample getters select the correct traf by TrackID but all pass the shared first-track trex to AddSampleDefaultValues. That binding erases track identity specifically when choosing inherited duration, size and flags. Explicit overrides mask the affected fields rather than making the shared binding correct.
Stored property prop_f28fv99jfq found a counterexample during a ten-second-budget native Go fuzz search. Its returned corpus file and a smaller normalized replay are retained. The deterministic checkProperty rerun at revision 702346275b141f91c229e5a759822d70d883d55c exited 1 with `go test ./mp4 -run '^FuzzPerfloopStreamTrackDefaults$' -count=1`. In the reduced replay, a two-track init precedes one sample of track 2. All five reading APIs return duration 1, size 1 and flags 33554432, instead of duration 6, size 2 and flags 65536. DecodeFile followed by GetFullSamples(GetTrex(2)) agrees with the constructed sample. The original replay also shows that an explicit duration remains correct while inherited size and flags are wrong.
The supported consumer operation is the documented per-track SampleAccessor API, reinforced by TestSingleSampleAccess's existing differential contract. The independent Case should first replay the saved failure, then check unequal defaults with reordered trex boxes, one- and two-track fragments, omitted fields, explicit overrides and first-sample flags across the accessor operations. Agreement with the matching-track reference is the confirming signal. The sampled search did not exhaust those combinations and establishes no production frequency.
The refreshed open work at https://github.com/Eyevinn/mp4ff/pull/657 implements AAC configuration parsing and descriptor construction. Its implementation does not change streaming default binding. Prior repairs for grouped sample reads and oversized bulk-read destinations do not repair this track association.
Change to test: Resolve inherited sample defaults using the requested track's identity throughout SampleAccessor, rather than binding every track to the first trex. Preserve tfhd, trun and first-sample-flag precedence, including behavior without init defaults.
Where it lives
perfloop-oss/mp4ff · mp4/stream.go
Evidence
The check passes with this change: `For the pinned bear-640x360-av_frag.mp4 and prog_8s_dec_dashinit.mp4 files, all five streaming sample-reading APIs return audio durations of 1001 ticks in each of the six Shaka fragments and 3000 ticks in each of the two mp4ff fragments, whereas matching-track DecodeFile/GetFullSamples and the audio trex report 1024 ticks for both files.`
Verification: no defect found.
Timeline
2026-11-01· Case opened2026-11-12· Case closed