feat(device): use WebP for device screenshot producers - #2859
Closed
quanruzhuoxiu wants to merge 3 commits into
Closed
feat(device): use WebP for device screenshot producers#2859quanruzhuoxiu wants to merge 3 commits into
quanruzhuoxiu wants to merge 3 commits into
Conversation
quanruzhuoxiu
force-pushed
the
feat/webp-report-consumers
branch
from
July 23, 2026 09:50
88e097e to
675a785
Compare
quanruzhuoxiu
force-pushed
the
feat/webp-device-producers-v2
branch
2 times, most recently
from
July 23, 2026 09:55
87f794f to
688cb95
Compare
quanruzhuoxiu
force-pushed
the
feat/webp-report-consumers
branch
from
July 23, 2026 11:56
675a785 to
92530ad
Compare
quanruzhuoxiu
force-pushed
the
feat/webp-device-producers-v2
branch
from
July 23, 2026 11:56
688cb95 to
a55dbdf
Compare
quanruzhuoxiu
force-pushed
the
feat/webp-report-consumers
branch
from
July 24, 2026 07:45
92530ad to
ebfa101
Compare
quanruzhuoxiu
force-pushed
the
feat/webp-device-producers-v2
branch
from
July 24, 2026 07:47
a55dbdf to
e83a7ea
Compare
Collaborator
Author
This was referenced Aug 26, 2026
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
The reusable PNG/JPEG-to-WebP implementation lives in
packages/shared/src/img/transform.ts:canonicalizeScreenshotBase64()validates the actual image bytes and callsconvertImgBufferToWebp(), which usesSharp.webp({ quality: 90, effort: 1 })in Node. Device adapters call this shared boundary unless the source already provides a JPEG stream that should be preserved.WebP generation paths
packages/android/src/device.tscalls sharedcanonicalizeScreenshotBase64(), which encodes with Sharppackages/android/src/scrcpy-manager.tsdecodes H.264 to raw RGB with FFmpeg, then encodes once withSharp.webp({ quality: 90, effort: 1 })packages/ios/src/device.tscalls sharedcanonicalizeScreenshotBase64(), which encodes with Sharppackages/computer/src/device.tscalls sharedcanonicalizeScreenshotBase64(), which encodes with Sharppackages/computer/src/device.tscalls sharedcanonicalizeScreenshotBase64(), which encodes with Sharppackages/computer/src/rdp/device.tsusespreserveJpeg: true: JPEG remains byte-for-byte JPEG, while PNG is encoded as WebPStack
Validation
pnpm exec nx run-many -t build -p @midscene/android @midscene/ios @midscene/computerpnpm --filter @midscene/android test(16 files, 325 tests passed)pnpm --filter @midscene/ios test(12 files, 146 tests passed)pnpm --filter @midscene/computer test(13 files, 89 tests passed)pnpm run type-check:testspnpm run lint