From ab78a774e9c20c76652bd364493eaa9f90f31cc3 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:01:00 -0800 Subject: [PATCH 01/10] fix(window): run Orca UI animations on the main thread so the compositor can't wedge A compositor-thread animation (the agent working spinner, loaders) that keeps ticking through a multi-second main-thread task makes one frame's result land more than 300 frames late. Chromium's frame sorter then stops sorting for the renderer's lifetime and the compositor walks a growing tracker list every frame, pinning a core until the window is hidden. No Chromium or Electron release fixes it (reproduced on Electron 43 and 45). Main-thread animations pause with the task, so the sorter never runs that far ahead. Tracked in #14882 --- src/main/window/createMainWindow.ts | 2 ++ src/main/window/dashboard-popout-window.ts | 3 ++- .../window/presentation/main-thread-animation-arguments.ts | 3 +++ src/main/window/workspace-space-window.ts | 3 ++- src/renderer/src/assets/main.css | 2 +- src/renderer/src/components/AgentWorkingSpinner.tsx | 2 +- .../src/lib/window-activity/offscreen-animation-pause.ts | 2 +- 7 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 src/main/window/presentation/main-thread-animation-arguments.ts diff --git a/src/main/window/createMainWindow.ts b/src/main/window/createMainWindow.ts index ff6caabd4f5f..60654d53c1a0 100644 --- a/src/main/window/createMainWindow.ts +++ b/src/main/window/createMainWindow.ts @@ -50,6 +50,7 @@ import { rectHasVisibleAreaOnAnyDisplay } from './presentation/window-bounds-val import { installWindowsPathRegistryChangeListener } from '../pty/environment/windows-path-registry-change' import { recordAgentSessionRuntimeEnd } from '../runtime/agent-session/records/agent-session-runtime-end-record' import { installNativeUnloadCoordinator } from './renderer-relays/native-unload-coordinator' +import { MAIN_THREAD_ANIMATION_ARGUMENTS } from './presentation/main-thread-animation-arguments' // Node warns past this many listeners per event name. Headroom above normal subsystem fan-out, // still low enough that a real leak warns. Per-request listeners belong on addFanoutListener, @@ -169,6 +170,7 @@ export function createMainWindow( webviewTag: true, // Pass host identity at birth so the renderer has it before first snapshot, without waiting for IPC registration. additionalArguments: [ + ...MAIN_THREAD_ANIMATION_ARGUMENTS, formatBrowserClientHostIdArgument(getBrowserClientHostId()), ...(windowMaterial === 'off' ? [] : [formatWindowMaterialArgument(windowMaterial)]), ...(pumpHiddenFrames ? [formatHiddenWindowFramePumpArgument()] : []), diff --git a/src/main/window/dashboard-popout-window.ts b/src/main/window/dashboard-popout-window.ts index 11dff8a9a93b..645cdecef062 100644 --- a/src/main/window/dashboard-popout-window.ts +++ b/src/main/window/dashboard-popout-window.ts @@ -21,6 +21,7 @@ import type { KeybindingOverrides } from '../../shared/keybindings/types' import { wslHostsWindowArguments } from '../wsl/host-lifecycle/wsl-host-gate' +import { MAIN_THREAD_ANIMATION_ARGUMENTS } from './presentation/main-thread-animation-arguments' import { isMacAppPasteInput } from './editing/mac-app-paste-input' const MIN_WIDTH = 480 @@ -168,7 +169,7 @@ export function createOrFocusDashboardPopout( partition: DASHBOARD_POPOUT_PARTITION, // No webviews run here; disable embedding and omit host identity so client-placed pages stay mirrors. webviewTag: false, - ...(wslArguments.length > 0 ? { additionalArguments: wslArguments } : {}) + additionalArguments: [...MAIN_THREAD_ANIMATION_ARGUMENTS, ...wslArguments] } }) installPrivilegedWindowNavigationPolicy(window.webContents) diff --git a/src/main/window/presentation/main-thread-animation-arguments.ts b/src/main/window/presentation/main-thread-animation-arguments.ts new file mode 100644 index 000000000000..3e1b3d9acb73 --- /dev/null +++ b/src/main/window/presentation/main-thread-animation-arguments.ts @@ -0,0 +1,3 @@ +// A compositor animation ticking through a multi-second main-thread task wedges Chromium's frame sorter, +// pinning a compositor core until the window hides (#14882); main-thread animations pause with the task. +export const MAIN_THREAD_ANIMATION_ARGUMENTS: readonly string[] = ['--disable-threaded-animation'] diff --git a/src/main/window/workspace-space-window.ts b/src/main/window/workspace-space-window.ts index 4c141e9c7809..d1eed2170cae 100644 --- a/src/main/window/workspace-space-window.ts +++ b/src/main/window/workspace-space-window.ts @@ -13,6 +13,7 @@ import { type UIZoomDirection } from '../../shared/app-lifecycle/windows/ui-zoom-level' import { wslHostsWindowArguments } from '../wsl/host-lifecycle/wsl-host-gate' +import { MAIN_THREAD_ANIMATION_ARGUMENTS } from './presentation/main-thread-animation-arguments' let spaceWindow: BrowserWindow | null = null @@ -67,7 +68,7 @@ export function createOrFocusWorkspaceSpaceWindow(store: Store): BrowserWindow { sandbox: true, partition: 'orca-workspace-space-window', webviewTag: false, - ...(wslArguments.length > 0 ? { additionalArguments: wslArguments } : {}) + additionalArguments: [...MAIN_THREAD_ANIMATION_ARGUMENTS, ...wslArguments] } }) spaceWindow = window diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 665bfbd7db9b..481c4fcbc384 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -2094,7 +2094,7 @@ html.native-shell .app-layout { grid-template-rows: 1fr; } -/* Keep rotation on the compositor: JS style writes caused typing stalls (#12359). */ +/* Keep rotation in CSS: JS style writes caused typing stalls (#12359). */ /* One day per iteration avoids per-second React animation events; still 12 steps/second. */ @keyframes agent-spinner-rotate { to { diff --git a/src/renderer/src/components/AgentWorkingSpinner.tsx b/src/renderer/src/components/AgentWorkingSpinner.tsx index 56ce94ad0e53..98306aea8e70 100644 --- a/src/renderer/src/components/AgentWorkingSpinner.tsx +++ b/src/renderer/src/components/AgentWorkingSpinner.tsx @@ -32,7 +32,7 @@ function observeSpinner(el: HTMLSpanElement): () => void { return observeOffscreenAnimation(el) } -// CSS compositor rotation avoids JS input-thread work; callers provide size. +// CSS rotation avoids JS style writes; callers provide size. export function AgentWorkingSpinner({ className }: { className?: string }): React.JSX.Element { return ( Date: Tue, 17 Nov 2026 19:35:20 -0800 Subject: [PATCH 02/10] perf(renderer): pause pending-check and hosted-tab spinners while scrolled out of view With animations on the renderer main thread, every running spinner costs a style pass per frame even when clipped. The PR checks tab, the pull request page and the hosted browser tab strip mount one spinner per pending row with no visibility gate, so that cost grew with row count. They now use the same offscreen pause as the sidebar checks list. Tracked in #14882 --- .../inspect-pull-request/checks-tab-check-row.tsx | 3 ++- .../src/components/pull-request-page/checks/row.tsx | 7 ++++++- .../tab-bar/browser-tabs/ClientHostedBrowserTab.tsx | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-check-row.tsx b/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-check-row.tsx index 2bb329f14337..7c9d7f433bd3 100644 --- a/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-check-row.tsx +++ b/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-check-row.tsx @@ -11,6 +11,7 @@ import type { PRCheckDetail } from '../../../../../shared/github/checks/check-ty import { getCheckDetailsKey, getCheckStatusLabel } from '@/components/github/pr-check-presentation' import { ChecksTabCheckDetails } from './checks-tab-check-details' import { useTranslate } from '@/i18n/use-translate' +import { observeOffscreenAnimation } from '@/lib/window-activity/offscreen-animation-pause' export function renderCheckRow({ check, @@ -62,7 +63,7 @@ export function ChecksTabCheckRow({ const color = CHECK_COLOR[conclusion] ?? 'text-muted-foreground' const statusLabel = getCheckStatusLabel(check, t) return ( -
+
) : showTerminalLoadingLabel ? (
- + {t( 'auto.components.activity.ActivityPrototypePage.1b633f5c1e', diff --git a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx index 4dfc1bfe99c4..d1644a546e02 100644 --- a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx +++ b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useAgentPickerDraftScope } from '../agent/AgentLaunchSetupButton' import { agentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program' import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input' @@ -377,7 +378,9 @@ export function AgentSessionContinuationDialog({ disabled={startDisabled} onClick={() => void handleStart()} > - {showStarting ? : null} + {showStarting ? ( + + ) : null} {starting ? t('components.agentSessionContinuation.starting', 'Starting…') : t('components.agentSessionContinuation.startSessionSentence', 'Start session')} diff --git a/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx b/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx index 98306aea8e70..4c04872c4899 100644 --- a/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx +++ b/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx @@ -1,6 +1,9 @@ import React from 'react' import { cn } from '@/lib/class-names' -import { observeOffscreenAnimation } from '@/lib/window-activity/offscreen-animation-pause' +import { + observeOffscreenAnimation, + observeVisibleAnimation +} from '@/lib/window-activity/offscreen-animation-pause' const SPINNER_ANIMATION_NAME = 'agent-spinner-rotate' @@ -17,7 +20,11 @@ function syncSpinnerPhase(el: HTMLSpanElement | null): void { 'animationName' in candidate && candidate.animationName === SPINNER_ANIMATION_NAME ) if (animation !== undefined) { - animation.startTime = 0 + if (animation.playState === 'paused') { + animation.currentTime = animation.timeline?.currentTime ?? 0 + } else { + animation.startTime = 0 + } } } @@ -29,7 +36,12 @@ function handleSpinnerAnimationStart(event: React.AnimationEvent void { - return observeOffscreenAnimation(el) + const stopOffscreen = observeOffscreenAnimation(el) + const stopVisible = observeVisibleAnimation(el) + return () => { + stopOffscreen() + stopVisible() + } } // CSS rotation avoids JS style writes; callers provide size. diff --git a/src/renderer/src/components/artifacts/ArtifactActions.tsx b/src/renderer/src/components/artifacts/ArtifactActions.tsx index a296372889df..5cb8642a3673 100644 --- a/src/renderer/src/components/artifacts/ArtifactActions.tsx +++ b/src/renderer/src/components/artifacts/ArtifactActions.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { Copy, ExternalLink, Loader2, MoreHorizontal, Trash2 } from 'lucide-react' import type { ArtifactListItem } from '../../../../shared/artifacts/artifacts' import { Button } from '@/components/ui/button' @@ -61,7 +62,11 @@ export function ArtifactActions({ 'More artifact actions' )} > - {deleting ? : } + {deleting ? ( + + ) : ( + + )} diff --git a/src/renderer/src/components/artifacts/ArtifactCollection.tsx b/src/renderer/src/components/artifacts/ArtifactCollection.tsx index 564400b5542a..663501c0ecba 100644 --- a/src/renderer/src/components/artifacts/ArtifactCollection.tsx +++ b/src/renderer/src/components/artifacts/ArtifactCollection.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useMemo, useState } from 'react' import { Loader2 } from 'lucide-react' import type { ArtifactListItem } from '../../../../shared/artifacts/artifacts' @@ -81,7 +82,9 @@ export function ArtifactCollection({ disabled={loadingMore} onClick={loadMore} > - {loadingMore ? : null} + {loadingMore ? ( + + ) : null} {t('auto.components.artifacts.ArtifactCollection.loadMore', 'Load more')}
diff --git a/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx b/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx index 85680aac4ff0..54c7eb3c7ebc 100644 --- a/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx +++ b/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' @@ -36,7 +37,10 @@ export function ArtifactListToolbar({ disabled={isRefreshing} className="shrink-0 border border-border bg-background shadow-none hover:bg-muted/50" > - + diff --git a/src/renderer/src/components/artifacts/ArtifactPreview.tsx b/src/renderer/src/components/artifacts/ArtifactPreview.tsx index 02c52a5923b6..6e18e35f89d3 100644 --- a/src/renderer/src/components/artifacts/ArtifactPreview.tsx +++ b/src/renderer/src/components/artifacts/ArtifactPreview.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useEffect, useRef, useState } from 'react' import { AlertCircle, Loader2 } from 'lucide-react' import { ORCA_BROWSER_GUEST_WEB_PREFERENCES_ATTRIBUTE } from '../../../../shared/browser/guest-lifecycle/browser-guest-web-preferences' @@ -146,7 +147,10 @@ export function ArtifactPreview({ shareUrl }: { shareUrl: string }): React.JSX.E > {state === 'loading' ? (
- +
) : null} {state === 'unavailable' ? ( diff --git a/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx b/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx index 40880cab485f..d245a4b66c7f 100644 --- a/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx +++ b/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useEffect, useRef, useState, type RefObject } from 'react' import { ArrowRight, Loader2, Share2 } from 'lucide-react' import type { ArtifactWriteRequest } from '../../../../shared/artifacts/artifacts' @@ -143,7 +144,11 @@ export function ArtifactPublishButton({ disabled={blocked} aria-label={label} > - {publishing ? : } + {publishing ? ( + + ) : ( + + )} @@ -255,7 +260,7 @@ export function ArtifactPublishButton({ {checkingLink ? (
- + {t( 'auto.components.artifacts.ArtifactPublishButton.checkingLink', 'Checking for an existing link…' @@ -295,7 +300,11 @@ export function ArtifactPublishButton({ disabled={!signedIn || !sharingEnabled || busy} onClick={() => void publish()} > - {publishing ? : } + {publishing ? ( + + ) : ( + + )} {publishing ? t('auto.components.artifacts.ArtifactPublishButton.sharing', 'Sharing…') : t( diff --git a/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx b/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx index a37b18b1aa37..b46e9dce5451 100644 --- a/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx +++ b/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useCallback, useRef, useState } from 'react' import { Check, Copy, ExternalLink, Loader2, RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -136,7 +137,10 @@ export function ArtifactPublishedLinkPanel({ )} aria-hidden={!publishing} > - + {t('auto.components.artifacts.ArtifactPublishedLinkPanel.updating', 'Updating…')} diff --git a/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx b/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx index 663f3299a9ab..16d5c828ec8f 100644 --- a/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx +++ b/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { cn } from '@/lib/class-names' import { useTranslate } from '@/i18n/use-translate' import { ARTIFACTS_TABLE_GRID_CLASS } from './artifacts-table-layout' @@ -7,7 +8,12 @@ import { } from '@/lib/list-interaction/list-table-layout' function SkeletonBar({ className }: { className?: string }): React.JSX.Element { - return
+ return ( +
+ ) } const TABLE_ROW_SKELETONS = [ diff --git a/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx b/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx index b063593256c6..77ffcbe13945 100644 --- a/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx +++ b/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { ArrowRight, Files, Loader2 } from 'lucide-react' import { Button } from '@/components/ui/button' import { useTranslate } from '@/i18n/use-translate' @@ -153,7 +154,9 @@ export function ArtifactsPageEmptyState({ disabled={loadingMore} onClick={onLoadMore} > - {loadingMore ? : null} + {loadingMore ? ( + + ) : null} {t('auto.components.artifacts.ArtifactCollection.loadMore', 'Load more')} ) : null} diff --git a/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx b/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx index 4007f7a5c2fb..ecfa91412695 100644 --- a/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx +++ b/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { cn } from '@/lib/class-names' import { automationsTableGridClass } from './listing/automations-table-layout' @@ -10,7 +11,12 @@ import { import { useTranslate } from '@/i18n/use-translate' function SkeletonBar({ className }: { className?: string }): React.JSX.Element { - return
+ return ( +
+ ) } const TABLE_ROW_SKELETONS = [ diff --git a/src/renderer/src/components/automations/details/AutomationDetailActions.tsx b/src/renderer/src/components/automations/details/AutomationDetailActions.tsx index 4b3f0bdd492c..0714fb9dd70c 100644 --- a/src/renderer/src/components/automations/details/AutomationDetailActions.tsx +++ b/src/renderer/src/components/automations/details/AutomationDetailActions.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { Loader2, MoreHorizontal, Pause, Pencil, Play, Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -70,7 +71,7 @@ export function AutomationDetailActions({ aria-busy={isRunNowPending || undefined} > {isRunNowPending ? ( - + ) : ( )} diff --git a/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx b/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx index 60ac16359446..310217393dfd 100644 --- a/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx +++ b/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { cn } from '@/lib/class-names' import type { Automation } from '../../../../../shared/automations/automation-definition' @@ -39,6 +40,7 @@ function HealthCell({ > {showDot ? (
{loading && entries.length === 0 ? (
- + {t('auto.components.automations.AutomationRunsDashboard.loading', 'Loading runs…')}
) : entries.length === 0 ? ( diff --git a/src/renderer/src/components/browser-pane/describe-page/browser-favicon.tsx b/src/renderer/src/components/browser-pane/describe-page/browser-favicon.tsx index ec7566b54d47..cc83289e7ac8 100644 --- a/src/renderer/src/components/browser-pane/describe-page/browser-favicon.tsx +++ b/src/renderer/src/components/browser-pane/describe-page/browser-favicon.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useState } from 'react' import { Globe, Loader2 } from 'lucide-react' import { cn } from '@/lib/class-names' @@ -34,7 +35,8 @@ export function BrowserFavicon({ if (loading) { return (