Problem
The MediaMuxer inside SimpleMp4FrameMuxer is constructed eagerly when the replay video encoder is created (CloseGuard.open registers a guard expecting release()), but release() was only reachable on the happy path. Two cases leaked it:
ReplayCache.createVideoOf returned early when frameCount == 0 (frames exist but none could be encoded) without calling encoder?.release().
SimpleMp4FrameMuxer.release() called muxer.stop() before muxer.release(). MediaMuxer.stop() throws IllegalStateException if the muxer was never started (no frame ever muxed, so INFO_OUTPUT_FORMAT_CHANGED never fired), so muxer.release() was skipped. The exception was then swallowed by SimpleVideoEncoder.release()'s catch block.
Surfaces as a CloseGuard warning: A resource was acquired at attached stack trace but never released ... Explicit termination method 'release' not called, pointing at the MediaMuxer constructor in SimpleMp4FrameMuxer. It is a latent native resource leak whenever a replay segment ends up with zero encodable frames.
Fix
Guard stop() behind the started flag so release() is always reached, and release the encoder on the no-frames return path.
Fixed in PR #5583.
Problem
The
MediaMuxerinsideSimpleMp4FrameMuxeris constructed eagerly when the replay video encoder is created (CloseGuard.openregisters a guard expectingrelease()), butrelease()was only reachable on the happy path. Two cases leaked it:ReplayCache.createVideoOfreturned early whenframeCount == 0(frames exist but none could be encoded) without callingencoder?.release().SimpleMp4FrameMuxer.release()calledmuxer.stop()beforemuxer.release().MediaMuxer.stop()throwsIllegalStateExceptionif the muxer was never started (no frame ever muxed, soINFO_OUTPUT_FORMAT_CHANGEDnever fired), somuxer.release()was skipped. The exception was then swallowed bySimpleVideoEncoder.release()'s catch block.Surfaces as a CloseGuard warning:
A resource was acquired at attached stack trace but never released ... Explicit termination method 'release' not called, pointing at theMediaMuxerconstructor inSimpleMp4FrameMuxer. It is a latent native resource leak whenever a replay segment ends up with zero encodable frames.Fix
Guard
stop()behind thestartedflag sorelease()is always reached, and release the encoder on the no-frames return path.Fixed in PR #5583.