perf(desktop): skip duplicate browser updates #8018
MergedBil0000(GitHub profile, opens in a new tab)merged 8 commits into
main fromrefs/pull/8018/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/desktop/src/preview/Manager.ts line 384OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -381,3 +381,4 @@381381 interface FrameCaptureSession {382382 readonly scope: Scope.Closeable;383383 readonly consumers: ReadonlySet<FrameCaptureConsumer>;384+ readonly lastFrame: Buffer | null;
- apps/desktop/src/preview/Manager.ts line 2577OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2550,4 +2558,20 @@25502558 webContentsId: wc.id,25512559 },2552- () => image.toJPEG(RECORDING_JPEG_QUALITY).toString("base64"),2560+ () => image.toJPEG(RECORDING_JPEG_QUALITY),25532561 );2562+ const frameConsumers = yield* SynchronizedRef.modify(frameCaptureSessionsRef, (sessions) => {2563+ const current = sessions.get(tabId);2564+ if (current?.scope !== captureSession.scope) {2565+ return [undefined, sessions] as const;2566+ }2567+ const recording =2568+ current.consumers.has("recording") && current.lastRecordingFrame?.equals(encoded) !== true;2569+ const pictureInPicture =2570+ current.consumers.has("picture-in-picture") &&2571+ current.lastPictureInPictureFrame?.equals(encoded) !== true;2572+ if (!recording && !pictureInPicture) {2573+ return [undefined, sessions] as const;2574+ }2575+ const next = {2576+ ...current,2577+ lastPictureInPictureFrame: pictureInPicture ? encoded : current.lastPictureInPictureFrame,
juliusmarminge requested changes
@@ -376,0 +377,21 @@377+ const previous = current.desktopByTabId[tabId] ?? null;378+ if (379+ previous === overlay ||380+ (previous !== null &&381+ overlay !== null &&382+ previous.hasWebContents === overlay.hasWebContents &&383+ previous.canGoBack === overlay.canGoBack &&384+ previous.canGoForward === overlay.canGoForward &&385+ previous.loading === overlay.loading &&386+ previous.zoomFactor === overlay.zoomFactor &&387+ previous.pictureInPicture === overlay.pictureInPicture &&388+ previous.colorScheme === overlay.colorScheme &&389+ previous.audioMuted === overlay.audioMuted &&390+ previous.audible === overlay.audible &&391+ previous.controller === overlay.controller &&392+ previous.favicon?.dataUrl === overlay.favicon?.dataUrl &&393+ previous.favicon?.pageUrl === overlay.favicon?.pageUrl &&394+ previous.favicon?.capturedAt === overlay.favicon?.capturedAt)395+ ) {396+ return current;397+ }macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this72c44a8
juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
216efb02-2129-4116-b425-4127706f8f1dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
09377aec-f562-47c2-b66b-dd64fd680474📥 Commits
Reviewing files that changed from the base of the PR and between 51e067e872f326754c7b2b0d4c92c10bd354f571 and fe2bfb484bf113df4ece566dc2db6ef44abf6464.
📒 Files selected for processing (3)
apps/desktop/src/preview/Manager.test.tsapps/desktop/src/preview/Manager.tsapps/web/src/previewStateStore.test.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The desktop preview pipeline now applies separate delivery rules for recording and picture-in-picture frames. Picture-in-picture retries failed frames and replays the first frame after renderer reload. The web preview state store suppresses equivalent desktop overlay updates.
Changes#
Preview delivery
apps/desktop/src/preview/Manager.tsdid-finish-load.apps/desktop/src/preview/Manager.test.tsapps/web/src/previewStateStore.ts,apps/web/src/previewStateStore.test.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: 🔵 Low · up to
fe2bfThe PR reduces duplicate desktop frame and overlay delivery while preserving retry behavior, but overlapping captures or a renderer reload could leave picture-in-picture deduplication state out of order and cause a duplicate, stale, or temporarily suppressed frame. This is a bounded delivery risk that is mergeable with explicit owner awareness or follow-up.
Sequence Diagram(s)#
Suggested reviewers:
juliusmarminge🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Full details: Description check
Explanation
The description includes clear What Changed and Why sections, detailed results and verification, and a completed checklist. The UI Changes section is omitted appropriately because the changes do not modify the UI.
Full details: Docstring Coverage
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.