Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

perf(desktop): 优化截图启动与导出性能

DavidShend3f96fe0a19e
diff --git a/apps/desktop/scripts/benchmark-region-screenshot.mjs b/apps/desktop/scripts/benchmark-region-screenshot.mjs
new file mode 100644
index 0000000000..e820868913
--- /dev/null
+++ b/apps/desktop/scripts/benchmark-region-screenshot.mjs
@@ -0,0 +1,125 @@
+#!/usr/bin/env node
+// Explicit performance/E2E run, outside unit tier. Uses the isolated ui-page
+// Electron host and real product source; never starts Cindy or touches user data.
+// node apps/desktop/scripts/benchmark-region-screenshot.mjs --baseline=HEAD --samples=30
+import assert from 'node:assert/strict';
+import { execFileSync } from 'node:child_process';
+import { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises';
+import { createRequire } from 'node:module';
+import os from 'node:os';
+import path from 'node:path';
+import { _electron } from 'playwright-core';
+import { buildPage, desktop, root } from './ui-page/build.mjs';
+import { adhocPage } from './ui-page/registry.mjs';
+import { pageResponse, origin } from './ui-page/run.mjs';
+
+const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3);
+const samples = Number(option('samples') ?? 30), baseline = option('baseline') ?? 'HEAD';
+assert.ok(Number.isInteger(samples) && samples >= 5 && samples <= 200);
+const git = args => execFileSync('git', args, { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
+const baselineSha = git(['rev-parse', '--verify', `${baseline}^{commit}`]).trim();
+const files = git(['ls-tree', '-r', '--name-only', baselineSha, '--', 'apps/desktop/src/renderer/features/region-screenshot']).trim().split('\n');
+const old = new Map(files.map(file => [path.normalize(path.join(root, file)), file]));
+const contents = new Map();
+const overlay = {
+ resolve: () => undefined,
+ has: file => old.has(path.normalize(file)),
+ get(file) {
+ const name = old.get(path.normalize(file));
+ if (!name) return undefined;
+ if (!contents.has(name)) contents.set(name, git(['show', `${baselineSha}:${name}`]));
+ return contents.get(name);
+ },
+};
+const fixture = adhocPage(path.join(desktop, 'scripts/fixtures/region-capture/performance.tsx'));
+const bundles = { before: await buildPage(fixture, overlay), after: await buildPage(fixture) };
+const temp = await mkdtemp(path.join(os.tmpdir(), 'cindy-screenshot-perf-'));
+const bundleDir = path.join(temp, 'bundle');
+const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => /^(PATH|SYSTEMROOT|WINDIR|TEMP|TMP|TMPDIR|DISPLAY|WAYLAND_DISPLAY|XDG_RUNTIME_DIR|DBUS_SESSION_BUS_ADDRESS|LANG|LC_ALL)$/i.test(key)));
+let app;
+const report = { generatedAt: new Date().toISOString(), baseline: baselineSha, samples, platform: process.platform, arch: process.arch, cpu: os.cpus()[0]?.model,
+ scope: 'Real Electron offscreen renderer (1040x760 DIP, 2x density), synthetic opaque BGRA source at the stated dimensions. Excludes OS capture, native window startup, IPC serialization, clipboard and disk. 3 warmups per batch; alternating before/after batches. First-paint timing includes two animation frames and is sensitive to vsync/GC.', results: [], regression: [] };
+const summary = values => {
+ const sorted = [...values].sort((a, b) => a - b);
+ const middle = sorted.length / 2;
+ return { p50: +((sorted[Math.floor(middle)] + sorted[Math.ceil(middle) - 1]) / 2).toFixed(3), p95: +sorted[Math.ceil(sorted.length * .95) - 1].toFixed(3) };
+};
+try {
+ await mkdir(bundleDir, { recursive: true });
+ await mkdir(path.join(temp, 'evidence'));
+ for (const [name, bundle] of Object.entries(bundles)) {
+ const prefix = `/b/${bundle.bundleDigest.slice(0, 16)}`;
+ for (const [key, file] of bundle.files) {
+ const target = path.join(bundleDir, key.startsWith('/assets/') ? key : `${prefix}${key}`);
+ await mkdir(path.dirname(target), { recursive: true });
+ await writeFile(target, file.body);
+ }
+ for (const theme of ['light', 'dark']) {
+ const document = pageResponse(origin, bundle, { page: 'screenshot-perf', case: 'default', theme, locale: 'en', platform: process.platform, viewport: { width: 1040, height: 760 }, data: {} });
+ await writeFile(path.join(bundleDir, `${name}-${theme}.html`), document.body);
+ }
+ }
+ app = await _electron.launch({ executablePath: createRequire(import.meta.url)('electron'), args: [path.join(desktop, 'scripts/ui-page/electron.cjs')],
+ env: { ...env, CINDY_UI_PROFILE: path.join(temp, 'profile'), CINDY_UI_BUNDLE_DIR: bundleDir,
+ CINDY_UI_EVIDENCE_DIR: path.join(temp, 'evidence'), CINDY_UI_WIDTH: '1040', CINDY_UI_HEIGHT: '760' } });
+ const page = await app.firstWindow();
+ const errors = []; page.on('pageerror', error => errors.push(error.message));
+ report.versions = await app.evaluate(() => ({ electron: process.versions.electron, chrome: process.versions.chrome }));
+ const load = async (side, theme = 'light') => {
+ await page.goto(`${origin}/${side}-${theme}.html`);
+ await page.waitForFunction(() => window.__uiPage?.ready && window.screenshotPerf);
+ };
+ for (const [width, height, scale] of [[1920, 1080, 1], [3840, 2160, 2], [1600, 10000, 2]]) {
+ const values = { before: [], after: [] };
+ // Alternate order to reduce JIT, temperature and background-load bias.
+ for (let batch = 0; batch < 2; batch++) for (const side of batch ? ['after', 'before'] : ['before', 'after']) {
+ await load(side);
+ const count = Math.ceil(samples / 2);
+ for (let i = -3; i < count; i++) {
+ const started = await page.evaluate(([w, h, s]) => window.screenshotPerf.begin(w, h, s), [width, height, scale]);
+ const exportMs = await page.evaluate(() => window.screenshotPerf.export());
+ if (i >= 0 && values[side].length < samples) values[side].push({ ...started, exportMs });
+ }
+ // Canvas probes can switch Chromium's backing store to CPU. Validate only
+ // after the timed batch, then reload before collecting any more samples.
+ await page.evaluate(() => window.screenshotPerf.verify());
+ }
+ const row = { width, height, scale };
+ for (const side of ['before', 'after']) row[side] = {
+ beginSyncMs: summary(values[side].map(v => v.syncMs)), paintedMs: summary(values[side].map(v => v.paintedMs)),
+ exportMs: summary(values[side].map(v => v.exportMs)), frameWrites: values[side][0].frameWrites,
+ raw: values[side],
+ };
+ report.results.push(row);
+ console.log(JSON.stringify({ ...row, before: { ...row.before, raw: undefined }, after: { ...row.after, raw: undefined } }));
+ }
+ for (const theme of ['light', 'dark']) for (const side of ['before', 'after']) {
+ for (const scenario of [
+ { name: 'offset-crop', args: [800, 600, 2, { x: 13, y: 17, width: 200, height: 160 }] },
+ { name: 'alpha-fallback', args: [800, 600, 1, undefined, true] },
+ { name: 'mixed-dpi-resize', args: [800, 600, 2, undefined, false, 1.5] },
+ ]) {
+ await load(side, theme);
+ console.log(`regression ${side}/${theme}/${scenario.name}`);
+ await page.evaluate(args => window.screenshotPerf.begin(...args), scenario.args);
+ await page.evaluate(() => window.screenshotPerf.export());
+ report.regression.push({ theme, side, name: scenario.name, ...await page.evaluate(() => window.screenshotPerf.verify()) });
+ }
+ await load(side, theme);
+ await page.evaluate(() => window.screenshotPerf.begin(800, 600));
+ await page.keyboard.press('r');
+ await page.mouse.move(100, 100); await page.mouse.down(); await page.mouse.move(300, 200); await page.mouse.up();
+ await page.evaluate(() => window.screenshotPerf.export());
+ report.regression.push({ theme, side, name: 'rectangle-annotation', ...await page.evaluate(() => window.screenshotPerf.verify(true)) });
+ }
+ for (const after of report.regression.filter(row => row.side === 'after')) {
+ const before = report.regression.find(row => row.side === 'before' && row.name === after.name && row.theme === after.theme);
+ assert.deepEqual({ ...after, side: undefined }, { ...before, side: undefined }, `Baseline parity: ${after.name}/${after.theme}`);
+ }
+ assert.deepEqual(errors, []);
+ if (option('output')) await writeFile(path.resolve(option('output')), JSON.stringify(report, null, 2) + '\n');
+ console.log(JSON.stringify({ regressions: report.regression, versions: report.versions, passed: true }));
+} finally {
+ await app?.close();
+ await rm(temp, { recursive: true, force: true });
+}
diff --git a/apps/desktop/scripts/fixtures/region-capture/performance.tsx b/apps/desktop/scripts/fixtures/region-capture/performance.tsx
new file mode 100644
index 0000000000..4c40b738d1
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/region-capture/performance.tsx
@@ -0,0 +1,133 @@
+// Explicit benchmark/E2E fixture: actual overlay, Canvas and keyboard export.
+// Only the native bridge is replaced. No captured user pixels or clipboard writes.
+import { flushSync } from 'react-dom';
+import { mountPage } from '../../ui-page/harness';
+import { RegionScreenshotOverlay } from '../../../src/renderer/features/region-screenshot/RegionScreenshotOverlay';
+import type { RegionScreenshotOverlayBridge } from '../../../src/renderer/features/region-screenshot/bridge';
+import type { RegionRect, RegionScreenshotBitmap, RegionScreenshotExport } from '../../../src/shared/regionScreenshot';
+
+let begin: Parameters<RegionScreenshotOverlayBridge['onBegin']>[0];
+let end: () => void;
+let onPaint: () => void = () => {};
+let exported: RegionScreenshotExport | null = null;
+let frame: RegionScreenshotBitmap;
+let selection: RegionRect;
+let viewport: { width: number; height: number };
+let scaleFactor = 1;
+let sequence = 0;
+let exportMs = 0;
+let exportStart = 0;
+let frameWrites = 0;
+const put = CanvasRenderingContext2D.prototype.putImageData;
+CanvasRenderingContext2D.prototype.putImageData = function (...args: Parameters<typeof put>) {
+ if (frame && args[0].width === frame.width && args[0].height === frame.height) frameWrites++;
+ return put.apply(this, args);
+};
+const key = (value: string) => flushSync(() => window.dispatchEvent(new KeyboardEvent('keydown', { key: value, bubbles: true })));
+
+Object.assign(window, { screenshotPerf: {
+ async begin(width: number, height: number, scale = 1, crop?: RegionRect, alpha = false, oversample = 1) {
+ flushSync(() => end?.());
+ const w = Math.round(width * oversample), h = Math.round(height * oversample);
+ const data = new Uint8Array(w * h * 4);
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
+ const i = (y * w + x) * 4;
+ data[i] = (x * 13 + y * 7) % 256;
+ data[i + 1] = (x * 3 + y * 11) % 256;
+ data[i + 2] = (x * 17 + y) % 256;
+ data[i + 3] = alpha ? (x + y) % 256 : 255;
+ }
+ frame = { width: w, height: h, data };
+ viewport = { width: width / scale, height: height / scale };
+ scaleFactor = scale;
+ selection = crop ?? { x: 0, y: 0, width: width / scale, height: height / scale };
+ const painted = new Promise<void>(resolve => { onPaint = resolve; });
+ frameWrites = 0;
+ // Start each sample at the same compositor phase; otherwise faster export
+ // shifts the next sample across a vsync boundary and biases paintedMs.
+ await new Promise(requestAnimationFrame);
+ const start = performance.now();
+ flushSync(() => begin({ token: String(++sequence), locale: 'en', frame,
+ viewport, scaleFactor: scale,
+ windows: [], cursor: null, lastRegion: selection }));
+ const syncMs = performance.now() - start;
+ await painted;
+ const paintedMs = performance.now() - start;
+ key('r');
+ return { syncMs, paintedMs, frameWrites };
+ },
+ async export() {
+ exported = null;
+ exportStart = performance.now();
+ key('Enter');
+ // Failed host export is deliberately retryable, allowing repeated samples
+ // without conflating capture/setup and export timing.
+ await Promise.resolve();
+ if (!exported) throw new Error('Overlay did not export');
+ return exportMs;
+ },
+ verify(annotated = false) {
+ if (!exported) throw new Error('Missing export');
+ const actual = (exported as RegionScreenshotExport).image;
+ if (actual.width !== Math.round(selection.width * scaleFactor)
+ || actual.height !== Math.round(selection.height * scaleFactor)) throw new Error('Export dimensions changed');
+ // Independent Canvas oracle, including scaling and alpha round-tripping.
+ const rgba = new ImageData(frame.width, frame.height);
+ for (let i = 0; i < frame.data.length; i += 4) {
+ rgba.data[i] = frame.data[i + 2]; rgba.data[i + 1] = frame.data[i + 1];
+ rgba.data[i + 2] = frame.data[i]; rgba.data[i + 3] = frame.data[i + 3];
+ }
+ const source = document.createElement('canvas');
+ source.width = frame.width; source.height = frame.height;
+ source.getContext('2d')!.putImageData(rgba, 0, 0);
+ const visible = document.querySelector('canvas')!;
+ if (visible.width !== frame.width || visible.height !== frame.height) throw new Error('Frozen canvas dimensions changed');
+ // The direct export must not mask an empty/stale first paint. Inspect the
+ // actual displayed canvas independently of the in-memory export path.
+ for (const [x, y] of [[0, 0], [13, 17], [frame.width - 1, frame.height - 1]]) {
+ const actualPixel = visible.getContext('2d')!.getImageData(x, y, 1, 1).data;
+ const expectedPixel = source.getContext('2d')!.getImageData(x, y, 1, 1).data;
+ if (actualPixel.some((v, i) => v !== expectedPixel[i])) throw new Error('Frozen canvas pixels changed');
+ }
+ const target = document.createElement('canvas');
+ target.width = actual.width; target.height = actual.height;
+ const ctx = target.getContext('2d', { willReadFrequently: true })!;
+ ctx.imageSmoothingEnabled = true; ctx.imageSmoothingQuality = 'high';
+ const rx = frame.width / viewport.width, ry = frame.height / viewport.height;
+ ctx.drawImage(source, selection.x * rx, selection.y * ry, selection.width * rx, selection.height * ry,
+ 0, 0, actual.width, actual.height);
+ const expected = ctx.getImageData(0, 0, actual.width, actual.height).data;
+ let differences = 0;
+ let firstDifference = '';
+ let hash = 2166136261;
+ // Canvas GPU/CPU unpremultiplication may differ by one colour level at low
+ // alpha (also in the untouched baseline). Compare the represented pixels
+ // in premultiplied space, exactly; opaque screenshots remain byte-exact.
+ const premultiply = (value: number, alpha: number) => Math.round(value * alpha / 255);
+ for (let i = 0; i < expected.length; i += 4) {
+ const alpha = actual.data[i + 3], expectedAlpha = expected[i + 3];
+ const blue = premultiply(actual.data[i], alpha), green = premultiply(actual.data[i + 1], alpha), red = premultiply(actual.data[i + 2], alpha);
+ for (const value of [blue, green, red, alpha]) hash = Math.imul(hash ^ value, 16777619);
+ if (blue !== premultiply(expected[i + 2], expectedAlpha) || green !== premultiply(expected[i + 1], expectedAlpha)
+ || red !== premultiply(expected[i], expectedAlpha) || alpha !== expectedAlpha) {
+ differences++;
+ firstDifference ||= `pixel=${i / 4} actualBGRA=${actual.data.slice(i, i + 4)} expectedRGBA=${expected.slice(i, i + 4)}`;
+ }
+ }
+ // A composited source canvas can use a different resampling backend from
+ // this detached oracle. Scaling is instead checked against the actual old
+ // product's export hash by the runner, never against a copied resampler.
+ const resampled = rx !== scaleFactor || ry !== scaleFactor;
+ if (annotated ? differences === 0 : !resampled && differences !== 0) throw new Error(`Pixel mismatch: ${differences} (annotated=${annotated}); ${firstDifference}`);
+ return { width: actual.width, height: actual.height, oracle: resampled ? 'baseline' : 'canvas', hash: hash >>> 0 };
+ },
+} });
+
+const bridge = {
+ onBegin: (callback) => { begin = callback; return () => {}; },
+ onEnd: (callback) => { end = callback; return () => {}; }, onClear: () => () => {},
+ shellReady() {}, painted() { onPaint(); }, focused() {}, selectionStarted() {}, copyText() {}, cancel() {}, abandon() {},
+ elementsAt: async () => null,
+ exportImage: async (_token, payload) => { exportMs = performance.now() - exportStart; exported = payload; return false; },
+} as RegionScreenshotOverlayBridge;
+void mountPage({ render: () => <RegionScreenshotOverlay bridge={bridge} /> });
diff --git a/apps/desktop/scripts/fixtures/region-capture/ui-page.mjs b/apps/desktop/scripts/fixtures/region-capture/ui-page.mjs
index 5cc66a3a9a..c198967f34 100644
--- a/apps/desktop/scripts/fixtures/region-capture/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/region-capture/ui-page.mjs
@@ -265,13 +265,19 @@ export default {
await (await button('remoteDesktop.actualSize')).click();
// The idle case produces a short image. Give it a smaller editing window
// so a wheel gesture has real overflow to scroll, just as with a long capture.
- if (ui.case === 'idle') await page.setViewportSize({ width: 900, height: 400 });
- const review = page.locator('[tabindex="0"]');
- assert.ok(await review.evaluate(el => el.scrollHeight > el.clientHeight), 'the editor has overflow to review');
- await review.evaluate(el => { el.scrollTop = 0; });
- await review.hover(); await page.mouse.wheel(0, 300);
- await page.waitForFunction(() => document.querySelector('[tabindex="0"]').scrollTop > 0);
- assert.deepEqual(await page.locator('canvas').first().evaluate(el => [el.width, el.height]), dimensions, 'zoom and scrolling do not resample the source');
+ try {
+ if (ui.case === 'idle') await page.setViewportSize({ width: 900, height: 400 });
+ const review = page.locator('[tabindex="0"]');
+ assert.ok(await review.evaluate(el => el.scrollHeight > el.clientHeight), 'the editor has overflow to review');
+ await review.evaluate(el => { el.scrollTop = 0; });
+ await review.hover(); await page.mouse.wheel(0, 300);
+ await page.waitForFunction(() => document.querySelector('[tabindex="0"]').scrollTop > 0);
+ assert.deepEqual(await page.locator('canvas').first().evaluate(el => [el.width, el.height]), dimensions, 'zoom and scrolling do not resample the source');
+ } finally {
+ // Electron reuses this page across variants. A CDP viewport override
+ // survives native setContentSize, poisoning every case after idle.
+ if (ui.case === 'idle') await page.setViewportSize({ width: 900, height: 700 });
+ }
// The shortcut hint follows the host platform: "(Ctrl+S)" on Windows, "(⌘S)" on macOS.
const save = (await ui.t('regionScreenshot.save')).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
await page.getByRole('button', { name: new RegExp(`^${save} \\((Ctrl\\+|⌘)S\\)$`) }).click();
diff --git a/apps/desktop/src/main/region-screenshot/__tests__/windows.test.ts b/apps/desktop/src/main/region-screenshot/__tests__/windows.test.ts
index e999a32aea..cc939192ed 100644
--- a/apps/desktop/src/main/region-screenshot/__tests__/windows.test.ts
+++ b/apps/desktop/src/main/region-screenshot/__tests__/windows.test.ts
@@ -776,6 +776,34 @@ describe('screenshot window lifecycle', () => {
}
});
+ // Performance regression: a cold/unresponsive first display delayed creation
+ // of every later shell by up to 4s. Existing coverage prewarmed both shells.
+ // Unit: two cold displays; the healthy second display must open within one
+ // shared timeout, and cancellation must never send a late BEGIN.
+ it.each([false, true])('prepares cold displays together (cancel=%s)', async (cancel) => {
+ const second = { ...display, id: display.id + 1 };
+ const session = new RegionScreenshotSession({ pool, captures: [{ display, image }, { display: second, image }], helper: {} as SnapshotHelper, windows: [], lastRegions: new Map(), onClosed: vi.fn(), onResult: vi.fn() });
+ const opening = session.open();
+ try {
+ expect(windows).toHaveLength(2);
+ const owner = pool.ensure(second)!.window.webContents;
+ pool.markShellReady(owner, owner.mainFrame);
+ if (cancel) session.close();
+ await vi.advanceTimersByTimeAsync(4000);
+ expect(await opening).toBe(!cancel);
+ const begins = windows[1].webContents.send.mock.calls.filter(([channel]) => channel === 'region-screenshot:begin');
+ expect(begins).toHaveLength(cancel ? 0 : 1);
+ if (!cancel) {
+ session.painted(owner, owner.mainFrame, session.token);
+ expect(windows[1].setOpacity).toHaveBeenLastCalledWith(1);
+ }
+ } finally {
+ session.close();
+ await vi.advanceTimersByTimeAsync(8000);
+ await opening;
+ }
+ });
+
it('keeps screenshots on workArea changes but closes on scale changes', async () => {
const overlay = pool.ensure(display)!;
pool.markShellReady(overlay.window.webContents, overlay.window.webContents.mainFrame);
diff --git a/apps/desktop/src/main/region-screenshot/session.ts b/apps/desktop/src/main/region-screenshot/session.ts
index c714ec03ed..81c5854697 100644
--- a/apps/desktop/src/main/region-screenshot/session.ts
+++ b/apps/desktop/src/main/region-screenshot/session.ts
@@ -131,13 +131,21 @@ export class RegionScreenshotSession {
screen.on('display-metrics-changed', this.onDisplayMetricsChanged);
const locale = getResolvedMainLocale();
const cursor = screen.getCursorScreenPoint();
- for (const capture of this.deps.captures) {
+ // Start all cold shells together: one slow display must not defer creation
+ // (or restart the timeout budget) of every subsequent display. Keep capture
+ // order when registering members, and retain the all-screens geometry barrier.
+ const prepared = await Promise.all(this.deps.captures.map(async (capture) => {
+ if (this.closed) return null;
const overlay = this.deps.pool.ensure(capture.display);
- if (!overlay || !(await this.deps.pool.waitForShell(overlay)) || this.closed) continue;
- if (overlay.window.isDestroyed()) continue;
+ if (!overlay || !(await this.deps.pool.waitForShell(overlay))) return null;
+ return { overlay, capture };
+ }));
+ if (this.closed) return false;
+ for (const member of prepared) {
+ if (!member || member.overlay.window.isDestroyed()) continue;
+ const { overlay, capture } = member;
this.members.set(overlay.window.webContents.id, { overlay, capture, painted: false });
}
- if (this.closed) return false;
if (this.members.size === 0) {
log.warn('no overlay became ready');
this.close();
diff --git a/apps/desktop/src/renderer/features/region-screenshot/RegionScreenshotOverlay.tsx b/apps/desktop/src/renderer/features/region-screenshot/RegionScreenshotOverlay.tsx
index 62d435353a..e5361d27ad 100644
--- a/apps/desktop/src/renderer/features/region-screenshot/RegionScreenshotOverlay.tsx
+++ b/apps/desktop/src/renderer/features/region-screenshot/RegionScreenshotOverlay.tsx
@@ -61,7 +61,7 @@ import {
type ShapeAnnotation,
type TextAnnotation,
} from './annotations';
-import { bitmapToImageData, imageDataToBitmap, type RegionScreenshotOverlayBridge } from './bridge';
+import { bitmapToImageData, cropOpaqueImageDataToBitmap, imageDataToBitmap, type RegionScreenshotOverlayBridge } from './bridge';
import { colorHex, colorRgb, Magnifier, type PixelColor } from './Magnifier';
import { ScreenshotModeBar, ScreenshotStyleBar, ScreenshotToolbar, TOOL_SHORTCUTS, type ScreenshotMode } from './ScreenshotToolbar';
import { SCREENSHOT_INK, SCREENSHOT_OVERLAY, type ScreenshotInk } from './screenshotColors';
@@ -291,13 +291,9 @@ export function RegionScreenshotOverlay({ bridge, imageEditor = false }: { bridg
}
initialCursorRef.current = payload.cursor ?? null;
// 各工具上次用的颜色 / 粗细跨截图保留 (浮层复用, 本次运行内有效)。
- const canvas = frameRef.current;
const frameData = bitmapToImageData(payload.frame);
- if (canvas) {
- canvas.width = payload.frame.width;
- canvas.height = payload.frame.height;
- canvas.getContext('2d')?.putImageData(frameData, 0, 0);
- }
+ // The layout effect writes the frozen frame once after React has mounted
+ // its canvas (including the independent editor's first image).
setSession({
token: payload.token,
scaleFactor: payload.scaleFactor,
@@ -590,19 +586,27 @@ export function RegionScreenshotOverlay({ bridge, imageEditor = false }: { bridg
const source = annotationSource();
if (!mapped || !source) return;
const { crop, output } = mapped;
- const canvas = document.createElement('canvas');
- canvas.width = output.width;
- canvas.height = output.height;
- const ctx = canvas.getContext('2d', { willReadFrequently: true });
- if (!ctx) return;
- ctx.imageSmoothingEnabled = true;
- ctx.imageSmoothingQuality = 'high';
- ctx.drawImage(frame, crop.x, crop.y, crop.width, crop.height, 0, 0, output.width, output.height);
- const sx = output.width / rect.width;
- const sy = output.height / rect.height;
- ctx.setTransform(sx, 0, 0, sy, -rect.x * sx, -rect.y * sy);
- drawAnnotations(ctx, list, source);
- const image = imageDataToBitmap(ctx.getImageData(0, 0, output.width, output.height));
+ // Unedited, pixel-aligned captures already have their pixels in memory.
+ // Avoid an extra canvas backing store and GPU readback. Resizing,
+ // annotations and alpha compositing retain the existing canvas path.
+ let image = list.length === 0 && crop.width === output.width && crop.height === output.height
+ ? cropOpaqueImageDataToBitmap(current.frameData, crop)
+ : null;
+ if (!image) {
+ const canvas = document.createElement('canvas');
+ canvas.width = output.width;
+ canvas.height = output.height;
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
+ if (!ctx) return;
+ ctx.imageSmoothingEnabled = true;
+ ctx.imageSmoothingQuality = 'high';
+ ctx.drawImage(frame, crop.x, crop.y, crop.width, crop.height, 0, 0, output.width, output.height);
+ const sx = output.width / rect.width;
+ const sy = output.height / rect.height;
+ ctx.setTransform(sx, 0, 0, sy, -rect.x * sx, -rect.y * sy);
+ drawAnnotations(ctx, list, source);
+ image = imageDataToBitmap(ctx.getImageData(0, 0, output.width, output.height));
+ }
busyRef.current = true;
setAiMenuOpen(false);
const ok = await bridge
diff --git a/apps/desktop/src/renderer/features/region-screenshot/__tests__/screenshotRendering.test.tsx b/apps/desktop/src/renderer/features/region-screenshot/__tests__/screenshotRendering.test.tsx
index 7868bd5820..43cbdbbf8e 100644
--- a/apps/desktop/src/renderer/features/region-screenshot/__tests__/screenshotRendering.test.tsx
+++ b/apps/desktop/src/renderer/features/region-screenshot/__tests__/screenshotRendering.test.tsx
@@ -3,7 +3,7 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest';
import { ScreenshotErrorBoundary } from '../ScreenshotErrorBoundary';
import { Magnifier } from '../Magnifier';
-import { bitmapToImageData, imageDataToBitmap, type RegionScreenshotOverlayBridge } from '../bridge';
+import { bitmapToImageData, cropOpaqueImageDataToBitmap, imageDataToBitmap, type RegionScreenshotOverlayBridge } from '../bridge';
import { RegionScreenshotOverlay } from '../RegionScreenshotOverlay';
import type { RegionScreenshotHit } from '../../../../shared/regionScreenshot';
import type { RegionCaptureFrame } from '../../../../shared/regionCapture';
@@ -257,6 +257,30 @@ describe('screenshot rendering recovery', () => {
expect(Array.from(imageDataToBitmap(image).data)).toEqual(bytes);
expect(bitmapToImageData({ width: 1, height: 2, data }, image)).not.toBe(image);
});
+ // Unit: the unannotated export fast path must crop rows, swap channels and
+ // leave the source reusable for retries/colour picking. Existing conversion
+ // coverage has no crop or alpha fallback. Minimal input: offset 2-row crop.
+ // Real Canvas parity (alpha, DPI, annotations) is in benchmark-region-screenshot.
+ it('copies only the selected opaque pixels and preserves the frozen image for retries', () => {
+ const data = new Uint8ClampedArray(new ArrayBuffer(4 + 3 * 2 * 4), 4);
+ data.set([1, 2, 3, 255, 4, 5, 6, 255, 7, 8, 9, 255, 10, 11, 12, 255, 13, 14, 15, 255, 16, 17, 18, 255]);
+ const image = { width: 3, height: 2, data } as ImageData;
+ const before = data.slice();
+ const crop = { x: 1, y: 0, width: 2, height: 2 };
+ const result = cropOpaqueImageDataToBitmap(image, crop)!;
+ expect(result).toEqual({ width: 2, height: 2, data: new Uint8Array([6, 5, 4, 255, 9, 8, 7, 255, 15, 14, 13, 255, 18, 17, 16, 255]) });
+ expect(data).toEqual(before);
+ expect(cropOpaqueImageDataToBitmap(image, crop)).toEqual(result);
+ result.data.fill(0);
+ expect(data).toEqual(before);
+ // A transparent pixel outside the selection does not affect this export.
+ data[3] = 0;
+ expect(cropOpaqueImageDataToBitmap(image, crop)).not.toBeNull();
+ data[19] = 127;
+ expect(cropOpaqueImageDataToBitmap(image, crop)).toBeNull();
+ expect(cropOpaqueImageDataToBitmap(image, { ...crop, x: 0.5 })).toBeNull();
+ expect(cropOpaqueImageDataToBitmap(image, { ...crop, x: 2 })).toBeNull();
+ });
it('releases the screen when a child crashes instead of showing the application crash page', () => {
vi.spyOn(console, 'error').mockImplementation(() => {});
const fail = vi.fn();
diff --git a/apps/desktop/src/renderer/features/region-screenshot/bridge.ts b/apps/desktop/src/renderer/features/region-screenshot/bridge.ts
index a06dc525a3..72e7c9e768 100644
--- a/apps/desktop/src/renderer/features/region-screenshot/bridge.ts
+++ b/apps/desktop/src/renderer/features/region-screenshot/bridge.ts
@@ -96,3 +96,26 @@ export function imageDataToBitmap(image: ImageData): RegionScreenshotBitmap {
swapRedBlue(data, data);
return { width: image.width, height: image.height, data: data as Uint8Array<ArrayBuffer> };
}
+
+/** Pixel-exact crop + RGBA → BGRA in one pass, without mutating the frozen frame.
+ * Alpha requires Canvas's premultiplication/rounding; return null for that path.
+ */
+export function cropOpaqueImageDataToBitmap(image: ImageData, crop: RegionRect): RegionScreenshotBitmap | null {
+ const { x, y, width, height } = crop;
+ if (!littleEndian || image.data.byteOffset % 4 !== 0
+ || ![x, y, width, height].every(Number.isInteger)
+ || x < 0 || y < 0 || width <= 0 || height <= 0
+ || x + width > image.width || y + height > image.height) return null;
+ const input = new Uint32Array(image.data.buffer, image.data.byteOffset, image.data.length / 4);
+ const output = new Uint32Array(width * height);
+ for (let row = 0; row < height; row++) {
+ const start = (y + row) * image.width + x;
+ const target = row * width;
+ for (let col = 0; col < width; col++) {
+ const pixel = input[start + col];
+ if (pixel >>> 24 !== 255) return null;
+ output[target + col] = (pixel & 0xff00ff00) | ((pixel & 0xff) << 16) | ((pixel >>> 16) & 0xff);
+ }
+ }
+ return { width, height, data: new Uint8Array(output.buffer) };
+}
diff --git a/docs/acceptance/region-screenshot-blackbox-2026-10-28.json b/docs/acceptance/region-screenshot-blackbox-2026-10-28.json
new file mode 100644
index 0000000000..b008740f63
--- /dev/null
+++ b/docs/acceptance/region-screenshot-blackbox-2026-10-28.json
@@ -0,0 +1,255 @@
+{
+ "generatedAt": "2026-10-28T13:42:44.762Z",
+ "verdict": "passed-with-coverage-limits",
+ "machine": "XD-PC",
+ "platform": "win32-x64",
+ "baseCommit": "7fdb9dd0963794cf46bc026f240d34c568bac03f",
+ "branch": "cindy/quirky-bohr",
+ "workingTree": "dirty: screenshot performance changes",
+ "instance": {
+ "region": "global",
+ "sandbox": "quirky-bohr-34018d",
+ "pid": 56388,
+ "cdpPort": 9337,
+ "readyVerdict": "DESKTOP_DEV_VERDICT=ready"
+ },
+ "displays": [
+ {
+ "x": 0,
+ "y": 0,
+ "width": 2560,
+ "height": 1440,
+ "deviceScaleFactor": 1
+ },
+ {
+ "x": 2560,
+ "y": 0,
+ "width": 2560,
+ "height": 1440,
+ "deviceScaleFactor": 1
+ }
+ ],
+ "method": "Full development app with mock account/task data; real global hotkey, Electron main/preload, OS screen capture, clipboard, native PNG save and pin. Renderer input uses Playwright CDP; native hotkey/dialog input uses computer tools. No screenshot API, capture pixels, clipboard or save-dialog response was replaced.",
+ "screenshotSessions": 8,
+ "cases": [
+ {
+ "name": "真实快捷键与双屏启动",
+ "status": "passed",
+ "detail": "独立 Cindy 实例通过系统热键打开两块 2560×1440 屏幕,浮层尺寸正确。"
+ },
+ {
+ "name": "左屏裁剪与系统复制",
+ "status": "passed",
+ "detail": "580×180;104,400 个像素与独立原生测试图逐个一致,差异为 0。"
+ },
+ {
+ "name": "右屏裁剪与原生 PNG 保存",
+ "status": "passed",
+ "detail": "经过 Windows 另存为对话框;落盘图片 580×180,全像素差异为 0。"
+ },
+ {
+ "name": "深色模式标注、撤销、重做与复制",
+ "status": "passed",
+ "detail": "矩形恢复后导出;1,840 个变化像素均位于预期矩形边界,其余像素保持一致。"
+ },
+ {
+ "name": "冷建双屏与 Esc 退出",
+ "status": "passed",
+ "detail": "外部关闭两份预热浮层,再用真实热键重新创建;右屏可选区,Esc 后无可见浮层。"
+ },
+ {
+ "name": "重复上次选区",
+ "status": "passed",
+ "detail": "重新打开后按 R,正确恢复左屏的 580×180 选区。"
+ },
+ {
+ "name": "取消原生保存",
+ "status": "passed",
+ "detail": "在系统保存框按 Esc;没有生成新图片,可再次截图。"
+ },
+ {
+ "name": "右键重选与取消",
+ "status": "passed",
+ "detail": "第一次右键清除选区,第二次退出截图。"
+ },
+ {
+ "name": "贴图显示与关闭",
+ "status": "passed",
+ "detail": "贴图画布 580×180,104,400 个像素差异为 0;Esc 关闭。"
+ },
+ {
+ "name": "全屏选区与取消",
+ "status": "passed",
+ "detail": "空格选择 2560×1440,Esc 退出;原生窗口列表仅剩测试实例主窗口。"
+ },
+ {
+ "name": "左屏原生吸附,Light / Dark",
+ "status": "passed",
+ "detail": "真实 Chrome、Windows helper、原生截图和真实 Overlay;移动、边界、细分元素、滚轮、单击均通过。"
+ },
+ {
+ "name": "右屏原生吸附,Light / Dark",
+ "status": "passed",
+ "detail": "窗口位于 (2700,80),同一套独立几何断言全部通过。"
+ }
+ ],
+ "pixels": {
+ "clipboard": {
+ "width": 580,
+ "height": 180,
+ "pixelCount": 104400,
+ "mismatch": 0
+ },
+ "nativeSave": {
+ "width": 580,
+ "height": 180,
+ "pixelCount": 104400,
+ "mismatch": 0
+ }
+ },
+ "annotation": {
+ "changed": 1840,
+ "bounds": {
+ "minX": 218,
+ "minY": 28,
+ "maxX": 341,
+ "maxY": 141
+ }
+ },
+ "pin": {
+ "width": 580,
+ "height": 180,
+ "mismatch": 0
+ },
+ "nativeSnapping": [
+ {
+ "position": "left",
+ "report": [
+ {
+ "theme": "light",
+ "content": {
+ "x": 88,
+ "y": 223,
+ "width": 984,
+ "height": 649
+ },
+ "window": [
+ 87,
+ 80,
+ 1073,
+ 873
+ ],
+ "nativeRegions": 0,
+ "movementSamples": 122,
+ "checks": [
+ "pending-movement",
+ "pending-boundary",
+ "button",
+ "file-list",
+ "body",
+ "browser-chrome",
+ "wheel",
+ "click"
+ ]
+ },
+ {
+ "theme": "dark",
+ "content": {
+ "x": 88,
+ "y": 223,
+ "width": 984,
+ "height": 649
+ },
+ "window": [
+ 87,
+ 80,
+ 1073,
+ 873
+ ],
+ "nativeRegions": 0,
+ "movementSamples": 121,
+ "checks": [
+ "pending-movement",
+ "pending-boundary",
+ "button",
+ "file-list",
+ "body",
+ "browser-chrome",
+ "wheel",
+ "click"
+ ]
+ }
+ ]
+ },
+ {
+ "position": "right",
+ "report": [
+ {
+ "theme": "light",
+ "content": {
+ "x": 2708,
+ "y": 223,
+ "width": 984,
+ "height": 649
+ },
+ "window": [
+ 2707,
+ 80,
+ 3693,
+ 873
+ ],
+ "nativeRegions": 0,
+ "movementSamples": 122,
+ "checks": [
+ "pending-movement",
+ "pending-boundary",
+ "button",
+ "file-list",
+ "body",
+ "browser-chrome",
+ "wheel",
+ "click"
+ ]
+ },
+ {
+ "theme": "dark",
+ "content": {
+ "x": 2708,
+ "y": 223,
+ "width": 984,
+ "height": 649
+ },
+ "window": [
+ 2707,
+ 80,
+ 3693,
+ 873
+ ],
+ "nativeRegions": 0,
+ "movementSamples": 122,
+ "checks": [
+ "pending-movement",
+ "pending-boundary",
+ "button",
+ "file-list",
+ "body",
+ "browser-chrome",
+ "wheel",
+ "click"
+ ]
+ }
+ ]
+ }
+ ],
+ "limitations": [
+ "macOS 未实机验证。",
+ "物理双屏均为 100% 缩放;真实混合 DPI 未验证。",
+ "本轮未实跑系统滚动截图和 WebM/GIF 录制;上一轮的 Chromium 场景不代表原生录制验收。",
+ "本轮只验收功能;不把工具调用或首次开发构建耗时计作性能指标。"
+ ],
+ "notes": [
+ "全应用初次启动时 recordingPreview 预热有一次 ERR_FAILED,后续页面重建成功;本轮没有对原生录制结论作通过声明。",
+ "UIA set_value 未把保存文件名提交给 Windows 对话框,文件实际保存于默认图片目录。核对确切新文件后将其移到证据目录;未覆盖用户文件。",
+ "自动化最初等到 Canvas 存在即输入,早于浮层显示;改为等窗口可见且尺寸稳定后输入。导出、Esc 销毁窗口时,CDP 的后续查询或 keyup 可报 page closed,已用窗口列表和实际产物独立核对结束结果。"
+ ]
+}
\ No newline at end of file
diff --git a/docs/acceptance/region-screenshot-performance-2026-10-28.json b/docs/acceptance/region-screenshot-performance-2026-10-28.json
new file mode 100644
index 0000000000..7687dfe3d5
--- /dev/null
+++ b/docs/acceptance/region-screenshot-performance-2026-10-28.json
@@ -0,0 +1,1358 @@
+{
+ "generatedAt": "2026-10-28T12:03:26.469Z",
+ "baseline": "7fdb9dd0963794cf46bc026f240d34c568bac03f",
+ "samples": 30,
+ "platform": "win32",
+ "arch": "x64",
+ "cpu": "Intel(R) Core(TM) Ultra 7 265K",
+ "scope": "Real Electron offscreen renderer (1040x760 DIP, 2x density), synthetic opaque BGRA source at the stated dimensions. Excludes OS capture, native window startup, IPC serialization, clipboard and disk. 3 warmups per batch; alternating before/after batches. First-paint timing includes two animation frames and is sensitive to vsync/GC.",
+ "results": [
+ {
+ "width": 1920,
+ "height": 1080,
+ "scale": 1,
+ "before": {
+ "beginSyncMs": {
+ "p50": 3.6,
+ "p95": 5.2
+ },
+ "paintedMs": {
+ "p50": 29.3,
+ "p95": 31.4
+ },
+ "exportMs": {
+ "p50": 12.1,
+ "p95": 13.2
+ },
+ "frameWrites": 2,
+ "raw": [
+ {
+ "syncMs": 4.300000011920929,
+ "paintedMs": 30,
+ "frameWrites": 2,
+ "exportMs": 12.399999976158142
+ },
+ {
+ "syncMs": 4,
+ "paintedMs": 28.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 13.799999982118607
+ },
+ {
+ "syncMs": 5.199999988079071,
+ "paintedMs": 28.69999998807907,
+ "frameWrites": 2,
+ "exportMs": 12.199999988079071
+ },
+ {
+ "syncMs": 3.2999999821186066,
+ "paintedMs": 29.299999982118607,
+ "frameWrites": 2,
+ "exportMs": 12.299999982118607
+ },
+ {
+ "syncMs": 4.0999999940395355,
+ "paintedMs": 29,
+ "frameWrites": 2,
+ "exportMs": 12.799999982118607
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 27.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 12.199999988079071
+ },
+ {
+ "syncMs": 3.5,
+ "paintedMs": 27.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 11.800000011920929
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 31.400000005960464,
+ "frameWrites": 2,
+ "exportMs": 12.099999994039536
+ },
+ {
+ "syncMs": 3.9000000059604645,
+ "paintedMs": 29.5,
+ "frameWrites": 2,
+ "exportMs": 12.5
+ },
+ {
+ "syncMs": 4.0999999940395355,
+ "paintedMs": 29.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 13
+ },
+ {
+ "syncMs": 3.5,
+ "paintedMs": 30.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 12.400000005960464
+ },
+ {
+ "syncMs": 3.5,
+ "paintedMs": 30,
+ "frameWrites": 2,
+ "exportMs": 11.800000011920929
+ },
+ {
+ "syncMs": 3.7999999821186066,
+ "paintedMs": 29.69999998807907,
+ "frameWrites": 2,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 29.200000017881393,
+ "frameWrites": 2,
+ "exportMs": 12.199999988079071
+ },
+ {
+ "syncMs": 3.4000000059604645,
+ "paintedMs": 29.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 11.600000023841858
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 28,
+ "frameWrites": 2,
+ "exportMs": 12.099999994039536
+ },
+ {
+ "syncMs": 5.4000000059604645,
+ "paintedMs": 29.5,
+ "frameWrites": 2,
+ "exportMs": 12.5
+ },
+ {
+ "syncMs": 4.100000023841858,
+ "paintedMs": 27.600000023841858,
+ "frameWrites": 2,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 3.4000000059604645,
+ "paintedMs": 27.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 3.5,
+ "paintedMs": 29.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 11.900000005960464
+ },
+ {
+ "syncMs": 4,
+ "paintedMs": 31.5,
+ "frameWrites": 2,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 29.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 13.200000017881393
+ },
+ {
+ "syncMs": 3.699999988079071,
+ "paintedMs": 29.299999982118607,
+ "frameWrites": 2,
+ "exportMs": 11.399999976158142
+ },
+ {
+ "syncMs": 3.2999999821186066,
+ "paintedMs": 31.299999982118607,
+ "frameWrites": 2,
+ "exportMs": 11.799999982118607
+ },
+ {
+ "syncMs": 4,
+ "paintedMs": 29.80000001192093,
+ "frameWrites": 2,
+ "exportMs": 12.5
+ },
+ {
+ "syncMs": 3.600000023841858,
+ "paintedMs": 29.200000017881393,
+ "frameWrites": 2,
+ "exportMs": 11.800000011920929
+ },
+ {
+ "syncMs": 3.300000011920929,
+ "paintedMs": 31.400000005960464,
+ "frameWrites": 2,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 30.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 12.099999994039536
+ },
+ {
+ "syncMs": 4.0999999940395355,
+ "paintedMs": 29.69999998807907,
+ "frameWrites": 2,
+ "exportMs": 12.600000023841858
+ },
+ {
+ "syncMs": 3.4000000059604645,
+ "paintedMs": 28.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 11.800000011920929
+ }
+ ]
+ },
+ "after": {
+ "beginSyncMs": {
+ "p50": 3.3,
+ "p95": 5.3
+ },
+ "paintedMs": {
+ "p50": 33.4,
+ "p95": 34.2
+ },
+ "exportMs": {
+ "p50": 2.85,
+ "p95": 5.9
+ },
+ "frameWrites": 1,
+ "raw": [
+ {
+ "syncMs": 3.0999999940395355,
+ "paintedMs": 34,
+ "frameWrites": 1,
+ "exportMs": 3.899999976158142
+ },
+ {
+ "syncMs": 4.9000000059604645,
+ "paintedMs": 32.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 5.9000000059604645
+ },
+ {
+ "syncMs": 4.899999976158142,
+ "paintedMs": 32.79999998211861,
+ "frameWrites": 1,
+ "exportMs": 2.699999988079071
+ },
+ {
+ "syncMs": 3.4000000059604645,
+ "paintedMs": 33.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 2.899999976158142
+ },
+ {
+ "syncMs": 3.0999999940395355,
+ "paintedMs": 33.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 2.9000000059604645
+ },
+ {
+ "syncMs": 4.300000011920929,
+ "paintedMs": 32.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 2.699999988079071
+ },
+ {
+ "syncMs": 5.4000000059604645,
+ "paintedMs": 33.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 2.899999976158142
+ },
+ {
+ "syncMs": 3.0999999940395355,
+ "paintedMs": 33,
+ "frameWrites": 1,
+ "exportMs": 2.699999988079071
+ },
+ {
+ "syncMs": 3,
+ "paintedMs": 33.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 4.9000000059604645
+ },
+ {
+ "syncMs": 3.300000011920929,
+ "paintedMs": 33.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 2.699999988079071
+ },
+ {
+ "syncMs": 3.2000000178813934,
+ "paintedMs": 34.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 2.7999999821186066
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 33.69999998807907,
+ "frameWrites": 1,
+ "exportMs": 2.699999988079071
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 33.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 3.0999999940395355
+ },
+ {
+ "syncMs": 3.199999988079071,
+ "paintedMs": 33.5,
+ "frameWrites": 1,
+ "exportMs": 2.5999999940395355
+ },
+ {
+ "syncMs": 2.9000000059604645,
+ "paintedMs": 33.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 3
+ },
+ {
+ "syncMs": 3.300000011920929,
+ "paintedMs": 33.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 3.9000000059604645
+ },
+ {
+ "syncMs": 3.7999999821186066,
+ "paintedMs": 33.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 2.9000000059604645
+ },
+ {
+ "syncMs": 3.300000011920929,
+ "paintedMs": 32.70000001788139,
+ "frameWrites": 1,
+ "exportMs": 3.800000011920929
+ },
+ {
+ "syncMs": 3.2999999821186066,
+ "paintedMs": 34.29999998211861,
+ "frameWrites": 1,
+ "exportMs": 7
+ },
+ {
+ "syncMs": 5.0999999940395355,
+ "paintedMs": 29.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 2.5999999940395355
+ },
+ {
+ "syncMs": 3.0999999940395355,
+ "paintedMs": 32.29999998211861,
+ "frameWrites": 1,
+ "exportMs": 2.5999999940395355
+ },
+ {
+ "syncMs": 3,
+ "paintedMs": 33.10000002384186,
+ "frameWrites": 1,
+ "exportMs": 2.9000000059604645
+ },
+ {
+ "syncMs": 2.9000000059604645,
+ "paintedMs": 34,
+ "frameWrites": 1,
+ "exportMs": 3.5999999940395355
+ },
+ {
+ "syncMs": 3.100000023841858,
+ "paintedMs": 33.30000001192093,
+ "frameWrites": 1,
+ "exportMs": 2.800000011920929
+ },
+ {
+ "syncMs": 3,
+ "paintedMs": 32.5,
+ "frameWrites": 1,
+ "exportMs": 2.800000011920929
+ },
+ {
+ "syncMs": 3.5,
+ "paintedMs": 34.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 2.800000011920929
+ },
+ {
+ "syncMs": 5.299999982118607,
+ "paintedMs": 34.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 2.7999999821186066
+ },
+ {
+ "syncMs": 3.0999999940395355,
+ "paintedMs": 33.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 2.699999988079071
+ },
+ {
+ "syncMs": 3,
+ "paintedMs": 32.79999998211861,
+ "frameWrites": 1,
+ "exportMs": 2.800000011920929
+ },
+ {
+ "syncMs": 3.5999999940395355,
+ "paintedMs": 33.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 5.199999988079071
+ }
+ ]
+ }
+ },
+ {
+ "width": 3840,
+ "height": 2160,
+ "scale": 2,
+ "before": {
+ "beginSyncMs": {
+ "p50": 13.5,
+ "p95": 15.5
+ },
+ "paintedMs": {
+ "p50": 20.65,
+ "p95": 32
+ },
+ "exportMs": {
+ "p50": 44.9,
+ "p95": 55.6
+ },
+ "frameWrites": 2,
+ "raw": [
+ {
+ "syncMs": 14,
+ "paintedMs": 25.200000017881393,
+ "frameWrites": 2,
+ "exportMs": 45.70000001788139
+ },
+ {
+ "syncMs": 12.900000005960464,
+ "paintedMs": 15,
+ "frameWrites": 2,
+ "exportMs": 45.599999994039536
+ },
+ {
+ "syncMs": 13.399999976158142,
+ "paintedMs": 18.5,
+ "frameWrites": 2,
+ "exportMs": 44.900000005960464
+ },
+ {
+ "syncMs": 13,
+ "paintedMs": 16.80000001192093,
+ "frameWrites": 2,
+ "exportMs": 44.69999998807907
+ },
+ {
+ "syncMs": 13.200000017881393,
+ "paintedMs": 18.5,
+ "frameWrites": 2,
+ "exportMs": 44.29999998211861
+ },
+ {
+ "syncMs": 13,
+ "paintedMs": 17.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 44.5
+ },
+ {
+ "syncMs": 13.5,
+ "paintedMs": 25,
+ "frameWrites": 2,
+ "exportMs": 45.5
+ },
+ {
+ "syncMs": 14,
+ "paintedMs": 21.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 44.30000001192093
+ },
+ {
+ "syncMs": 14.700000017881393,
+ "paintedMs": 20,
+ "frameWrites": 2,
+ "exportMs": 55.599999994039536
+ },
+ {
+ "syncMs": 16,
+ "paintedMs": 18.400000005960464,
+ "frameWrites": 2,
+ "exportMs": 45.19999998807907
+ },
+ {
+ "syncMs": 13.400000005960464,
+ "paintedMs": 18.600000023841858,
+ "frameWrites": 2,
+ "exportMs": 44.79999998211861
+ },
+ {
+ "syncMs": 13.099999994039536,
+ "paintedMs": 17.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 44.89999997615814
+ },
+ {
+ "syncMs": 14.100000023841858,
+ "paintedMs": 19.200000017881393,
+ "frameWrites": 2,
+ "exportMs": 44.900000005960464
+ },
+ {
+ "syncMs": 12.900000005960464,
+ "paintedMs": 30.200000017881393,
+ "frameWrites": 2,
+ "exportMs": 48.5
+ },
+ {
+ "syncMs": 13.799999982118607,
+ "paintedMs": 31.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 45.900000005960464
+ },
+ {
+ "syncMs": 13.800000011920929,
+ "paintedMs": 29.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 44
+ },
+ {
+ "syncMs": 13.599999994039536,
+ "paintedMs": 27.80000001192093,
+ "frameWrites": 2,
+ "exportMs": 43.29999998211861
+ },
+ {
+ "syncMs": 13.400000005960464,
+ "paintedMs": 25.299999982118607,
+ "frameWrites": 2,
+ "exportMs": 45
+ },
+ {
+ "syncMs": 13.300000011920929,
+ "paintedMs": 25.700000017881393,
+ "frameWrites": 2,
+ "exportMs": 43.5
+ },
+ {
+ "syncMs": 13.900000005960464,
+ "paintedMs": 29.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 45.80000001192093
+ },
+ {
+ "syncMs": 13.700000017881393,
+ "paintedMs": 19.5,
+ "frameWrites": 2,
+ "exportMs": 44.900000005960464
+ },
+ {
+ "syncMs": 13.599999994039536,
+ "paintedMs": 19.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 45.80000001192093
+ },
+ {
+ "syncMs": 12.799999982118607,
+ "paintedMs": 24.299999982118607,
+ "frameWrites": 2,
+ "exportMs": 45.69999998807907
+ },
+ {
+ "syncMs": 13.5,
+ "paintedMs": 18.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 45.900000005960464
+ },
+ {
+ "syncMs": 13.899999976158142,
+ "paintedMs": 32,
+ "frameWrites": 2,
+ "exportMs": 46.900000005960464
+ },
+ {
+ "syncMs": 15.5,
+ "paintedMs": 34.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 58
+ },
+ {
+ "syncMs": 13.299999982118607,
+ "paintedMs": 16.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 44.400000005960464
+ },
+ {
+ "syncMs": 13.199999988079071,
+ "paintedMs": 25.299999982118607,
+ "frameWrites": 2,
+ "exportMs": 44.400000005960464
+ },
+ {
+ "syncMs": 13.600000023841858,
+ "paintedMs": 26.700000017881393,
+ "frameWrites": 2,
+ "exportMs": 43.79999998211861
+ },
+ {
+ "syncMs": 13.5,
+ "paintedMs": 19.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 44.79999998211861
+ }
+ ]
+ },
+ "after": {
+ "beginSyncMs": {
+ "p50": 11.45,
+ "p95": 12.5
+ },
+ "paintedMs": {
+ "p50": 18.75,
+ "p95": 29.2
+ },
+ "exportMs": {
+ "p50": 12.55,
+ "p95": 18.3
+ },
+ "frameWrites": 1,
+ "raw": [
+ {
+ "syncMs": 12.400000005960464,
+ "paintedMs": 21.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 18.30000001192093
+ },
+ {
+ "syncMs": 11.199999988079071,
+ "paintedMs": 29.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 16.80000001192093
+ },
+ {
+ "syncMs": 11.199999988079071,
+ "paintedMs": 24.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 10.400000005960464
+ },
+ {
+ "syncMs": 11,
+ "paintedMs": 19,
+ "frameWrites": 1,
+ "exportMs": 11.599999994039536
+ },
+ {
+ "syncMs": 11.599999994039536,
+ "paintedMs": 18.299999982118607,
+ "frameWrites": 1,
+ "exportMs": 13.099999994039536
+ },
+ {
+ "syncMs": 11.400000005960464,
+ "paintedMs": 16.200000017881393,
+ "frameWrites": 1,
+ "exportMs": 12.199999988079071
+ },
+ {
+ "syncMs": 11.5,
+ "paintedMs": 29.69999998807907,
+ "frameWrites": 1,
+ "exportMs": 12.600000023841858
+ },
+ {
+ "syncMs": 11.600000023841858,
+ "paintedMs": 16.600000023841858,
+ "frameWrites": 1,
+ "exportMs": 12.099999994039536
+ },
+ {
+ "syncMs": 11.099999994039536,
+ "paintedMs": 18.5,
+ "frameWrites": 1,
+ "exportMs": 12.700000017881393
+ },
+ {
+ "syncMs": 12.5,
+ "paintedMs": 17.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 15.800000011920929
+ },
+ {
+ "syncMs": 11.299999982118607,
+ "paintedMs": 13.5,
+ "frameWrites": 1,
+ "exportMs": 12.900000005960464
+ },
+ {
+ "syncMs": 11.699999988079071,
+ "paintedMs": 17.80000001192093,
+ "frameWrites": 1,
+ "exportMs": 11.599999994039536
+ },
+ {
+ "syncMs": 11.299999982118607,
+ "paintedMs": 18.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 13.199999988079071
+ },
+ {
+ "syncMs": 13,
+ "paintedMs": 29,
+ "frameWrites": 1,
+ "exportMs": 10.299999982118607
+ },
+ {
+ "syncMs": 11.800000011920929,
+ "paintedMs": 19.200000017881393,
+ "frameWrites": 1,
+ "exportMs": 12.200000017881393
+ },
+ {
+ "syncMs": 12,
+ "paintedMs": 21.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 15.099999994039536
+ },
+ {
+ "syncMs": 11,
+ "paintedMs": 13.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 17.200000017881393
+ },
+ {
+ "syncMs": 11.199999988079071,
+ "paintedMs": 23.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 10.5
+ },
+ {
+ "syncMs": 11.099999994039536,
+ "paintedMs": 19.80000001192093,
+ "frameWrites": 1,
+ "exportMs": 11.799999982118607
+ },
+ {
+ "syncMs": 11.5,
+ "paintedMs": 19.30000001192093,
+ "frameWrites": 1,
+ "exportMs": 12.300000011920929
+ },
+ {
+ "syncMs": 11.599999994039536,
+ "paintedMs": 17.5,
+ "frameWrites": 1,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 10.900000005960464,
+ "paintedMs": 13.200000017881393,
+ "frameWrites": 1,
+ "exportMs": 12.5
+ },
+ {
+ "syncMs": 12,
+ "paintedMs": 18.5,
+ "frameWrites": 1,
+ "exportMs": 10.899999976158142
+ },
+ {
+ "syncMs": 11.099999994039536,
+ "paintedMs": 19.799999982118607,
+ "frameWrites": 1,
+ "exportMs": 19.30000001192093
+ },
+ {
+ "syncMs": 12.399999976158142,
+ "paintedMs": 22.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 12.800000011920929
+ },
+ {
+ "syncMs": 10.900000005960464,
+ "paintedMs": 14.600000023841858,
+ "frameWrites": 1,
+ "exportMs": 12.5
+ },
+ {
+ "syncMs": 11.599999994039536,
+ "paintedMs": 16.80000001192093,
+ "frameWrites": 1,
+ "exportMs": 12
+ },
+ {
+ "syncMs": 11.200000017881393,
+ "paintedMs": 17.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 12.599999994039536
+ },
+ {
+ "syncMs": 11.900000005960464,
+ "paintedMs": 20.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 14
+ },
+ {
+ "syncMs": 11.099999994039536,
+ "paintedMs": 24.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 12.599999994039536
+ }
+ ]
+ }
+ },
+ {
+ "width": 1600,
+ "height": 10000,
+ "scale": 2,
+ "before": {
+ "beginSyncMs": {
+ "p50": 24.85,
+ "p95": 34.3
+ },
+ "paintedMs": {
+ "p50": 39.9,
+ "p95": 47.5
+ },
+ "exportMs": {
+ "p50": 87.7,
+ "p95": 101.1
+ },
+ "frameWrites": 2,
+ "raw": [
+ {
+ "syncMs": 24.399999976158142,
+ "paintedMs": 37.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 88.19999998807907
+ },
+ {
+ "syncMs": 26.5,
+ "paintedMs": 44,
+ "frameWrites": 2,
+ "exportMs": 88.59999999403954
+ },
+ {
+ "syncMs": 24.599999994039536,
+ "paintedMs": 43.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 82.90000000596046
+ },
+ {
+ "syncMs": 32,
+ "paintedMs": 36.20000001788139,
+ "frameWrites": 2,
+ "exportMs": 101.09999999403954
+ },
+ {
+ "syncMs": 25.299999982118607,
+ "paintedMs": 30.899999976158142,
+ "frameWrites": 2,
+ "exportMs": 85.2000000178814
+ },
+ {
+ "syncMs": 24.5,
+ "paintedMs": 36.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 86.69999998807907
+ },
+ {
+ "syncMs": 24.400000005960464,
+ "paintedMs": 29.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 89.69999998807907
+ },
+ {
+ "syncMs": 24.900000005960464,
+ "paintedMs": 37.79999998211861,
+ "frameWrites": 2,
+ "exportMs": 90.7000000178814
+ },
+ {
+ "syncMs": 25.100000023841858,
+ "paintedMs": 44.60000002384186,
+ "frameWrites": 2,
+ "exportMs": 82.40000000596046
+ },
+ {
+ "syncMs": 24.69999998807907,
+ "paintedMs": 28,
+ "frameWrites": 2,
+ "exportMs": 110.5
+ },
+ {
+ "syncMs": 24.30000001192093,
+ "paintedMs": 42.80000001192093,
+ "frameWrites": 2,
+ "exportMs": 85.40000000596046
+ },
+ {
+ "syncMs": 24.799999982118607,
+ "paintedMs": 40.5,
+ "frameWrites": 2,
+ "exportMs": 82
+ },
+ {
+ "syncMs": 24.600000023841858,
+ "paintedMs": 37.20000001788139,
+ "frameWrites": 2,
+ "exportMs": 87.30000001192093
+ },
+ {
+ "syncMs": 24.099999994039536,
+ "paintedMs": 40.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 86.59999999403954
+ },
+ {
+ "syncMs": 25.100000023841858,
+ "paintedMs": 45.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 84.90000000596046
+ },
+ {
+ "syncMs": 25.69999998807907,
+ "paintedMs": 44.79999998211861,
+ "frameWrites": 2,
+ "exportMs": 87.90000000596046
+ },
+ {
+ "syncMs": 24.900000005960464,
+ "paintedMs": 37.80000001192093,
+ "frameWrites": 2,
+ "exportMs": 88.7999999821186
+ },
+ {
+ "syncMs": 24.599999994039536,
+ "paintedMs": 46.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 89.69999998807907
+ },
+ {
+ "syncMs": 25,
+ "paintedMs": 34.30000001192093,
+ "frameWrites": 2,
+ "exportMs": 87.90000000596046
+ },
+ {
+ "syncMs": 25.19999998807907,
+ "paintedMs": 40.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 91.2000000178814
+ },
+ {
+ "syncMs": 24.099999994039536,
+ "paintedMs": 39.599999994039536,
+ "frameWrites": 2,
+ "exportMs": 84.80000001192093
+ },
+ {
+ "syncMs": 27.30000001192093,
+ "paintedMs": 40.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 85.19999998807907
+ },
+ {
+ "syncMs": 34.29999998211861,
+ "paintedMs": 47.5,
+ "frameWrites": 2,
+ "exportMs": 87.5
+ },
+ {
+ "syncMs": 24.5,
+ "paintedMs": 29.900000005960464,
+ "frameWrites": 2,
+ "exportMs": 91.2999999821186
+ },
+ {
+ "syncMs": 24.400000005960464,
+ "paintedMs": 32.69999998807907,
+ "frameWrites": 2,
+ "exportMs": 85.19999998807907
+ },
+ {
+ "syncMs": 25.30000001192093,
+ "paintedMs": 30.600000023841858,
+ "frameWrites": 2,
+ "exportMs": 85.30000001192093
+ },
+ {
+ "syncMs": 24.599999994039536,
+ "paintedMs": 34.19999998807907,
+ "frameWrites": 2,
+ "exportMs": 88.5
+ },
+ {
+ "syncMs": 24.69999998807907,
+ "paintedMs": 44.099999994039536,
+ "frameWrites": 2,
+ "exportMs": 88
+ },
+ {
+ "syncMs": 36.39999997615814,
+ "paintedMs": 53.79999998211861,
+ "frameWrites": 2,
+ "exportMs": 92.80000001192093
+ },
+ {
+ "syncMs": 25,
+ "paintedMs": 43.5,
+ "frameWrites": 2,
+ "exportMs": 85.90000000596046
+ }
+ ]
+ },
+ "after": {
+ "beginSyncMs": {
+ "p50": 21.25,
+ "p95": 29.7
+ },
+ "paintedMs": {
+ "p50": 35.65,
+ "p95": 40.7
+ },
+ "exportMs": {
+ "p50": 22.25,
+ "p95": 39.8
+ },
+ "frameWrites": 1,
+ "raw": [
+ {
+ "syncMs": 22.19999998807907,
+ "paintedMs": 31.80000001192093,
+ "frameWrites": 1,
+ "exportMs": 29.80000001192093
+ },
+ {
+ "syncMs": 25.5,
+ "paintedMs": 35.5,
+ "frameWrites": 1,
+ "exportMs": 39.80000001192093
+ },
+ {
+ "syncMs": 20.799999982118607,
+ "paintedMs": 26.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 25.599999994039536
+ },
+ {
+ "syncMs": 20.69999998807907,
+ "paintedMs": 37.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 23.700000017881393
+ },
+ {
+ "syncMs": 21.30000001192093,
+ "paintedMs": 26.5,
+ "frameWrites": 1,
+ "exportMs": 22.900000005960464
+ },
+ {
+ "syncMs": 20.5,
+ "paintedMs": 23.899999976158142,
+ "frameWrites": 1,
+ "exportMs": 24.200000017881393
+ },
+ {
+ "syncMs": 21.399999976158142,
+ "paintedMs": 30.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 28.099999994039536
+ },
+ {
+ "syncMs": 20.899999976158142,
+ "paintedMs": 37.79999998211861,
+ "frameWrites": 1,
+ "exportMs": 24.5
+ },
+ {
+ "syncMs": 21.19999998807907,
+ "paintedMs": 39.79999998211861,
+ "frameWrites": 1,
+ "exportMs": 21.5
+ },
+ {
+ "syncMs": 21.099999994039536,
+ "paintedMs": 27.19999998807907,
+ "frameWrites": 1,
+ "exportMs": 23.899999976158142
+ },
+ {
+ "syncMs": 21.299999982118607,
+ "paintedMs": 26.5,
+ "frameWrites": 1,
+ "exportMs": 22.900000005960464
+ },
+ {
+ "syncMs": 21.5,
+ "paintedMs": 24.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 24.30000001192093
+ },
+ {
+ "syncMs": 35.30000001192093,
+ "paintedMs": 51.5,
+ "frameWrites": 1,
+ "exportMs": 29.900000005960464
+ },
+ {
+ "syncMs": 20.80000001192093,
+ "paintedMs": 27.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 21.599999994039536
+ },
+ {
+ "syncMs": 24,
+ "paintedMs": 39.599999994039536,
+ "frameWrites": 1,
+ "exportMs": 20.900000005960464
+ },
+ {
+ "syncMs": 22.099999994039536,
+ "paintedMs": 31.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 42.20000001788139
+ },
+ {
+ "syncMs": 21,
+ "paintedMs": 23.299999982118607,
+ "frameWrites": 1,
+ "exportMs": 32.5
+ },
+ {
+ "syncMs": 20.80000001192093,
+ "paintedMs": 30.200000017881393,
+ "frameWrites": 1,
+ "exportMs": 20.900000005960464
+ },
+ {
+ "syncMs": 21,
+ "paintedMs": 35.79999998211861,
+ "frameWrites": 1,
+ "exportMs": 21.200000017881393
+ },
+ {
+ "syncMs": 24.5,
+ "paintedMs": 38,
+ "frameWrites": 1,
+ "exportMs": 21.200000017881393
+ },
+ {
+ "syncMs": 24.30000001192093,
+ "paintedMs": 40.20000001788139,
+ "frameWrites": 1,
+ "exportMs": 21
+ },
+ {
+ "syncMs": 21.099999994039536,
+ "paintedMs": 35.80000001192093,
+ "frameWrites": 1,
+ "exportMs": 20.80000001192093
+ },
+ {
+ "syncMs": 25.100000023841858,
+ "paintedMs": 40.70000001788139,
+ "frameWrites": 1,
+ "exportMs": 20.69999998807907
+ },
+ {
+ "syncMs": 29.700000017881393,
+ "paintedMs": 34.099999994039536,
+ "frameWrites": 1,
+ "exportMs": 25.80000001192093
+ },
+ {
+ "syncMs": 20.69999998807907,
+ "paintedMs": 26.799999982118607,
+ "frameWrites": 1,
+ "exportMs": 20.80000001192093
+ },
+ {
+ "syncMs": 21.099999994039536,
+ "paintedMs": 37.400000005960464,
+ "frameWrites": 1,
+ "exportMs": 20.900000005960464
+ },
+ {
+ "syncMs": 24.600000023841858,
+ "paintedMs": 36.30000001192093,
+ "frameWrites": 1,
+ "exportMs": 21
+ },
+ {
+ "syncMs": 21.19999998807907,
+ "paintedMs": 37.5,
+ "frameWrites": 1,
+ "exportMs": 21
+ },
+ {
+ "syncMs": 21.700000017881393,
+ "paintedMs": 39.10000002384186,
+ "frameWrites": 1,
+ "exportMs": 20.80000001192093
+ },
+ {
+ "syncMs": 21.200000017881393,
+ "paintedMs": 36.900000005960464,
+ "frameWrites": 1,
+ "exportMs": 21.19999998807907
+ }
+ ]
+ }
+ }
+ ],
+ "regression": [
+ {
+ "theme": "light",
+ "side": "before",
+ "name": "offset-crop",
+ "width": 400,
+ "height": 320,
+ "oracle": "canvas",
+ "hash": 3731316037
+ },
+ {
+ "theme": "light",
+ "side": "before",
+ "name": "alpha-fallback",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 2433304853
+ },
+ {
+ "theme": "light",
+ "side": "before",
+ "name": "mixed-dpi-resize",
+ "width": 800,
+ "height": 600,
+ "oracle": "baseline",
+ "hash": 1022123766
+ },
+ {
+ "theme": "light",
+ "side": "before",
+ "name": "rectangle-annotation",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 328964738
+ },
+ {
+ "theme": "light",
+ "side": "after",
+ "name": "offset-crop",
+ "width": 400,
+ "height": 320,
+ "oracle": "canvas",
+ "hash": 3731316037
+ },
+ {
+ "theme": "light",
+ "side": "after",
+ "name": "alpha-fallback",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 2433304853
+ },
+ {
+ "theme": "light",
+ "side": "after",
+ "name": "mixed-dpi-resize",
+ "width": 800,
+ "height": 600,
+ "oracle": "baseline",
+ "hash": 1022123766
+ },
+ {
+ "theme": "light",
+ "side": "after",
+ "name": "rectangle-annotation",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 328964738
+ },
+ {
+ "theme": "dark",
+ "side": "before",
+ "name": "offset-crop",
+ "width": 400,
+ "height": 320,
+ "oracle": "canvas",
+ "hash": 3731316037
+ },
+ {
+ "theme": "dark",
+ "side": "before",
+ "name": "alpha-fallback",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 2433304853
+ },
+ {
+ "theme": "dark",
+ "side": "before",
+ "name": "mixed-dpi-resize",
+ "width": 800,
+ "height": 600,
+ "oracle": "baseline",
+ "hash": 1022123766
+ },
+ {
+ "theme": "dark",
+ "side": "before",
+ "name": "rectangle-annotation",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 328964738
+ },
+ {
+ "theme": "dark",
+ "side": "after",
+ "name": "offset-crop",
+ "width": 400,
+ "height": 320,
+ "oracle": "canvas",
+ "hash": 3731316037
+ },
+ {
+ "theme": "dark",
+ "side": "after",
+ "name": "alpha-fallback",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 2433304853
+ },
+ {
+ "theme": "dark",
+ "side": "after",
+ "name": "mixed-dpi-resize",
+ "width": 800,
+ "height": 600,
+ "oracle": "baseline",
+ "hash": 1022123766
+ },
+ {
+ "theme": "dark",
+ "side": "after",
+ "name": "rectangle-annotation",
+ "width": 800,
+ "height": 600,
+ "oracle": "canvas",
+ "hash": 328964738
+ }
+ ],
+ "versions": {
+ "electron": "42.11.12",
+ "chrome": "148.0.7778.280"
+ }
+}
diff --git a/docs/acceptance/region-screenshot-performance-2026-10-28.md b/docs/acceptance/region-screenshot-performance-2026-10-28.md
new file mode 100644
index 0000000000..7e849dbf32
--- /dev/null
+++ b/docs/acceptance/region-screenshot-performance-2026-10-28.md
@@ -0,0 +1,90 @@
+# 内置截图性能优化与回归(2026-10-28)
+
+普通截图导出的主要开销来自额外的 Canvas 绘制、像素读回和通道转换。无标注、无需缩放且选区像素全部不透明时,改为从现有 ImageData 一次完成裁剪和 RGBA → BGRA 转换;保持原图不变,可继续取色或重试。标注、缩放、透明像素仍使用 Canvas 路径。
+
+另移除了开始截图时重复的一次全屏 `putImageData`,保留 React layout effect 中的绘制与原有首帧确认。多屏冷窗口同时准备,全部就绪或超时后再统一定位和发送图片,保持显示顺序、取消、来源校验及故障降级行为。
+
+## 性能实测
+
+机器:XD-PC,Windows x64,Intel Core Ultra 7 265K;Electron 42.11.12 / Chromium 148.0.7778.280。基线为 `7fdb9dd0963794cf46bc026f240d34c568bac03f`,优化版为当前工作区源码。
+
+每种尺寸、每个版本各采样 30 次;每批预热 3 次,按旧→新、新→旧交替运行。调用真实 `RegionScreenshotOverlay`,通过键盘选择选区并导出,使用程序生成的 BGRA 图,不读取用户截图内容。临时 Electron profile 和构建文件放在唯一临时目录,结束时清理。
+
+下表测量从导出快捷键到 Renderer 把位图交给 bridge 的耗时,单位 ms。**不包含系统抓屏、原生窗口创建、IPC 传输、剪贴板写入或文件保存,不代表截图端到端耗时。**
+
+| 原图尺寸 | 导出 P50:优化前 → 后 | 耗时下降 | 导出 P95:优化前 → 后 |
+| --- | --- | --- | --- |
+| 1920 × 1080 | 12.10 → 2.85 | 76.4% | 13.20 → 5.90 |
+| 3840 × 2160 | 44.90 → 12.55 | 72.0% | 55.60 → 18.30 |
+| 1600 × 10000 | 87.70 → 22.25 | 74.6% | 101.10 → 39.80 |
+
+1600 × 10000 是大图处理样本,不是实际滚动采集总耗时。所有性能样本均为不透明、无标注、不缩放的完整选区;其它路径不据此宣称同等加速。
+
+| 原图尺寸 | Renderer 开始截图的同步处理 P50:前 → 后 | 首帧确认 P50:前 → 后 |
+| --- | --- | --- |
+| 1920 × 1080 | 3.60 → 3.30 | 29.30 → 33.40 |
+| 3840 × 2160 | 13.50 → 11.45 | 20.65 → 18.75 |
+| 1600 × 10000 | 24.85 → 21.25 | 39.90 → 35.65 |
+
+测量使用 1040 × 760 DIP、2x 密度的隔离 offscreen 窗口,像素缓冲区尺寸如表。首帧确认包含两次 animation frame,受垂直同步与 GC 影响;1080p 本次反而增加 4.1 ms,因此不宣称首屏展示全面加速。同步处理与导出是本次可靠的收益点。完整样本及 P95 见[原始 JSON](region-screenshot-performance-2026-10-28.json)。
+
+每次初始帧写入从 2 次减为 1 次。直接导出减少一个额外 Canvas backing store(4K RGBA 一份约 31.6 MiB),这是按像素数计算的分配量,不是进程峰值内存实测。
+
+## 功能回归
+
+- 相关单测:10 个文件、114 项通过;覆盖窗口生命周期、首帧屏障、取消与迟到结果、IPC 来源、取色、位图、滚动拼接、录制、剪贴板和交给新任务。
+- 新增多屏冷启动回归先在旧实现失败,再在新实现通过;一个冷屏不再阻止第二个屏幕开始准备,取消后不会发送迟到的 BEGIN。
+- 直接裁剪单测核对跨行选区、颜色通道、源数据不变、重试、选区外透明像素、选区内透明像素回退及越界/非整数回退。
+- Electron 像素回归:偏移选区、透明像素、混合 DPI 缩放和矩形标注,在 Light / Dark 下分别与旧代码结果对照,全部通过;同时检查实际显示画布,避免只验证内存导出而漏掉空白首帧。不透明像素逐字节核对;透明像素按预乘 alpha 的实际颜色核对(旧版 GPU/CPU 反预乘也存在 1 级取整差异);重采样与标注额外核对旧/新完整输出 hash。
+- `pnpm ui:check --page region-capture --case all --theme all --engine chromium`:16/16 通过,包含吸附、滚动截图、预览滚动、工具条拖动、WebM/GIF 录制、暂停、标注、保存及解码;已查看深浅色截图。
+- `pnpm ui:check --changed --theme all`(Electron):12/16 通过,截图相关场景全部通过。WebM 预览在 offscreen 宿主中超时,GIF 的独立解码页遇到 `Target.createTarget: Not supported`。通过 `--case 'video,gif' --theme light --compare=HEAD` 确认旧代码同样失败;未把这 4 项记为通过,录制部分以 Chromium 结果补充。
+- 本次还修复了已有 UI 场景的视口污染:idle 场景把页面缩到 900 × 400 后,用 finally 恢复到 900 × 700,避免 Electron 复用页面时后续场景的尺寸断言全部失败。
+- Desktop typecheck、涉及源码的 ESLint、test-hygiene 与 `git diff --check` 通过。
+
+修改的单测单文件计时:`windows.test.ts` 的 Vitest 总耗时 1.85s、用例 43ms;`screenshotRendering.test.tsx` 最后一次 14.70s,其中 jsdom 环境初始化 11.55s、收集 2.69s、用例 206ms,超过 5s 预算。该文件必须真实渲染 React/Canvas 调用,不能去掉 DOM 环境;没有新增真实等待或模块重载。此前同一最终用例集合连同其余 9 文件共 2.26s 完成,因此记录这次环境初始化波动,不扩大 timeout 或删断言。
+
+上述性能回归阶段未实测系统剪贴板/原生保存框及真实多屏;这些功能已在下述黑盒验收中补齐。仍未实测 macOS、物理混合 DPI,以及完整 Cindy 截图的端到端耗时;现有 macOS 模拟分支不等于实机验收。
+
+## Windows 双屏黑盒验收补充
+
+2026-10-28 在 XD-PC 启动当前工作区的完整开发实例,收到 `DESKTOP_DEV_VERDICT=ready`。命令为 `pnpm restart:desktop:remote -- --region=global --isolated=@worktree --mock`,为避免其它实例端口和快捷键冲突,测试实例使用 CDP 9337 和 `Ctrl+Alt+Shift+F9`。账号/任务使用模拟数据,截图、main/preload IPC、系统剪贴板、原生保存框及贴图均使用真实生产实现,无替身。两个物理显示器均为 2560×1440、100% 缩放,位于 `(0,0)` 和 `(2560,0)`。
+
+屏幕上展示本次创建的原生测试窗口,使用固定红绿蓝色块和文字;没有把个人桌面内容写进证据。系统快捷键/保存框由 computer 工具输入,截图界面的键盘、鼠标操作由 Playwright 连接该独立实例完成;没有调用内部导出函数替代点击,也没有把期望像素传入截图实现。
+
+完成 8 次真实截图会话及以下 12 类检查:
+
+| 检查 | 结果 |
+| --- | --- |
+| 系统热键开启两屏浮层 | 两屏可见尺寸均为 2560×1440 |
+| 左屏框选 → 系统复制 | 580×180,104,400 个像素逐个核对,差异 0 |
+| 右屏框选 → Windows 另存为 → PNG | 580×180,104,400 个像素逐个核对,差异 0 |
+| Dark 标注 → 撤销 → 重做 → 复制 | 矩形实际导出,1,840 个变化像素仅位于预期边界,其余像素不变 |
+| 关闭两份预热浮层后冷建 → 右屏选区 → Esc | 两份浮层重新创建并可操作;结束无残留可见窗口 |
+| R 重复上次区域 | 恢复正确的 580×180 选区 |
+| 原生保存框取消 | 未生成新图片,可继续截图 |
+| 右键重选/退出 | 第一次清除选区,第二次退出 |
+| 贴到屏幕 → Esc | 贴图 580×180,全像素差异 0,正常关闭 |
+| 空格全屏 → Esc | 正确选择 2560×1440 并退出 |
+| 左屏原生元素吸附,Light / Dark | 两种模式全部通过 |
+| 右屏原生元素吸附,Light / Dark | 两种模式全部通过 |
+
+原生吸附专项复用 `apps/desktop/scripts/check-region-snapping.mjs`,以此次开发实例编译的 helper 分别运行 `--position=80,80` 和 `--position=2700,80`,墙钟 7.71s / 7.24s。它使用真实 Chrome、Windows helper、原生捕获像素与真实 Overlay,传输层由 fixture 适配;不将其冒充完整应用 IPC 验收。每屏每主题验证移动期间稳定、跨边界、按钮、文件区域、正文、浏览器外框、滚轮切换及单击锁定。四组移动画面样本数为 122 / 121 / 122 / 122,均符合独立几何断言。
+
+原始结果见 [黑盒结果 JSON](region-screenshot-blackbox-2026-10-28.json)。本地图片及可预览的自包含单文件报告在 `artifacts/region-blackbox-20261028/report.html`,已目检浅色选区、深色标注和贴图。
+
+验收过程中两处自动化适配已单独记录:输入应等待浮层可见且尺寸稳定,不能仅等待 Canvas 存在;Windows 保存框的 UIA `set_value` 未提交文件名,实际文件保存于默认图片目录,随后核对新文件并移入证据目录。导出或 Esc 会销毁辅助窗口,后续 CDP 查询/keyup 的 `page closed` 由产物与原生窗口列表交叉验证,不作为功能失败或忽略真实失败。初次启动有一次 `recordingPreview` 预热 `ERR_FAILED`,后续页面重建;本轮未验收真实系统滚动截图或 WebM/GIF 录制,也未验证 macOS 与物理混合 DPI,不对这些范围作通过承诺。本轮没有修改产品代码,也未更新安装版。
+
+## 复跑
+
+仓库根运行:
+
+```powershell
+node apps/desktop/scripts/benchmark-region-screenshot.mjs --baseline=7fdb9dd0963794cf46bc026f240d34c568bac03f --samples=30 --output=docs/acceptance/region-screenshot-performance-2026-10-28.json
+pnpm --filter desktop exec vitest run src/main/region-screenshot src/renderer/features/region-screenshot src/shared/__tests__/regionScreenshot.test.ts
+pnpm --filter desktop run typecheck
+pnpm ui:check --page region-capture --case all --theme all --engine chromium
+```
+
+基准使用同一 fixture、分别编译基线和当前真实组件,不切分支、不覆盖源码。性能采样期间没有同时启动本任务的类型检查或其它测试。
+
+设计依据:`docs/design-rules/DESIGN.md` §10 双模式、§14.4 性能与直接交互;此次不改变布局、主题颜色或文案。测试价值依据为 `docs/dev-rules/engineering-conventions.md` §3.2;新增用例并入原测试文件,严格性能计时与真实 Canvas 留在显式 benchmark/E2E 脚本。