Skip to content

fix(android): name the codec error when video compression fails (#428) - #429

Merged
numandev1 merged 1 commit into
numandev1:mainfrom
oeddyo:fix/android-codec-failure-message
Oct 26, 2026
Merged

numandev1 merged 1 commit into
numandev1:mainfrom
oeddyo:fix/android-codec-failure-message

Conversation

@oeddyo

@oeddyo oeddyo commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #428.

On Android, a MediaCodec.CodecException thrown during Video.compress usually has an empty message, so the promise rejects with nothing useful (CodecException: or just start failed). Every codec failure looks the same from JS. Before #424 that is how the Exynos NO_MEMORY failures reached us: empty, with the cause only in logcat.

CodecException.getDiagnosticInfo() already names the error (android.media.MediaCodec.error_neg_12 is NO_MEMORY). This PR appends it to the failure message at the two catch sites that wrap codec work in Compressor.start:

before: ""                 after: "android.media.MediaCodec.error_neg_12"
before: "start failed"     after: "start failed: android.media.MediaCodec.error_neg_12"

Messages from other exceptions are unchanged. The finishMovie() catch only touches the muxer, so it is left alone.

Changelog

[ANDROID] [FIXED] - Video compression failures now name the MediaCodec error instead of an empty message

Test Plan

  • Ran local JS PR gate: yarn test:pr (passes, 13/13)
  • yarn build:android (BUILD SUCCESSFUL)
  • Ran yarn test:harness:android on an arm64 API emulator: 8/9 passed. The one failure, compresses a real image fixture through the exported Image API (expected 16 to be less than or equal to 8), fails the same way on unmodified main with the same emulator, so it is unrelated. The harness has no Video.compress failure case, so this is a regression check only.

The CodecException branch was not runtime-verified: I couldn't force a real CodecException on an emulator. The diagnosticInfo format comes from AOSP MediaCodec.CodecException ("android.media.MediaCodec.error_" + (errorCode < 0 ? "neg_" : "") + Math.abs(errorCode)), available since API 21 (minSdk is 24).

🤖 Generated with Claude Code

…ndev1#428)

A MediaCodec.CodecException usually has an empty message, so the
rejection carried nothing. Append its diagnosticInfo, which names the
codec error (e.g. android.media.MediaCodec.error_neg_12 for NO_MEMORY).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow error-formatting change addresses the reported issue without altering compression behavior, and no blocking issues remain.

No open issues 🎉

What changed in this PR

Improves Android video compression errors for #428 by including codec diagnostics in failure messages, making failures such as Exynos NO_MEMORY identifiable from JavaScript.

Changes:

  • Adds a shared formatter that includes MediaCodec.CodecException.diagnosticInfo at both codec-work catch sites.
  • Preserves non-codec exception messages and leaves compression logic unchanged.
  • Records the fix in the triage log.

The codec-exception branch was not runtime-verified, as noted in the test plan.

File Description
TRIAGE.md Records #428 and its diagnostic-message fix.
android/​src/​main/​java/​com/​reactnativecompressor/​Video/​VideoCompressor/​compressor/​Compressor.kt Adds codec diagnostics to both relevant failure paths.

Review effort: Balanced

@numandev1
numandev1 merged commit e49b969 into numandev1:main Oct 26, 2026
4 checks passed
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.

[Android] Video.compress rejects with an empty message on MediaCodec.CodecException

3 participants