Give the probe hop an injectable dispatcher, so an escaped coroutine error fails the test that caused it #66
Closed
opened 2026-08-24 20:46:13 +00:00 by JMR-dev
·
1 comment
No Branch/Tag Specified
main
fix/102-picker-back-press-overshoot
fix/268-saf-picker-determinism
feat/ogg-vorbis-libvorbis
feat/expedited-conversion-work
fix/gate-cache-in-worktrees
chore/gate-runs-shellcheck
test/publish-delete-arm-real-provider
docs/e8-instrumented-coverage
docs/api37-carrier-count-drift
docs/e7-second-constraint
test/publish-to-a-real-saf-destination
fix/api37-report-match-line
fix/api37-task-snapshot-crash
test/join-failure-message-on-device
docs/e2e-read-findings-e7
test/cancelling-a-running-export
test/reattach-to-a-running-job
test/content-uri-reaches-ffmpeg
fix/launcher-wiring-waits-for-the-pick
fix/cancel-tests-need-a-slower-encode
test/cancelling-a-running-join
test/cancelling-a-running-session
test/notification-cancel-action
test/ffmpeg-progress-is-observed
test/fallback-asserts-the-path
test/flac-and-opus-assert-their-format
docs/e2e-read-findings
docs/wave4-coverage-numbers
fix/injectable-startup-sweep-scope
test/session-outcome-seam
test/launcher-callback-identity
test/theme-follows-system-dark
test/audio-drop-arm
fix/rotation-waits-for-recreation
fix/convert-guards-on-ready
test/retry-save-mime
test/hardware-progress-reaches-workmanager
test/ffprobe-mapping-seam
test/device-codec-enumeration-seam
test/unknown-container-row
test/null-message-fallbacks
test/cancel-reaches-workmanager
docs/coverage-wave3-recovery
test/concat-engine-seam
docs/coverage-wave3
test/mediaprobe-merge-seam
test/adaptive-shell-wiring
test/aac-audio-args
test/notification-progress-text
test/media3-muxer-guard
test/hardware-fallback-and-cancellation
test/unprobeable-join-clip
test/one-branch-outcomes
test/foreground-type-regimes
fix/bound-wedge-diagnostics
docs/coverage-wave2
test/screen-wiring
test/viewmodel-setters
test/join-state-mapping
test/conversion-state-mapping
test/dedupe-user-messages
fix/restore-stack-merges
test/refused-jobs
test/concatworker-failure-arms
test/container-capabilities-audio
test/readspec-enum-fallbacks
test/outputpublisher-seams
test/mediaprobe-track-seam
test/outputpublisher-partial-branches
test/fake-provider-scaffolding
docs/coverage-read-findings
chore/gitignore-kotlin
test/bound-the-hangs
docs/coverage-remeasure
ci/baseline-counter-precision
fix/invalid-suggestion-chip
ci/wedged-leg-report
fix/reattachment-overwrites-pick
test/theme-live-branches
fix/failed-save-retry
fix/empty-composition-crash
ci/advisory-failure-report
docs/seven-run-counts
test/release-permission-guard
ci/build-workflow-permissions
docs/api37-point-release
docs/benchmark-populate-path
fix/dead-assertion-probe-test
ci/actionlint
test/device-codecs-encode-consequence
fix/sdkmanager-pipefail
docs/readme-restart-claim
fix/saf-picker-root-discovery
fix/probe-dispatcher-seam
test/media3engine-mime-tables
test/mediaprobe-pure-helpers
fix/codec-vocabulary-drift
docs/robolectric-rationale-correction
docs/api37-advisory-counts
test/r38-8-saf-e2e
test/r38-7-join-states
test/r38-6-conversion-states
test/r38-5-state-seam
fix/jacoco-robolectric-coverage
docs/instrumented-tests-correction
test/r38-2-filecard
test/r38-4-advanced-picker
test/r38-3-pickers
tools/file-issue-script
tools/api-37-emulator
fix/review-app-gaps
docs/review-corrections
No results found.
Labels
Clear labels
above-cut
accessibility
backlog
bug
confirmed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
plausible
question
sev:high
sev:low
sev:medium
wontfix
Worked autonomously overnight: local, JVM-verifiable, no product decision
Barrier affecting people with disabilities
Held for manual review: product/UX call, CI/workflow, hardware, or unverifiable here
Something isn't working
Reviewer demonstrated the defect
Improvements or additions to documentation
This issue or pull request already exists
New feature or request
Good for newcomers
Extra attention is needed
This doesn't seem right
Reviewer could not fully demonstrate it; treat as unproven
Further information is requested
High severity
Low severity
Medium severity
This will not be worked on
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: JMR-dev/LibreMediaConverter#66
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Found while implementing #57. The workaround landed there; this is the fix it defers to, plus a gap the workaround introduces.
The escaped error
ConversionViewModelProbeFailureTest.an OutOfMemoryError is not swallowedproves an OOM raisedinside the probe is rethrown rather than reported as an unreadable file.
ConversionViewModel.onInputPickedruns the probe in
viewModelScope.launch { withContext(Dispatchers.IO) { ... } }with no exceptionhandler, by design — the ViewModel's KDoc says a real OOM should reach the thread's handler and take
the process down.
On the JVM there is no such handler. kotlinx-coroutines-test installs a process-wide
CoroutineExceptionHandleronce and never removes it, so the error is collected and handed towhichever
runTeststarts next. Every Compose rule is arunTest.It surfaced during #57 as two different test classes failing on two consecutive runs of identical,
green code, with a message naming neither the test nor the error's origin. The throw happens on a
real
Dispatchers.IOthread after the state assertion that ends the test causing it, so deliverycan land arbitrarily late.
What #57 did, and what it costs
createDrainedComposeRule()inapp/src/test/java/org/libremediaconverter/EscapedCoroutineErrors.ktdrains the collector at rule-construction time.
@Beforecannot (the rule'srunTestwraps it) and@BeforeClasscannot (Robolectric runs it outside the sandbox classloader). It works, and everyCompose test in
src/testnow depends on it.The gap:
runCatching { runTest {} }discards whatever it finds. It cannot distinguish the oneknown deposit from a genuinely unexpected escaped error, so a future coroutine failure that nobody
asserted on becomes silent rather than failing a random later test. That trades a loud, misleading
symptom for a quiet one. Acceptable as a stopgap because there is exactly one known depositor;
not acceptable as the permanent answer, which is why this ticket exists.
The fix
Give the probe hop an injectable dispatcher, exactly as
ConversionViewModel's constructor alreadydoes for
cleanupDispatcher:With the hop on a test dispatcher, the error has somewhere to land: it fails the test that caused it,
by name, and nothing leaks into the process-wide collector. Then
createDrainedComposeRule()can losethe drain and become a thin alias — or go away entirely.
Done means
ConversionViewModelProbeFailureTestasserts the OOM at the callrather than only through the resulting state.
drainEscapedCoroutineErrors()is removed, or reduced to something that no longer swallowsunknown errors.
returns — a fix for a heisenbug that cannot be shown to reappear has not been shown to work.
./gradlew :app:assembleDebug :app:testDebugUnitTest :app:compileDebugAndroidTestKotlin :app:ktlintCheck :app:detekt :app:lintDebug --continueTracked on the board as Backlog, not Ready for Development, and the reason is a sequencing constraint rather than a gap in the evidence:
This is blocked until the #52 chain lands.
createDrainedComposeRule()is what every Compose test insrc/testcurrently starts from — #57, and #58, #59, #60, #62, #63 as they arrive. Landing the dispatcher seam first would mean those tests need rewriting onto it mid-flight, and landing it while they are in flight would conflict onConversionViewModel's constructor.Order: finish #58–#63, then this, then delete the drain.
The evidence and the done-state are already clear enough for Ready for Development — the flake was observed twice on identical green code, the cause is traced, and the acceptance is written. It is only the ordering that holds it.