Skip to content

fix(crash-reporting): scope renderer breadcrumbs to the renderer that emitted them - #15709

Closed
nwparker wants to merge 1 commit into
mainfrom
nwparker/crash-scan-car-08-20
Closed

nwparker wants to merge 1 commit into
mainfrom
nwparker/crash-scan-car-08-20

Conversation

@nwparker

@nwparker nwparker commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​359 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​351
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73

Description

Crash breadcrumbs are stored in a single global ring in the main process (crash-breadcrumb-store.ts, MAX_BREADCRUMBS = 30), and the IPC listener that receives renderer breadcrumbs discarded the sender:

// src/main/ipc/crash-reporting.ts — before
ipcMain.on('crashReports:recordBreadcrumb', (_event, args) => {
  recordRendererBreadcrumbFromRenderer(args)   // _event.sender.id thrown away
})

getCrashBreadcrumbSnapshot() was then attached unfiltered to every renderer crash report. So a report filed by renderer A carried breadcrumbs emitted by renderer B — a second window, a browser-pane webview guest, or the dashboard popout. Orca genuinely runs multiple renderers; the renderer_memory breadcrumb literally reports browserWebviews and registeredBrowserGuests counts.

This fix tags each renderer breadcrumb with its originating webContents and filters the snapshot to the reporting renderer. Main-process breadcrumbs (app_started, updater_*, gpu_fallback_applied, …) carry no origin and stay visible on every report, because they are genuinely global evidence.

This is not a theoretical bug — it produced a wrong diagnosis during the triage that found it. Investigating crash b05f68db / sidebar.worktrees from #orca-crashes, I read a lazy_chunk_reload + lazy_chunk_reload_vetoed breadcrumb pair in the bundle as proof that the crashing renderer had taken the lazy-chunk reload branch, and built a whole root-cause theory on it. Because the ring is global and unattributed, those crumbs could have come from any renderer. The theory was wrong.

Fix evidence

src/main/crash-reporting/crash-breadcrumb-renderer-attribution.test.ts drives the real main-process code — the real registerCrashReportingHandlers, the real store (not mocked; the pre-existing IPC suites mock the store, which is exactly why they never caught this), the real recordProcessGoneCrash, and the real crashReports:recordRendererError handler. Two renderers are simulated by invoking the captured IPC listener with { sender: { id: 11 } } and { sender: { id: 22 } }. Assertions read what actually lands in store.record(...).

BEFORE — production code at origin/main, new tests applied:

× does not attach a sibling renderer breadcrumb to a process-gone report
  → expected [ 'app_started', …(2) ] to not include 'lazy_chunk_reload_vetoed'
× keeps a quiet renderer own trail while other renderers churn
  → expected [ 'renderer_bootstrap_started', …(21) ] to deeply equal [ 'renderer_bootstrap_started', …(1) ]
× keeps an identical coalesced storm on each emitting renderer report
  → expected 1 to be undefined
× does not file one renderer payload under a name-only coalesced sibling
  → expected 9 to be 1
× does not attach a sibling renderer breadcrumb to a react-error-boundary report
  → expected [ 'app_started', …(2) ] to not include 'lazy_chunk_reload_vetoed'
× stores the origin label sanitization leaves untouched, so filtering matches
  → expected undefined to be 'renderer:11'
✓ still coalesces one renderer own repeats into a single entry
✓ keeps every renderer trail on a child crash that names no webContents

Tests  6 failed | 2 passed (8)

AFTER — fix applied, same tests, nothing weakened:

✓ does not attach a sibling renderer breadcrumb to a process-gone report
✓ keeps a quiet renderer own trail while other renderers churn
✓ keeps an identical coalesced storm on each emitting renderer report
✓ does not file one renderer payload under a name-only coalesced sibling
✓ still coalesces one renderer own repeats into a single entry
✓ does not attach a sibling renderer breadcrumb to a react-error-boundary report
✓ keeps every renderer trail on a child crash that names no webContents
✓ stores the origin label sanitization leaves untouched, so filtering matches

Tests  8 passed (8)

Note the two tests that pass before and after — they are the guard rails proving the fix does not over-correct: a child/GPU crash that names no renderer still gets the whole ring, and one renderer's own repeats still coalesce normally.

Wider verification, macOS (arm64):

src/main/crash-reporting + ipc/crash-reporting + shared/crash-reporting
+ renderer crash-diagnostics + react-error-boundary-reporting + createMainWindow-renderer-crash-recovery
  Test Files  26 passed (26)      Tests  291 passed (291)

tsc --noEmit -p config/tsconfig.node.json → exit 0. oxlint clean.

Windows (win32, awin) — 42 of the 66 crashes in this triage batch were Windows, so the suite was re-run natively there:

neil@awin MINGW64 ~/orca/workspaces/orca/crash-win-08-20 (verify-crumbs)
 Test Files  23 passed (23)      Tests  263 passed (263)

ELI5

Imagine one shared notepad on the wall of a building. Every room writes what it's doing on that same notepad, and nobody signs their name. When one room catches fire, we photocopy the last 30 lines of the notepad and staple it to the incident report as "what this room was doing."

Except half those lines were written by other rooms. So the fire investigator reads "was heating oil" and blames the wrong room — which is exactly what happened to me while triaging these crashes.

This change makes each room sign its notes. Building-wide announcements ("power came back on") stay unsigned and go on every report, because they really do apply to everyone. When a room catches fire, the report now includes the building-wide announcements plus that room's own notes, and nobody else's.

Trade-offs

Real ones, including things that get worse:

  1. The eviction half is deliberately NOT fixed. The ring is still one shared 30-entry budget and the filter runs after the budget slice. A chatty sibling renderer can still push the crashing renderer's crumbs out before the report is filed, so a scoped report can now come back with fewer than 30 entries where it previously came back with 30. Those extra entries were another renderer's and were misleading — but "fewer breadcrumbs" is a visible change, and it means a busy multi-window session can still produce a thin report. Fixing it properly is a capacity/tuning decision; see "Rejected approach" below for why it is not in this PR. Comments on getCrashBreadcrumbSnapshot and in the test say so explicitly.

  2. Webview guests and popouts drop off the main window's report. Browser-pane guests and dashboard-popout are separate webContents, so their breadcrumbs no longer appear on the main window's crash report. This is the intended semantics, but if you were relying on seeing browser-guest activity on a main-window crash, you will not see it any more. The flip side is that a popout's own boundary report now gets its own trail instead of the main window's.

  3. Cross-renderer coalescing changed. The renderer coalesce key now includes origin, so two renderers emitting an identical coalesced breadcrumb inside the 30s window no longer share one entry. This costs one extra ring slot per storming window (still MAX_COALESCE_KEYS-bounded). Without it, the sibling's copy was suppressed into an entry its own report then filtered out — the count vanished. That was a blocker finding in review loop 1.

  4. origin is a new optional field on the serialized breadcrumb and appears in crash-report text as - <ts>: <name> [renderer:11]. Per docs/reference/remote-wire-compatibility.md this is the safe case: additive, no new stream opcode. Absent origin degrades to today's behavior (visible on every report), never to a disappearance. It goes through the same sanitizeCrashReportString redaction and length cap as every other breadcrumb string, and there is a test locking the round-trip so filtering can never silently stop matching.

  5. No behavior change for GPU/utility/child crashes — they name no renderer and keep the full ring, because no single surface filed the report and scoping it would delete real evidence.

Rejected approach (worth knowing before review)

The first attempt at this fix tried to solve misattribution and eviction together, and redesigned the storage layer: per-origin rings, per-origin retained crumbs, reserved snapshot budgets, and a 16-origin LRU. It failed 5 consecutive adversarial review loops without converging. Every blocker/major finding was about the machinery it added, not the bug — LRU-evicting a live renderer's entire trail, erasing evidence on the webContents destroyed path, losing retained-crumb dedup, and over-reporting coalesce visibility (the same class of error "fixed" wrongly three times). A perf pass measured it introducing a 13× regression on the coalesce expiry sweep (0.242ms → 3.267ms) plus 2.5ms of synchronous main-process work on every window close.

That approach was discarded and the problem split. This PR does misattribution only: ~60 net lines of production code, filtering on read, single ring untouched.

Adversarial review

2 loops to clean. Each loop was a fresh sub-agent with no prior context, instructed to break the change and to treat any reintroduced per-origin ring / budget / LRU as a blocker.

  • Loop 1 — not clean. 1 blocker, 1 minor, 1 nit.
    • blocker: the coalesce key excluded origin, so two renderers emitting the same coalesced breadcrumb shared one ring entry owned by whichever emitted first; the sibling's copy was suppressed into a crumb its own report filtered out, and the count was lost. Fixed (trade-off 3 above).
    • minor: no recorder-level test locked the "absent reporter id degrades to the full ring" contract.
    • nit: the reporting side built the origin label raw while the recording side stored it sanitized; equality held only by luck.
  • Loop 2 — clean. No blockers or majors. Three residual minor/nit items were reported, two of which I then closed by hand with the last two tests in the suite (keeps every renderer trail on a child crash that names no webContents, stores the origin label sanitization leaves untouched). The remaining minor — retained renderer_memory_highwater crumbs carry an origin while retainedBreadcrumbKey is still name:surface:threshold — is noted and left; it only affects which of two same-surface high-water profiles is retained, not attribution.

Perf

/perf audit: no meaningful impact.

  • +~0.31 µs per renderer breadcrumb (one sanitize pass over the renderer:<id> string) and +~0.06 µs on the coalesce suppressed path. At the worst observed emission rate (1459/min crash loop ≈ 24 crumbs/s) that is +1.3 µs of main-process CPU per second.
  • The snapshot path gets 64.7% faster when filtered, because .filter drops entries before the sort and deep map.
  • The O(origins × ring) shape that caused the rejected attempt's 13× regression is absent: isVisibleToReporter is O(1) per crumb on crash-time-only paths, and isCoalescedCrumbStillInEvidence (the O(ring) indexOf the expiry sweep calls) is byte-identical to HEAD.
  • No optimizations applied — every candidate was either unsafe or not worth the code.

Scope / collisions

Deliberately does not touch process-gone classification or suppression policy. Verified no overlap with open PRs #12484, #15251, #15059, #15294. webContentsId is added as a first-class optional field on ProcessGoneCrashEvent rather than stuffed into the untyped details blob, so the internal Chromium id never reaches the persisted report or the user-facing copy-diagnostics text.

… emitted them

Crash breadcrumbs live in one global ring in the main process, and the IPC
listener discarded event.sender, so a report filed by one renderer carried
another renderer's trail. Tag renderer crumbs with their webContents origin and
filter the snapshot to the reporting renderer; main-process crumbs stay global.

Child/GPU crashes name no renderer and keep the whole ring, as before.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds a shared renderer origin format and sanitized breadcrumb origin metadata. Renderer IPC handlers derive origins from sender IDs and pass them through direct and coalesced recording paths. Breadcrumb snapshots filter renderer-scoped entries by reporter origin while preserving global entries. Renderer crash reports use scoped snapshots, while child and GPU crash reports retain the full ring. Tests cover sanitization, coalescing, filtering, and report attribution.

Merge Risk: 🟡 Moderate · up to eacee

The change scopes crash breadcrumbs to their emitting renderer, but renderer-specific report deduplication and retained highwater records still ignore renderer identity, so one renderer can suppress another report or lose its own diagnostic evidence. Merge should wait for these bounded correctness issues to be fixed.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but the required linked issue is empty and several template sections and checklist confirmations are missing. Add a valid linked issue and complete the missing template sections, including Visual Proof or N/A, AI Disclosure, Review, Notes, and checklist status.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: scoping renderer breadcrumbs to their emitting renderer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/shared/crash-breadcrumb-origin.ts (1)

1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove or shorten this comment.

The function name and implementation already show this behavior. Use one short comment only if the format contract needs explanation.

As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 55bc3871-c1d5-4a39-8f65-ca84bf5e4f60

📥 Commits

Reviewing files that changed from the base of the PR and between a057864 and eaceeb8.

📒 Files selected for processing (12)
  • src/main/crash-reporting/crash-breadcrumb-renderer-attribution.test.ts
  • src/main/crash-reporting/crash-breadcrumb-store.test.ts
  • src/main/crash-reporting/crash-breadcrumb-store.ts
  • src/main/crash-reporting/process-gone-recorder.ts
  • src/main/index.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.ts
  • src/main/ipc/crash-reporting-renderer-error-report.ts
  • src/main/ipc/crash-reporting.ts
  • src/shared/crash-breadcrumb-origin.ts
  • src/shared/crash-reporting.test.ts
  • src/shared/crash-reporting.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines 52 to +62
export function recordCrashBreadcrumb(
name: string,
data?: CrashReportBreadcrumbData
data?: CrashReportBreadcrumbData,
origin?: string
): CrashReportBreadcrumb | undefined {
const sanitized = sanitizeCrashReportBreadcrumbs([
{
createdAt: new Date().toISOString(),
name,
data
data,
...(origin ? { origin } : {})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Include origin in the retained breadcrumb key.

retainedBreadcrumbKey identifies renderer_memory_highwater entries by name, surface, and threshold only. If two renderers emit the same retained breadcrumb, the second write replaces the first. The first renderer then filters out the replacement and loses its own highwater evidence.

Include breadcrumb.origin in the retained key. Add a test with two origins and equal retained-breadcrumb data.

Proposed fix
 function retainedBreadcrumbKey(breadcrumb: CrashReportBreadcrumb): string | null {
   if (breadcrumb.name !== 'renderer_memory_highwater') {
     return null
   }
   const surface = breadcrumb.data?.rendererSurface
   const threshold = breadcrumb.data?.thresholdPct
-  return `${breadcrumb.name}:${String(surface)}:${String(threshold)}`
+  return JSON.stringify([
+    breadcrumb.name,
+    breadcrumb.origin ?? null,
+    surface,
+    threshold
+  ])
 }

Comment on lines +45 to +47
/** Crashing webContents, when the source is a renderer. Kept out of `details`
* so this internal Chromium id never reaches the user-facing report text. */
webContentsId?: number

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Scope report deduplication by renderer identity. Both paths now know the reporting renderer, but both dedupe before recording with keys that exclude it. A matching failure in a sibling renderer suppresses that renderer's report and its scoped breadcrumbs.

  • src/main/crash-reporting/process-gone-recorder.ts#L45-L47: include webContentsId or its origin in renderer-only process-gone dedupe keys.
  • src/main/ipc/crash-reporting-renderer-error-report.ts#L120-L123: include webContentsId or its origin in renderer error-report dedupe keys.
📍 Affects 2 files
  • src/main/crash-reporting/process-gone-recorder.ts#L45-L47 (this comment)
  • src/main/ipc/crash-reporting-renderer-error-report.ts#L120-L123

@nwparker

Copy link
Copy Markdown
Contributor Author

Held as draft after readiness review: #16313 already merged a superset of this fix, including per-renderer dedupe, retained-key scoping, filter-before-budget behavior, and persistence scrubbing. This branch now conflicts with main and should not merge as-is.

@nwparker

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #16313; the merged implementation includes the required attribution, dedupe, retention, and persistence fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant