Skip to content

chore: Harden MJPEG frame parsing and stream startup - #2927

Merged
mykola-mokhnach merged 1 commit into
appium:masterfrom
mykola-mokhnach:sync-mjpeg
Jul 30, 2026
Merged

chore: Harden MJPEG frame parsing and stream startup#2927
mykola-mokhnach merged 1 commit into
appium:masterfrom
mykola-mokhnach:sync-mjpeg

Conversation

@mykola-mokhnach

Copy link
Copy Markdown
Contributor

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#appendChunk no longer uses a stray JPEG SOI marker found in a
    continuation 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#emitFrame now 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-Length overstates
    the 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 before
    any frame arrives, instead of waiting out the full server timeout.
  • MJpegStream#start() now calls stop() before rethrowing on failure, so a
    failed start doesn't leak the underlying HTTP stream/pipes.
  • MjpegFrameParser is now exported so it can be unit tested directly.

@mykola-mokhnach
mykola-mokhnach merged commit 36bf6a0 into appium:master Jul 30, 2026
7 checks passed
@mykola-mokhnach
mykola-mokhnach deleted the sync-mjpeg branch July 30, 2026 16:56
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))
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 12.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants