Device view: should the agent produce JPEG frames, and with what encoder?

未关闭
#455 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
冷清
技术栈
dart, flutter, go
领域
mobile, testing-qa

调研方向

Read the device view hub's probe.screenshot handling and the Dart agent's screenshot capture path, then compare the listed encoding options. The issue asks for a design decision and physical-device measurements before choosing; completion means selecting an approach based on PNG versus JPEG size, encode time, and Wi-Fi frame rate.

由索引模型根据 Issue 内容生成。

描述

Question

The device view hub asks the agent for JPEG frames (probe.screenshot with format: "jpeg", quality), but the Dart agent can only produce PNG: dart:ui offers ImageByteFormat.png, rawRgba and rawStraightRgba, no JPEG. Today the hub therefore falls back to PNG and reports caps.jpeg as false. Should the agent gain a JPEG encoder, and if so, which kind?

What a JPEG saves (measured on the host, not on a device)

Same frames, converted with sips (macOS), at 603x1311:

Frame JPEG (q60) PNG Ratio
photographic 41 KiB 474 KiB 11.5x
UI screenshot 28 KiB 87 KiB 3.1x

Typical app screens sit between the two. Over USB or local Wi-Fi the PNG size is tolerable; it matters on a slow link and for the rate the hub can sustain. The WebKit decode spike (#448) shows the viewer side is not a bottleneck either way (JPEG decode 3-6 ms).

Options

  1. package:image (pure Dart). Current version 4.12.0 (published 2026-10-11, pub.dev), MIT licence, null-safe, supports every platform, depends on archive (^4.5.0, which depends on path and posix). The agent today depends on the Flutter SDK only, so this adds two third-party packages to every app that includes the agent, even though the agent is a dev dependency. Cost on the device: the frame must be read as raw RGBA (toByteData(rawRgba), about 3.2 MB at 603x1311) and encoded in Dart on the UI isolate or a helper isolate, which is CPU on the device being tested and can disturb the timing of the app under test. Not measured yet; it needs a device run.
  2. A native channel (a small platform plugin per platform: UIImage.jpegData on iOS, Bitmap.compress on Android). Fast and uses the platform encoder, but the agent currently ships no native plugin code, so this means a federated plugin, native build files in the user's app, and per-platform maintenance. It also breaks the "add one Dart dependency" install story.
  3. Do nothing in the agent; encode on the host. Keep PNG between agent and CLI and re-encode to JPEG in the hub (Go standard library image/jpeg). The viewer gets small frames, the device does no extra work, and nothing changes in the agent. The device-to-host link still carries the PNG, which is the part a slow link would feel.
  4. Lower the PNG cost instead: capture at the scale the viewer needs (already done by the scale parameter), which cuts bytes roughly with the pixel count.

Recommendation (to decide)

Option 3 first (no agent change, works with every released agent) plus option 4, which already exists. Revisit option 1 only if a measurement on a physical phone over Wi-Fi shows the PNG link is the limit; option 2 only if option 1's CPU cost disturbs tests. No code is proposed here.

To measure before choosing

  • PNG vs JPEG size and encode time on a physical phone at the pane's usual scale.
  • Frame rate the hub sustains over Wi-Fi with PNG at scale 0.5 and 1.0.
主要语言
Go
星标
6
派生
3
平均合并
6 小时 28 分钟
30 天内合并 PR
362

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AlphaWaveSystems/flutter-probe 的其他 Issue

查看 AlphaWaveSystems/flutter-probe 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。