new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Electron · API · all subjects

webcontents: process

18 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

CPUUsage object properties

The CPUUsage object contains three properties: percentCPUUsage (number, percentage of CPU used since the last call to the API that returned this object, first call returns 0), cumulativeCPUUsage (number, optional, total seconds of CPU time used since process startup), and idleWakeupsPerSecond (number, average idle CPU wakeups per second since the last call, first call returns 0, always returns 0 on Windows).

percentCPUUsage and idleWakeupsPerSecond are averages

percentCPUUsage and idleWakeupsPerSecond are averages rather than instant samples. Each call starts a fresh measurement interval.

process.getCPUUsage() measurement interval

process.getCPUUsage() measures the process it is called in. Only calls to process.getCPUUsage() in that same process reset its interval.

app.getAppMetrics() measurement interval

app.getAppMetrics() measures every process in the app as the cpu property of each ProcessMetric. It keeps a separate interval for each process ID, and a single call resets all of them at once, since one call reports on every process.

CPUUsage measurement intervals are independent

Each API's measurement interval is independent. Calling process.getCPUUsage() does not change what app.getAppMetrics() reports and vice-versa. The main process can report different percentCPUUsage values through each API at the same moment.

Measuring CPU usage over a controlled interval

To measure an interval you control, use cumulativeCPUUsage instead of percentCPUUsage. Subtract an earlier reading from a later one to get usage over that span. Reading cumulativeCPUUsage still means calling app.getAppMetrics() or process.getCPUUsage(), which starts a new interval for everyone else.

ProcessMetric object pid property

The pid property is an Integer representing the process id of the process.

ProcessMetric object type property values

The type property is a string that identifies the process type. Valid values are: Browser, Tab, Utility, Zygote, Sandbox helper, GPU, Pepper Plugin, Pepper Plugin Broker, Unknown.

ProcessMetric object serviceName property

The serviceName property is an optional string representing the non-localized name of the process.

ProcessMetric object name property

The name property is an optional string representing the name of the process. Examples for utility processes include: Audio Service, Content Decryption Module Service, Network Service, Video Capture.

ProcessMetric object cpu property

The cpu property is a CPUUsage object containing CPU usage information for the process. The percentCPUUsage and idleWakeupsPerSecond values are averages over the time since the previous call to the API returning this object.

ProcessMetric object creationTime property

The creationTime property is a number representing the creation time for the process in milliseconds since epoch. Since the pid can be reused after a process dies, use both the pid and creationTime together to uniquely identify a process.

ProcessMetric object memory property

The memory property is a MemoryInfo object containing memory information for the process.

ProcessMetric object sandboxed property

The sandboxed property is an optional boolean indicating whether the process is sandboxed on OS level. This property is available on macOS and Windows.

ProcessMetric object integrityLevel property values

The integrityLevel property is an optional string available on Windows that indicates the integrity level of the process. Valid values are: untrusted, low, medium, high, unknown.

webview runs in separate process

The webview tag runs in a separate process than the app and does not have the same permissions as the web page. All interactions between the app and embedded content are asynchronous.

webview process crash detection

isCrashed() returns boolean indicating whether the renderer process has crashed.

webview render-process-gone event

render-process-gone event fires when renderer process unexpectedly disappears, normally because it crashed or was killed. Returns: details (RenderProcessGoneDetails).

Give your agent this brain