chore: Harden MJPEG frame parsing and stream startup - #2927
Merged
Conversation
KazuCocoa
approved these changes
Jul 30, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 30, 2026
## [12.1.2](v12.1.1...v12.1.2) (2026-07-30) ### Miscellaneous Chores * Harden MJPEG frame parsing and stream startup ([#2927](#2927)) ([36bf6a0](36bf6a0))
Contributor
|
🎉 This PR is included in version 12.1.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backports fixes from appium/appium-uiautomator2-driver#1028,
which ported this driver's MJPEG helpers (#2915) and hardened them further. Applies
the same fixes here:
MjpegFrameParser#appendChunkno longer uses a stray JPEG SOI marker found in acontinuation chunk as the copy start offset. Since the chunk is continuing an
already-open frame, it always belongs there in full — a SOI marker inside it can
only belong to the next frame, so using it as the start truncated the tail of
the current frame.
MjpegFrameParser#emitFramenow pushes only the bytes actually written(
buffer.subarray(0, bytesWritten)) instead of the whole pre-allocated buffer,so a frame no longer leaks trailing zero bytes when
Content-Lengthoverstatesthe real frame size. Frame state is also reset after emitting, so a later stray
chunk can't be appended onto a buffer already pushed downstream.
MJpegStream#start()now rejects immediately if the connection closes beforeany frame arrives, instead of waiting out the full server timeout.
MJpegStream#start()now callsstop()before rethrowing on failure, so afailed start doesn't leak the underlying HTTP stream/pipes.
MjpegFrameParseris now exported so it can be unit tested directly.