Repository navigation
HEVC recovery crashes native core in NVIDIA MFT callback; async encoder shutdown is missing #570
Description
Activity
- added a commit that references this issue
on Sep 21, 2026 Candidate lifecycle fix committed as 66d5d62 on integration branch and carried into PR #566. Retains IMFActivate; explicitly shuts down the asynchronous transform before releasing D3D resources; polls the event queue with a stop-aware wait so joining cannot depend on a future driver event; clears stale texture handle on restart.
Validation on RTX 4090: 20 idle start/stop cycles and 10 active HEVC encode/decode/FLV cycles passed. H.264 round trip passed. These do not prove crash elimination under long recovery stress. The patched lifecycle build is not yet installed: current shell is behind its close guard, and automatic review denied forced termination. User has been asked to dismiss the dialog. #569 sustained receiver validation remains failed; do not close either issue based on these bounded tests.
Installed validation, 2026-09-21: native 66d5d62 (PR equivalent 86a561c), SHA256 3D99E00A86AFD424FD368CA33952C0E47AEC72F7B56138CC23015D9CDB5024C7, RTX 4090, HEVC 1920x1080 60 fps 10 Mbps, real Zoom meeting (9 participants), Speaker + Slides scene. No builds or heavy tests during this window.
The continuous run lasted approximately 6 min 26 sec (10:32:26-10:38:52 local), with 0 RTMP retries and actual YouTube public playback at 1920x1080@60. This is NOT a release acceptance pass:
- After a deliberate clean stop/start, the compressed queue overflowed at 10:39:08 (60 queued chunks, 1,294,910 bytes). The supervisor restarted the sender once. Native core stayed running through this recovery. The lifecycle fix addresses the observed shutdown defect but does not resolve transport backpressure.
- Between the 10:33 baseline and pre-restart snapshot, render deadline misses increased 79 -> 1328 and skipped slots 12 -> 16. Program buffer had 78 underruns, 62 overflows and 13 deadline misses at the end (cumulative since engine start).
- In an isolated 78-second interval, program-buffer underruns rose 57 -> 78 and overflows 41 -> 62.
- YouTube viewer counters rose 2/1132 -> 8/5710 dropped frames over 76 seconds. Browser playback drops and CVP render misses are distinct measurements; neither proves the other caused it.
Evidence: local artifacts/youtube-preparing-20260921/lifecycle-soak-{5min,before-restart,after-restart}.json, lifecycle-soak-start.json, and media-core.log. PR #566 remains draft; #569 and #570 remain open. Next transport investigation must account for startup/restart backpressure as well as long-run behavior, and preserve real audio plus requested video quality.
Validation update, 2026-09-21: the prior activation-shutdown fix was insufficient. Installed native 84beebb crashed again after a live HEVC stop, following a GPU NV12-map timeout. Dump corevideo-native.exe.52704.dmp shows a driver callback in nvEncMFThevcx entering a destroyed critical section (RtlEnterCriticalSection / null access), on an RTWorkQ callback thread. The shell recovered the core; this is a failed stability run, not acceptance.
The follow-up now stops input, joins CVP's event reader, sends END_OF_STREAM and COMMAND_DRAIN, consumes HaveOutput until DrainComplete, then sends END_STREAMING before activation shutdown and D3D release. A 1.5-second drain deadline falls back to flush and is logged; real driver calls themselves are not guaranteed bounded. Microsoft's async-MFT lifecycle documentation requires the asynchronous drain completion event rather than treating a joined client thread as completion of driver work.
Hardware validation: 20 idle HEVC starts/stops plus 10 active encode/decode/mux cycles passed with drain_complete=1. The first five installed 1080p60 HEVC start/stop cycles all completed drain and restarted, generations 2 through 6, with the same native process alive. Further live verification continues; keep this issue open until merge and acceptance.
- added a commit that references this issue
on Sep 21, 2026 Additional installed verification after the drain fix and #574: a continuous 30m16s HEVC run completed without a native process replacement or sender restart. At 13:36:52 EDT, normal stream stop reported
shutdown drain_complete=1 hr=0x00000000; the sender settled tostoppedwith no warning and retryCount 0. Native PID 46964 and shell PID 52528 remained alive, and subsequent API snapshots were fresh. The app was left open. This adds sustained-run/stop evidence to the earlier hardware and short restart tests, not a fleet-wide crash guarantee. All 19 checks passed on PR head db876ba.Backlog reconciliation after PR #566 merged at 793c452 and beta-2026-09-21-793c452 shipped. Closing the specific asynchronous MFT shutdown defect: explicit drain/shutdown is merged; 20 idle hardware cycles, 10 active encode/decode cycles, repeated installed restarts, and the 30m16s installed soak plus normal drain/stop are documented above. Exact merged main passed 1,149 native tests and application CI. This does not close #513 or guarantee absence of unrelated driver failures.
Native core crashed during HEVC sender recovery at 2026-09-21 10:20:12, exception 0xc0000005. Full dump retained locally: corevideo-native.exe.15800.dmp. CDB exception stack is ntdll!RtlpWaitOnCriticalSection -> nvEncMFThevcx -> RTWorkQ serial work queue callback. Do not infer private NVIDIA function names from export-relative symbols.
Inspection: MediaFoundationGpuVideoEncoder::stop joins its own event loop then releases GPU resources and COM encoder references without IMFShutdown/IMFActivate::ShutdownObject. Microsoft requires explicit shutdown of async MFTs before release. The encoder loop also uses blocking GetEvent, which can hold shutdown indefinitely without another event.
Related live test #569 triggered repeated backpressure recoveries, exposing the lifecycle defect. Fix explicit MFT shutdown before resource release and ensure the event worker exits without waiting indefinitely. Validate repeated HEVC start/stop and fault recovery. This is not proof that all failures inside the driver are caused by this omission.