perf(call): JPEG thumbnails + memoized picker cards unfreeze the grid
The picker still felt frozen while thumbnails were streaming in because each result was both (a) large — PNG @ 320×180 landed at 60-150 KB base64 — and (b) triggering a high-priority React re-render of the whole grid. Three fixes together restore interactivity: - Thumbnails encoded as JPEG @ Q70 at 240×135 instead of PNG @ 320×180. Drops the typical payload from ~100 KB to ~20 KB, so IPC JSON-parsing on arrival is 5× faster. - SourceCard wrapped in React.memo so only the card whose thumbnail just landed re-renders. Previously one new thumbnail caused all ~20 cards to re-evaluate their props. - setSources updates run inside startTransition so scroll / click events stay on the high-priority lane while the grid backfills. Also: when the user enables "Sound mit übertragen" AND has a source picked, the picker now surfaces an inline amber note explaining that the OS picker will appear for the audio capture path. Matches the existing console info log but is visible pre-click so users don't experience it as a bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,10 @@ export interface ScreenSource {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: ScreenSourceKind;
|
||||
/** Base64-encoded PNG without a data-URL prefix. Null when capture failed. */
|
||||
/** Base64-encoded JPEG without a data-URL prefix. Null when capture failed.
|
||||
* Kept under `thumbnailPng` key for rollout stability — the server-side
|
||||
* format switched from PNG to JPEG for payload size, but the field name
|
||||
* preserves the wire contract during the transition. */
|
||||
thumbnailPng: string | null;
|
||||
width: number;
|
||||
height: number;
|
||||
@@ -69,8 +72,10 @@ export async function enumerateScreenSources(): Promise<ScreenSource[]> {
|
||||
}
|
||||
|
||||
// Data-URL helper — picker tiles bind `src={thumbnailDataUrl(src)}` so the
|
||||
// thumbnail bytes never leave the component's render pass.
|
||||
// thumbnail bytes never leave the component's render pass. Rust encodes
|
||||
// JPEG now (smaller payload, faster decode); the mime type here must
|
||||
// match or the <img> element silently fails to paint.
|
||||
export function thumbnailDataUrl(src: ScreenSource): string | null {
|
||||
if (!src.thumbnailPng) return null;
|
||||
return 'data:image/png;base64,' + src.thumbnailPng;
|
||||
return 'data:image/jpeg;base64,' + src.thumbnailPng;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user