The guard against "MP4 for everything" has never fired, so weakening it would restore the bug silently #171

Closed
opened 2026-09-02 02:14:59 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-09-02 02:14:59 +00:00 (Migrated from github.com)

The guard against "MP4 for everything" is itself unguarded

Media3Engine.buildTransformer (app/src/main/java/org/libremediaconverter/convert/Media3Engine.kt:135-138):

val muxerFactory = requireNotNull(Media3Muxers.factoryFor(plan.container)) {
    "Media3 cannot mux ${plan.container}; this job should have routed to FFmpeg."
}

JaCoCo: Media3Engine$buildTransformer$3 is 4 lines / 4 branches at 0% — the message lambda has
never been built, so the guard has never fired.

This is the guard against the exact historical defect Media3Muxers' own KDoc names: the router
claimed five containers while the engine silently wrote MP4 for all of them.

Media3Muxers.factoryFor returns null for fourteen containers
(app/src/main/java/org/libremediaconverter/convert/Media3Muxers.kt), and nothing drives a plan
carrying one of them, so weakening this line would restore that bug unnoticed.

The work

New test beside Media3EngineEmptyCompositionTest.kt, reusing its harness shape — including its
two disciplines: first assert CopyPlanner.plan(...) really produced the plan the test needs
(:67-69), and keep the assertFalse(failure is CancellationException) guard so an unresumed
continuation cannot read as a pass.

Drive Media3Engine.transcode with a WEBM plan; assert the failure is IllegalArgumentException
and that its message names the container.

Acceptance, and the trap in it

Mutation: replace requireNotNull(...) with ?: DefaultMuxer.Factory().

This mutation does not make the export succeed. It makes transcode proceed into a real
Transformer run that fails some other way under Robolectric, which a bare runCatching catches just
as happily. So the assertion must pin the exact type and the message — otherwise the test passes
with the guard deleted, which is precisely the vacuous case this wave exists to avoid.

## The guard against "MP4 for everything" is itself unguarded `Media3Engine.buildTransformer` (`app/src/main/java/org/libremediaconverter/convert/Media3Engine.kt:135-138`): ```kotlin val muxerFactory = requireNotNull(Media3Muxers.factoryFor(plan.container)) { "Media3 cannot mux ${plan.container}; this job should have routed to FFmpeg." } ``` JaCoCo: `Media3Engine$buildTransformer$3` is **4 lines / 4 branches at 0%** — the message lambda has never been built, so the guard has never fired. This is the guard against the exact historical defect `Media3Muxers`' own KDoc names: *the router claimed five containers while the engine silently wrote MP4 for all of them.* `Media3Muxers.factoryFor` returns `null` for fourteen containers (`app/src/main/java/org/libremediaconverter/convert/Media3Muxers.kt`), and nothing drives a plan carrying one of them, so weakening this line would restore that bug unnoticed. ## The work New test beside `Media3EngineEmptyCompositionTest.kt`, reusing its harness shape — including its two disciplines: first assert `CopyPlanner.plan(...)` really produced the plan the test needs (`:67-69`), and keep the `assertFalse(failure is CancellationException)` guard so an unresumed continuation cannot read as a pass. Drive `Media3Engine.transcode` with a WEBM plan; assert the failure is `IllegalArgumentException` **and that its message names the container**. ## Acceptance, and the trap in it Mutation: replace `requireNotNull(...)` with `?: DefaultMuxer.Factory()`. **This mutation does not make the export succeed.** It makes `transcode` proceed into a real Transformer run that fails some other way under Robolectric, which a bare `runCatching` catches just as happily. So the assertion must pin the exact type *and* the message — otherwise the test passes with the guard deleted, which is precisely the vacuous case this wave exists to avoid.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMediaConverter#171