Skip to content

Fix subtitle post-processing error losing original exception#13256

Merged
TobiGr merged 1 commit intoTeamNewPipe:devfrom
pierreeurope:fix/ttml-postprocessing-error-reporting
Feb 19, 2026
Merged

Fix subtitle post-processing error losing original exception#13256
TobiGr merged 1 commit intoTeamNewPipe:devfrom
pierreeurope:fix/ttml-postprocessing-error-reporting

Conversation

@pierreeurope
Copy link
Contributor

What is this?

This PR fixes the error reporting in subtitle (TTML → SRT) post-processing, addressing #13206.

The problem

When subtitle post-processing fails, users see a generic error:

RuntimeException: post-processing algorithm returned 8

This happens because TtmlConverter.process() catches all exceptions and returns opaque integer error codes (1 for IOException, 8 for anything else). Postprocessing.run() then wraps this code into a new RuntimeException, discarding the original exception and its stack trace entirely.

This makes it impossible to diagnose the actual root cause of subtitle download failures.

The fix

Instead of catching exceptions and returning error codes, the exceptions are now propagated properly:

  • IOExceptions are re-thrown directly
  • Other exceptions are wrapped in an IOException with the original exception preserved as the cause

This allows DownloadMission.doPostprocessing() to catch and report the actual error with its full stack trace, which will appear in user crash reports.

Why this approach

The process() method's return-code-based error handling was designed for cases where partial recovery is possible (like in muxers). For TtmlConverter, there is no partial recovery — a parse failure is fatal. Propagating the exception is more idiomatic and preserves diagnostic information that is critical for debugging issues like #13206.

APK testing

This is a minimal, low-risk change to error handling only — no behavioral change when conversion succeeds.

Previously, TtmlConverter.process() caught all exceptions during TTML
to SRT conversion and returned opaque error codes (1 for IOException,
8 for other exceptions). These error codes were then wrapped by
Postprocessing.run() into a generic RuntimeException with the message
'post-processing algorithm returned N', losing the original exception
and its stack trace.

This made it impossible for users and developers to diagnose the root
cause of subtitle download failures, as reported in TeamNewPipe#13206.

Now, IOExceptions are re-thrown directly, and other exceptions are
wrapped in an IOException with the original exception as the cause.
This allows DownloadMission.doPostprocessing() to properly catch and
report the actual error, including the full stack trace in the crash
report.

Fixes TeamNewPipe#13206

Signed-off-by: pierreeurope <[email protected]>
@github-actions github-actions bot added the size/small PRs with less than 50 changed lines label Feb 16, 2026
@TobiGr TobiGr self-requested a review February 16, 2026 13:31
@TobiGr TobiGr added downloader Issue is related to the downloader subtitles Related to displaying, converting or saving subtitles or captions. bug Issue is related to a bug template missing The bug/feature template is missing (e.g. the used app does not support issue templates) labels Feb 16, 2026
Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Thank you

@TobiGr TobiGr merged commit 01e77e2 into TeamNewPipe:dev Feb 19, 2026
6 checks passed
@TobiGr TobiGr mentioned this pull request Feb 28, 2026
1 task
@Riglav
Copy link

Riglav commented Mar 9, 2026

From nightly

Exception

  • User Action: download post-processing
  • Request: https://www.youtube.com/watch?v=8NGNYGnKjQ8 [ {type=subtitles format=Timed Text Markup Language language=en autoGenerated=true} ]
  • Content Country: RU
  • Content Language: ru-RU
  • App Language: ru_RU
  • Service: YouTube
  • Timestamp: 2026-03-09T18:43:41.968+03:00
  • Package: org.schabi.newpipe.nightly
  • Service: YouTube
  • Version: 0.28.4-1129-202603090155
  • OS: Linux Android 5.1 - 22
Crash log

java.io.IOException: TTML to SRT conversion failed
	at us.shandian.giga.postprocessing.M4aNoDash.process(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:1753)
	at us.shandian.giga.postprocessing.Postprocessing.run(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:160)
	at us.shandian.giga.get.DownloadMission$$ExternalSyntheticLambda0.run(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:36)
	at java.lang.Thread.run(Thread.java:831)
Caused by: java.lang.IllegalArgumentException: Bad position (limit 991): -66
	at java.nio.Buffer.positionImpl(Buffer.java:351)
	at java.nio.Buffer.position(Buffer.java:345)
	at java.nio.charset.CharsetDecoderICU.setPosition(CharsetDecoderICU.java:205)
	at java.nio.charset.CharsetDecoderICU.decodeLoop(CharsetDecoderICU.java:154)
	at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:306)
	at org.jsoup.internal.SimpleStreamReader.read(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:26)
	at org.jsoup.parser.CharacterReader.bufferUp(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:49)
	at org.jsoup.parser.CharacterReader.current(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:1)
	at org.jsoup.parser.TokeniserState$1.read(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:1)
	at org.jsoup.parser.TreeBuilder.runParser(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:53)
	at org.jsoup.helper.DataUtil.parseInputStream(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:31)
	at org.schabi.newpipe.streams.SrtFromTtmlWriter.build(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:47)
	at us.shandian.giga.postprocessing.M4aNoDash.process(r8-map-id-4ee8491925e9f63582909ec8638e4e6c1187dcc9623dded94e561aebbf291d9e:1736)
	... 3 more


@Riglav
Copy link

Riglav commented Mar 9, 2026

And from the new version.

Exception

  • User Action: download post-processing
  • Request: https://www.youtube.com/watch?v=8NGNYGnKjQ8 [ {type=subtitles format=Timed Text Markup Language language=en autoGenerated=true} ]
  • Content Country: US
  • Content Language: en-
  • App Language: ru
  • Service: YouTube
  • Timestamp: 2026-03-09T18:50:39.845+03:00
  • Package: org.schabi.newpipe
  • Service: YouTube
  • Version: 0.28.4
  • OS: Linux Android 5.1 - 22
Crash log

java.io.IOException: TTML to SRT conversion failed
	at us.shandian.giga.postprocessing.M4aNoDash.process(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:1753)
	at us.shandian.giga.postprocessing.Postprocessing.run(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:160)
	at us.shandian.giga.get.DownloadMission$$ExternalSyntheticLambda0.run(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:36)
	at java.lang.Thread.run(Thread.java:831)
Caused by: java.lang.IllegalArgumentException: Bad position (limit 991): -66
	at java.nio.Buffer.positionImpl(Buffer.java:351)
	at java.nio.Buffer.position(Buffer.java:345)
	at java.nio.charset.CharsetDecoderICU.setPosition(CharsetDecoderICU.java:205)
	at java.nio.charset.CharsetDecoderICU.decodeLoop(CharsetDecoderICU.java:154)
	at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:306)
	at org.jsoup.internal.SimpleStreamReader.read(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:26)
	at org.jsoup.parser.CharacterReader.bufferUp(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:49)
	at org.jsoup.parser.CharacterReader.current(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:1)
	at org.jsoup.parser.TokeniserState$1.read(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:1)
	at org.jsoup.parser.TreeBuilder.runParser(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:53)
	at org.jsoup.helper.DataUtil.parseInputStream(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:31)
	at org.schabi.newpipe.streams.SrtFromTtmlWriter.build(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:47)
	at us.shandian.giga.postprocessing.M4aNoDash.process(r8-map-id-ce0307bac2c3f16e8dc2f832773b0599f307ee51c82b5550b73911d8a6d3ce37:1736)
	... 3 more


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue is related to a bug downloader Issue is related to the downloader size/small PRs with less than 50 changed lines subtitles Related to displaying, converting or saving subtitles or captions. template missing The bug/feature template is missing (e.g. the used app does not support issue templates)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants