Repository navigation
fix(crash-reports): label the renderer footprint's age and pair outsideHeapMB with its own heap - #22743
fix(crash-reports): label the renderer footprint's age and pair outsideHeapMB with its own heap#22743OrcaWin wants to merge 2 commits into
Conversation
…deHeapMB with its own heap recordRendererMemorySample emits the footprint from the previous background read, so privateMB/residentMB are one interval (~60s) older than the heap fields beside them, and outsideHeapMB subtracted the current heap from that stale footprint. Bundle F0C4339L5R9 read a 254->633MB jump as 43s before a crash when it was ~104s. Each footprint read now records when it resolved and the heap it saw then. Crumbs gain an optional footprintAgeMs, and outsideHeapMB is computed from the heap measured alongside the footprint. Emission stays synchronous so the last pre-crash sample is never deferred behind an async read.
…dge later refreshes
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed both changed files against main (7ea0127) at head 7ff85ba — the production change and its test.
- Footprint reading now carries its own heap and timestamp.
FootprintReadingstoresreadAtMsandheapAccountedBytes(used heap + malloced + Blink) captured when the asyncreadProcessMemory()resolves, sooutsideHeapMB = stale privateMB − heap from that same momentinstead of subtracting the current heap. footprintAgeMson both crumb types.renderer_memoryandrenderer_memory_highwaternow reportmax(0, now − readAtMs), letting readers place the staleprivateMB/residentMBon a timeline. New field is optional and backward compatible.- Settle hardening.
settle()clears the in-flight flag before the new synchronous heap read and wraps that read in try/catch, so a throwing bridge cannot wedge later footprint refreshes; the generation guard still drops stale settles. - Regression test. A two-sample, mocked-clock test reproduces bundle F0C4339L5R9 and asserts
privateMB: 254,usedHeapMB: 400,footprintAgeMs: 60000,outsideHeapMB: 74; it fails on the base code (outsideHeapMB: 0, nofootprintAgeMs). Ran the file locally: 19/19 pass.
I checked the areas the adversarial loop flagged as previously fixed (in-flight flag ordering, Date.now restoration) and they hold, and confirmed no downstream consumer keys on these fields: renderer_memory is not coalesced and the renderer_memory_highwater retained key ignores the new field, so ring/eviction behavior is unchanged.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe renderer now retains each process-footprint reading with its timestamp and heap-accounted bytes. Breadcrumbs report the reading’s age and calculate Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Memory crash breadcrumbs may report an inaccurate footprint age or outside-heap value when a footprint read is delayed. This is a bounded diagnostics risk rather than a user-facing workflow failure. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 98daeec5-cbef-4d0b-bd84-608e3d4853ea
📒 Files selected for processing (2)
src/renderer/src/lib/crash-diagnostics.test.tssrc/renderer/src/lib/renderer-memory-sampling.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| lastFootprintReading = footprint | ||
| ? { footprint, readAtMs: Date.now(), heapAccountedBytes: readHeapAccountedBytes() } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the bridge implementation and its callers to establish measurement timing.
rg -n -C 8 '\breadProcessMemory\b' srcRepository: stablyai/orca
Length of output: 11414
🏁 Script executed:
#!/bin/bash
rg -n -C 12 'readRendererProcessMemory|RendererProcessMemory' src/preload src/renderer/src/lib/renderer-memory-sampling.tsRepository: stablyai/orca
Length of output: 19297
🏁 Script executed:
rg -n -C 12 'readRendererProcessMemory|RendererProcessMemory' src/preload src/renderer/src/lib/renderer-memory-sampling.tsRepository: stablyai/orca
Length of output: 19297
🏁 Script executed:
#!/bin/bash
set -o pipefail
rg -n -C 12 'readRendererProcessMemory|RendererProcessMemory' src/preload src/renderer/src/lib/renderer-memory-sampling.tsRepository: stablyai/orca
Length of output: 19297
🏁 Script executed:
#!/bin/bash
rg -n -C 3 '"electron"\s*:' package.json package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/nullRepository: stablyai/orca
Length of output: 486
🌐 Web query:
Electron process.getProcessMemoryInfo measurement timing API contract
💡 Result:
<source_evidence>
<source>
<title>process | Electron</title>
<location>https://electronjs.org/docs/latest/api/process</location>
<excerpt>- `crash()` - `hang()` - `getCreationTime()` - `getHeapStatistics()` - `getBlinkMemoryInfo()` - `getProcessMemoryInfo()` - `getSystemMemoryInfo()` - `getSystemVersion()` - `getCPUUsage()` - `uptime()` - `argv` - `execPath` - `env` - `pid` - `arch` - `platform` - `sandboxed` - `contextIsolated` - `type` - `version` - `versions` - `mas` - `windowsStore` - `contextId` ... ### process.getProcessMemoryInfo() ... Returns`Promise `- Resolves with a ProcessMemoryInfo ... Returns an object giving memory usage statistics about the current process. Note that all statistics are reported in Kilobytes. This api should be called after app ready. ... Chromium does not provide`residentSet` value for macOS. This is because macOS performs in-memory compression of pages that haven&`#39`;t been recently used. As a result the resident set size value is not what one would expect.`private` memory is more representative of the actual pre-compression memory usage of the process on macOS.</excerpt>
</source>
<source>
<title>ProcessMemoryInfo Object | Electron</title>
<location>https://electronjs.org/docs/latest/api/structures/process-memory-info</location>
<excerpt>ProcessMemoryInfo Object | Electron - `residentSet` Integer Linux Windows - The amount of memory currently pinned to actual physical RAM in Kilobytes. - `private` Integer - The amount of memory not shared by other processes, such as JS heap or HTML content in Kilobytes. - `shared` Integer - The amount of memory shared between processes, typically memory consumed by the Electron code itself in Kilobytes.</excerpt>
</source>
<source>
<title>[Feature Request]: Add additional APIs/info to Electron&`#39`;s process object for getting performance metrics</title>
<location>GitHub issue 28114 in electron/electron (link omitted to avoid creating a cross-reference)</location>
<excerpt># [Feature Request]: Add additional APIs/info to Electron&`#39`;s process object for getting performance metrics ... ### Preflight Checklist - [X] I have read the Contributing Guidelines for this project. - [X] I agree to follow the Code of Conduct that this project adheres to. - [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success. ### Problem Description In my non-sandboxed Renderer, I was getting some performance metrics: ``` const memoryInfo: NodeJS.MemoryUsage = process.memoryUsage(); const cpuTime = process.cpuUsage().system + process.cpuUsage().user; ``` Now that I&`#39`;m sandboxing my Renderer, I have to use Electron&`#39`;s process object instead of Node&`#39`;s. For CPU time, I can call `process.getCPUUsage()`, but I&`#39`;m not sure how exactly to get the `user` + `system` value that I was seeing in Node Node docs say: >returns the user and system CPU time usage of the current process Not sure what the equivalent of this is with the return of `getCPUUsage` (documented here). Next, I get the heap and rss information (normally returned by Node&`#39`;s `process.memoryUsage()`) by doing: ``` heapTotal = process.getHeapStatistics().totalHeapSize * 1024 heapUsed = process.getHeapStatistics().usedHeapSize * 1024 rss = (await process.getProcessMemoryInfo()).residentSet ``` ... However, how do I get `external` which in Node (docs) refers to: >memory usage of C++ objects bound to JavaScript objects managed by V8 The `arrayBuffers` property that Node sets isn&`#39`;t useful to me personally. ### Proposed Solution Can there be an API / additional property in one of the return values of an existing API that gets me the corresponding values that Node returns? Namely: * `process.cpuUsage()` * `process.memoryUsage().external` Also, ideally, `getProcessMemoryInfo` would be synchronous like in Node if that&`#39`;s possible to achieve (I have a version skew issue now between my Electron app and the website it hosts where the site assumes the performance metrics API is synchronous, but now it won&`#39`;t be) ### Alternatives Considered Not really sure what we can do here. Seems to me, Electron should be the one providing this info. ### Additional Information n/a ## Timeline ... > I think you&`#39`;re looking for `app.getAppMetrics()` > > That method allows access to process-level metrics for all processes, regardless of sandbox state (or even if JS is running in them, e.g. GPU process) ... > `@MarshallOfSound` Thanks - though I&`#39`;m still not seeing how to get the same cpu info I was getting with Node using this API. It returns a `CPUUsage` object whose values are deltas, which is not what I want. Node returns values that measure "time spent in user and system code respectively". > > Similarly, the `MemoryInfo` object is missing the `external` property I believe (which Node returns), or I&`#39`;m not sure what corresponds to it anyway. ... > `@pushkin-` it looks like Node&`#39`;s APIs also return a delta since last called for CPU usage. Can you clarify what requirements you have of this information? > > The `MemoryInfo` structure includes all memory, not just JS heap memory, so the `external` property isn&`#39`;t relevant. `app.getAppMetrics` includes memory details for processes that don&`#39`;t run JS, such as utility processes and the GPU process. ... > `@nornagon` They only return a delta if passed a start parameter. Without any parameters, they return the total time. (docs) > > Are you saying that `external` is baked into `(await process.getProcessMemoryInfo()).residentSet`? > > And I currently don&`#39`;t need info about other processes, so don&`#39`;t have a real need to use `app.getAppMetrics()`. I&`#39`;m making calls to these performance metrics APIs a number of times during workflows and want a quick way of getting this information. The old way cost 0.035ms. Using `await getProcessMemoryInfo` costs 5.9 ms which might already be unnacc…[truncated]</excerpt>
</source>
<source>
<title>Replace `getProcessMemoryInfo` API in chromium 67 · Issue `#13447` · electron/electron</title>
<location>GitHub issue 13447 in electron/electron (link omitted to avoid creating a cross-reference)</location>
<excerpt># Issue: electron/electron `#13447` - Repository: electron/electron | :electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS | 122K stars | C++ ## Replace `getProcessMemoryInfo` API in chromium 67 - Author: [`@alexeykuzmin`](https://github.com/alexeykuzmin) - Association: CONTRIBUTOR - State: closed (completed) - Labels: chromium - Created: 2018-06-26T21:48:57Z - Updated: 2019-03-20T22:24:10Z - Closed: 2019-03-20T22:24:09Z - Closed by: [`@codebytere`](https://github.com/codebytere) `ProcessMetrics::GetMemoryBytes` won&`#39`;t be available after an upgrade to Chromium 67+, see `#13383`. But those metrics are quite important, so we should try to find a way to keep them. /cc `@miniak`, `@juturu`, `@nitsakh` --- ### Timeline **alexeykuzmin** added label `chromium` · Jun 26, 2018 at 9:49pm **alexeykuzmin** mentioned this in PR [`#13446`: fix: deprecate properties in app.getAppMetrics()](https://github.com/electron/electron/pull/13446); changed the title from "Keep `privateBytes` and `sharedBytes` event after the `ProcessMetrics::GetMemoryBytes` is not available" to "Keep `privateBytes` and `sharedBytes` even after the `ProcessMetrics::GetMemoryBytes` is not available" · Jun 26, 2018 at 9:50pm **`@nitsakh`** commented · Jul 30, 2018 at 10:07pm > Based on the chromium task (https://bugs.chromium.org/p/chromium/issues/detail?id=819289) and related notes, it looks like the details in the electron `getProcessMemoryInfo` API response provide results are platform specific and mean different on different platforms. These no longer exist in chromium 67. Chromium has moved to using the memory_instrumentation apis, and that&`#39`;s the recommended cross platform way. > There are ways to get platform specific details (process_metric.h), but if just the memory footprint is needed we can use the `private_memory_footprint` from the instrumentation API. > (Also updating the issue title to reflect the `getProcessMemoryInfo` API deprecation) **nitsakh** changed the title from "Keep `privateBytes` and `sharedBytes` even after the `ProcessMetrics::GetMemoryBytes` is not available" to "Replace `getProcessMemoryInfo` API in chromium 67" · Jul 30, 2018 at 10:09pm **codebytere** mentioned this in PR [`#13962`: test: re-enable app.getAppMetric API](https://github.com/electron/electron/pull/13962) · Aug 7, 2018 at 12:12am **alexeykuzmin** mentioned this in PR [`#13756`: chore: Chromium 67](https://github.com/electron/electron/pull/13756) · Sep 10, 2018 at 10:08pm **nitsakh** mentioned this in PR [`#14847`: feat: Implement process.getProcessMemoryInfo to get the process memory usage](https://github.com/electron/electron/pull/14847) · Oct 4, 2018 at 6:30am **`@nitsakh`** commented · Oct 4, 2018 at 6:31am > /cc `@electron/reviewers` Request your suggestions for the above PR and the API changes. **MarshallOfSound** mentioned this in issue [`#16179`: `app.getAppMetrics()` and `ProcessMetric` - memory no longer available](https://github.com/electron/electron/issues/16179) · Dec 22, 2018 at 10:13pm **`@bpasero`** commented · Jan 8, 2019 at 11:48am > `@alexeykuzmin` `@nitsakh` is this still an issue given https://github.com/electron/electron/pull/14847 landed? I cannot find it in Electron 4.0.x though, so not sure if its 5.0.x only? **bpasero** mentioned this in issue [`#54801`: Replace call to process.getProcessMemoryInfo](https://github.com/microsoft/vscode/issues/54801) · Jan 8, 2019 at 11:48am **`@codebytere`** commented · Mar 20, 2019 at 10:24pm > This is completed and released in 5-0-x. **codebytere** closed this · Mar 20, 2019 at 10:24pm</excerpt>
</source>
<source>
<title>services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc - chromium/src - Git at Google</title>
<location>https://chromium.googlesource.com/chromium/src/+/227a6ffe303aa697ab4b344db93f6b35f9ce3b4c/services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc</location>
<excerpt>| void QueuedRequestDispatcher::SetUpAndDispatch( | | QueuedRequest* request, | | const std::vector & clients, | | const ChromeCallback& chrome_callback, | | const OsCallback& os_callback) { | | using ResponseType = QueuedRequest::PendingResponse::Type; | ... // Note: ... a ClientProcess and | | ... other process for ... memory dumps. | ... | // Don&`#39`;t request a chrome memory dump at all if the client wants only the | | // processes&`#39`; vm regions, which are retrieved via RequestOSMemoryDump(). | | if (request->wants_chrome_dumps()) { | | request->pending_responses.insert({client, ResponseType::kChromeDump}); | | client->RequestChromeMemoryDump(request->args, | | base::Bind(chrome_callback, client)); | | } | ... // On most platforms each ... ->wants_mmaps ... os_callback ... | `#endif` // !defined ... LINUX) | ... | void QueuedRequestDispatcher::Finalize(QueuedRequest* request, | | TracingObserver* tracing_observer) { | | DCHECK( ... | // Reconstruct a map of pid -> ProcessMemoryDump by reassembling the responses | | // received by the clients for this dump. In some cases the response coming | | // from one client can also provide the dump of OS counters for other | | // processes. A concrete case is Linux, where the browser process provides | | // details for the child processes to get around sandbox restrictions on | | // opening /proc pseudo files. | | // All the pointers in the maps will continue to be owned by |request| | | // which outlives these containers. | | std::map<base::ProcessId, mojom::ProcessType> pid_to_process_type; | | std::map<base::ProcessId, const base::trace_event::ProcessMemoryDump*> | | pid_to_pmd; | | std::map<base::ProcessId, mojom::RawOSMemDump*> pid_to_os_dump; | ... | for (auto& response : request->responses) { | | const base::ProcessId& original_pid = response.second.process_id; | | pid_to_process_type[original_pid] = response.second.process_type; | | // |chrome_dump| can be nullptr if this was a OS-counters only response. | | pid_to_pmd[original_pid] = response.second.chrome_dump.get(); | ... | // |response| accumulates the replies received by each client process. | | // Depending on the OS each client process might return 1 chrome + 1 OS | | // dump each or, in the case of Linux, only 1 chrome dump each % the | | // browser process which will provide all the OS dumps. | | // In the former case (!OS_LINUX) we expect client processes to have | | // exactly one OS dump in their |response|, % the case when they | | // unexpectedly disconnect in the middle of a dump (e.g. because they | | // crash). In the latter case (OS_LINUX) we expect the full map to come | | // from the browser process response. | | OSMemDumpMap& extra_os_dumps = response.second.os_dumps; | ... | `#if` defined(OS_LINUX) | | for (const auto& kv : extra_os_dumps) { | | auto pid = kv.first == base::kNullProcessId ? original_pid : kv.first; | | DCHECK_EQ(pid_to_os_dump[pid], nullptr); | | pid_to_os_dump[pid] = kv.second.get(); | | } | ... | `#else` | ... dumps) { ... | // Generate the global memory graph from the map of pids to dumps, removing | | // weak nodes. | | std::unique_ptr global_graph = | | GraphProcessor::CreateMemoryGraph(pid_to_pmd); | | GraphProcessor::RemoveWeakNodesFromGraph(global_graph.get()); | ... , uint64 ... | // Build up the global dump by iterating on the |valid| process dumps. | | mojom::GlobalMemoryDumpPtr global_dump(mojom::GlobalMemoryDump::New()); | | global_dump->process_dumps.reserve(request->responses.size()); | ... | for (const auto& response : request->responses) { | | base::ProcessId pid = response.second.process_id; | | // These pointers are owned by |request|. | | mojom::RawOSMemDump* raw_os_dump = pid_to_os_dump[pid]; | | auto* raw_chrome_dump = pid_to_pmd[pid]; | | // If we have the OS dump we should have the platform private footprint. | | DCHECK(!raw_os_dump || raw_os_dump->platform_private_footprint…[truncated]</excerpt>
</source>
</source_evidence>
Citations:
- 1: https://electronjs.org/docs/latest/api/process
- 2: https://electronjs.org/docs/latest/api/structures/process-memory-info
- 3: GitHub issue 28114 in electron/electron (link omitted to avoid creating a cross-reference)
- 4: GitHub issue 13447 in electron/electron (link omitted to avoid creating a cross-reference)
- 5: https://chromium.googlesource.com/chromium/src/+/227a6ffe303aa697ab4b344db93f6b35f9ce3b4c/services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc
🌐 Web query:
Electron v43.7.0 source process.getProcessMemoryInfo implementation
💡 Result:
<source_evidence>
<source>
<title>shell/common/api/electron_bindings.cc at c16c6da2 · electron/electron</title>
<location>https://github.com/electron/electron/blob/c16c6da2/shell/common/api/electron_bindings.cc</location>
<excerpt>// static void ElectronBindings::BindProcess(v8::Isolate* isolate, gin_helper::Dictionary* process, base::ProcessMetrics* metrics) { // These bindings are shared between sandboxed & unsandboxed renderers process->SetMethod("crash", &Crash); process->SetMethod("hang", &Hang); process->SetMethod("getCreationTime", &GetCreationTime); process->SetMethod("getHeapStatistics", &GetHeapStatistics); process->SetMethod("getBlinkMemoryInfo", &GetBlinkMemoryInfo); if (electron::IsBrowserProcess()) { process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); } process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); process->SetMethod("getSystemVersion", &base::SysInfo::OperatingSystemVersion); process->SetMethod("getCPUUsage", base::BindRepeating(&ElectronBindings::GetCPUUsage, base::Unretained(metrics))); ... // static v8::Local<v8::Promise> ElectronBindings::GetProcessMemoryInfo( v8::Isolate* isolate) { CHECK(electron::IsBrowserProcess()); gin_helper::Promise<gin_helper::Dictionary> promise(isolate); v8::Local<v8::Promise> handle = promise.GetHandle(); if (!Browser::Get()->is_ready()) { promise.RejectWithErrorMessage( "Memory Info is available only after app ready"); return handle; } v8::Global<v8::Context> context(isolate, isolate->GetCurrentContext()); memory_instrumentation::MemoryInstrumentation::GetInstance() ->RequestGlobalDumpForPid( base::GetCurrentProcId(), {} /* allocator_dump_names */, base::BindOnce(&ElectronBindings::DidReceiveMemoryDump, std::move(context), std::move(promise), base::GetCurrentProcId())); return handle; }</excerpt>
</source>
<source>
<title>shell/common/api/electron_bindings.cc</title>
<location>https://github.com/electron/electron/blob/bae71626/shell/common/api/electron_bindings.cc</location>
<excerpt>// static void ElectronBindings::BindProcess(v8::Isolate* isolate, gin_helper::Dictionary* process, base::ProcessMetrics* metrics) { // These bindings are shared between sandboxed & unsandboxed renderers process->SetMethod("crash", &Crash); process->SetMethod("hang", &Hang); process->SetMethod("getCreationTime", &GetCreationTime); process->SetMethod("getHeapStatistics", &GetHeapStatistics); process->SetMethod("getBlinkMemoryInfo", &GetBlinkMemoryInfo); if (electron::IsBrowserProcess()) { process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); } process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); process->SetMethod("getSystemVersion", &base::SysInfo::OperatingSystemVersion); process->SetMethod("getCPUUsage", base::BindRepeating(&ElectronBindings::GetCPUUsage, base::Unretained(metrics))); ... // static v8::Local ElectronBindings::GetProcessMemoryInfo( v8::Isolate* isolate) { CHECK(electron::IsBrowserProcess()); gin_helper::Promise<gin_helper::Dictionary> promise(isolate); v8::Local handle = promise.GetHandle(); if (!Browser::Get()->is_ready()) { promise.RejectWithErrorMessage( "Memory Info is available only after app ready"); return handle; } memory_instrumentation::MemoryInstrumentation::GetInstance() ->RequestGlobalDumpForPid( base::GetCurrentProcId(), {} /* allocator_dump_names */, base::BindOnce(&ElectronBindings::DidReceiveMemoryDump, std::move(promise), base::GetCurrentProcId())); return handle; }</excerpt>
</source>
<source>
<title>docs/api/process.md</title>
<location>https://github.com/electron/electron/blob/bae71626/docs/api/process.md</location>
<excerpt>* `crash()` * `hang()` * `getCreationTime()` * `getHeapStatistics()` * `getBlinkMemoryInfo()` * `getProcessMemoryInfo()` * `getSystemMemoryInfo()` * `getSystemVersion()` * `getCPUUsage()` * `uptime()` * `argv` * `execPath` * `env` * `pid` * `arch` * `platform` * `sandboxed` * `contextIsolated` * `type` * `version` * `versions` * `mas` * `windowsStore` * `contextId` ... ### `process.getProcessMemoryInfo()` ... Returns `Promise ` - Resolves with a ProcessMemoryInfo ... Returns an object giving memory usage statistics about the current process. Note that all statistics are reported in Kilobytes. This api should be called after app ready. ... Chromium does not provide `residentSet` value for macOS. This is because macOS performs in-memory compression of pages that haven&`#39`;t been recently used. As a result the resident set size value is not what one would expect. `private` memory is more representative of the actual pre-compression memory usage of the process on macOS.</excerpt>
</source>
<source>
<title>refactor: only access memory coordinator interface from browser process · Pull Request `#31295` · electron/electron</title>
<location>GitHub pull request 31295 in electron/electron (link omitted to avoid creating a cross-reference)</location>
<excerpt>## refactor: only access memory coordinator interface from browser process ... Currently implementation of `process.getProcessMemoryInfo` accesses the coordinator directly from the renderer process. This PR refactors the internal implementation to accommodate the upstream change while maintaining the user facing api and does not introduce any behavior changes. ... > `@pushkin-` every child process including the browser registers itself as a client with the resource coordinator service that lives inside the browser process, the coordinator is interface that can be used to talk with the clients to get respective memory dumps. At the end of day, the clients are responsible to collect the dumps and send them to the coordinator. > > This PR only changes the point of access to the coordinator interface, even before this PR accessing the coordinator from the renderer causes it talk to the browser process via mojo to get the interface. With this PR it makes it clear where the coordinator lives and there is no behavior change.</excerpt>
</source>
<source>
<title>docs/api/structures/process-memory-info.md</title>
<location>https://github.com/electron/electron/blob/main/docs/api/structures/process-memory-info.md</location>
<excerpt># docs/api/structures/process-memory-info.md - Branch: main - Repository: electron/electron --- # ProcessMemoryInfo Object * `residentSet` Integer _Linux_ _Windows_ - The amount of memory currently pinned to actual physical RAM in Kilobytes. * `private` Integer - The amount of memory not shared by other processes, such as JS heap or HTML content in Kilobytes. * `shared` Integer - The amount of memory shared between processes, typically memory consumed by the Electron code itself in Kilobytes.</excerpt>
</source>
</source_evidence>
Citations:
- 1: https://github.com/electron/electron/blob/c16c6da2/shell/common/api/electron_bindings.cc
- 2: https://github.com/electron/electron/blob/bae71626/shell/common/api/electron_bindings.cc
- 3: https://github.com/electron/electron/blob/bae71626/docs/api/process.md
- 4: GitHub pull request 31295 in electron/electron (link omitted to avoid creating a cross-reference)
- 5: https://github.com/electron/electron/blob/main/docs/api/structures/process-memory-info.md
- 6: GitHub pull request 14847 in electron/electron (link omitted to avoid creating a cross-reference)
- 7: https://releases.electronjs.org/release/v43.7.0
🏁 Script executed:
sed -n '58,100p' src/renderer/src/lib/renderer-memory-sampling.tsRepository: stablyai/orca
Length of output: 1847
Carry the process-memory measurement time through the bridge.
Electron 43.7.0 starts a global memory dump for process.getProcessMemoryInfo() and returns its result asynchronously. readRendererProcessMemory() does not preserve the dump time. Line 118 records Date.now() only after settlement and reads heap metrics at that later time. If the dump completes before settlement, the next breadcrumb reports an age that is too small and can calculate an incorrect outsideHeapMB.
Carry an authoritative measurement timestamp through the bridge. If that timestamp is unavailable, omit the age and paired outsideHeapMB calculation for this reading.

Description
This PR changes diagnostics only. The app behaves the same for users. It fixes misleading memory numbers in the
renderer_memorycrash breadcrumbs. These numbers are the timeline we use to investigate the Scan-23 cluster of native renderer crashes on v1.4.210. Five crashes could not be symbolized, and they are reported in Slack channel C0B4PDCMPPT.recordRendererMemorySample()insrc/renderer/src/lib/renderer-memory-sampling.tsemits the process footprint that is already cached, and only after that starts a new background read. As a result, theprivateMBandresidentMBvalues in each crumb are one sampling interval (~60 s) older than theusedHeapMBnext to them.outsideHeapMBwas calculated as that old footprint minus the current heap, so it mixed two moments. It often clamped to 0 when the heap was growing. Nothing in the crumb said the footprint was old. In bundle F0C4339L5R9, a footprint jump from 254 to 633 MB appeared to happen 43 s before a crash. It was actually read about 104 s before the crash.ELI5
Every minute, the app writes down how much memory it is using. One of those numbers was written from last minute's reading and not labeled as old, and a second number mixed the old reading with a new one. So when we looked back after a crash, events seemed to happen later than they did. Now each note says how old that reading is, and the mixed number uses readings taken at the same moment.
What Changed
Before: A
renderer_memorycrumb showedprivateMB: 254next tousedHeapMB: 400, but the 254 came from the read one interval earlier.outsideHeapMBcame out as0, the clamped result of 254 − 430. A reader could not tell that any of these values were old.After:
lastFootprintReading: { footprint, readAtMs, heapAccountedBytes }.outsideHeapMBis now the footprint minus the heap measured at the same moment. If no heap reading was available at that moment, the field is left out, so the crumb never shows a mixed value.footprintAgeMs(now − readAtMs, never below 0), on bothrenderer_memoryandrenderer_memory_highwatercrumbs.privateMB,residentMBandmallocedMBkeep the same names and meanings. Nothing was renamed or removed.settle()now clears the in-flight flag before it reads the heap, and the heap read is wrapped in try/catch. A heap bridge that throws can no longer block all later footprint refreshes.Why
We kept the crumb emitted at the same moment and added a label to it. We considered making the sample wait for the async
getProcessMemoryInfo()call and emitting afterwards. We rejected that for two reasons:With this change, readers get an
outsideHeapMBwhose two parts come from the same moment, and an exact age they can use to placeprivateMB/residentMBcorrectly on the timeline. They no longer have to guess "about 60 s".Fix evidence
The new test in
crash-diagnostics.test.tstakes two samples 60 s apart, withDate.nowmocked. The first sample sees a 150 MB heap and a 254 MB footprint. The second sees a 400 MB heap and a 633 MB footprint. These numbers come from bundle F0C4339L5R9.Before the fix (the new test fails):
After the fix:
That run covers
crash-diagnostics.test.ts,renderer-memory-profile.test.tsandsrc/preload/renderer-process-memory-reader.test.ts. I re-ran it on the pushed head.crash-diagnostics.test.tsalso passed 19/19 on 3 repeat runs.pnpm tc:web,oxlint,oxfmt --checkandpnpm run check:code-quality:changedpass, the last with 0 new findings.Trade-offs
privateMBandresidentMBare still about one interval old. They are now labeled as old, not made current, so timeline analysis must usefootprintAgeMs.footprintAgeMs.outsideHeapMBno longer lines up withusedHeapMBin the same crumb. It lines up with the heap fromfootprintAgeMsago.footprintAgeMs. Treat those as about one interval (~60 s) old.mallocedMBis 1 MB in every sample, so it tells us nothing. I left it as it is, because removing it would change the schema without a clear benefit.Adversarial review
The review took 2 loops to come back clean.
settle()ran before the in-flight flag was cleared. If it threw, the flag would stay set, every later footprint refresh would be skipped for the rest of the session, and the rejection would go unhandled. The fix clears the flag first and wraps the heap read in try/catch.Date.nowonly after its assertions, so a failing assertion would leave it mocked for the tests after it. The fix restores it before asserting.footprintAgeMsto 0 or moreprivateMBin the repo, inprocess-gone-diagnostics.ts, is unrelated and does not read these crumbsLinked Issue
No GitHub issue. This comes from the Scan-23 crash scan: the v1.4.210 native renderer crash cluster in Slack channel C0B4PDCMPPT.
Visual Proof
N/A. This changes diagnostics breadcrumb fields only. Nothing in the UI or in how the app behaves changes.
Testing
I added a reproduction test to
crash-diagnostics.test.ts, and the related test files pass. The change is platform-independent renderer code and does not touch SSH or remote paths.AI Disclosure
Written with Claude Code (Claude Opus).
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)