feat: add child-process-gone event to app (#24367)

This commit is contained in:
Milan Burda 2020-07-20 16:34:16 +02:00 committed by GitHub
parent f146a164af
commit fa1323d6cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 1 deletions

View file

@ -360,7 +360,7 @@ page.
Emitted whenever there is a GPU info update. Emitted whenever there is a GPU info update.
### Event: 'gpu-process-crashed' ### Event: 'gpu-process-crashed' _Deprecated_
Returns: Returns:
@ -369,6 +369,11 @@ Returns:
Emitted when the GPU process crashes or is killed. Emitted when the GPU process crashes or is killed.
**Deprecated:** This event is superceded by the `child-process-gone` event
which contains more information about why the child process dissapeared. It
isn't always because it crashed. The `killed` boolean can be replaced by
checking `reason === 'killed'` when you switch to that event.
### Event: 'renderer-process-crashed' _Deprecated_ ### Event: 'renderer-process-crashed' _Deprecated_
Returns: Returns:
@ -403,6 +408,36 @@ Returns:
Emitted when the renderer process unexpectedly dissapears. This is normally Emitted when the renderer process unexpectedly dissapears. This is normally
because it was crashed or killed. because it was crashed or killed.
#### Event: 'child-process-gone'
Returns:
* `event` Event
* `details` Object
* `type` String - Process type. One of the following values:
* `Utility`
* `Zygote`
* `Sandbox helper`
* `GPU`
* `Pepper Plugin`
* `Pepper Plugin Broker`
* `Unknown`
* `reason` String - The reason the child process is gone. Possible values:
* `clean-exit` - Process exited with an exit code of zero
* `abnormal-exit` - Process exited with a non-zero exit code
* `killed` - Process was sent a SIGTERM or otherwise killed externally
* `crashed` - Process crashed
* `oom` - Process ran out of memory
* `launch-failure` - Process never successfully launched
* `integrity-failure` - Windows code integrity checks failed
* `exitCode` Number - The exit code for the process
(e.g. status from waitpid if on posix, from GetExitCodeProcess on Windows).
* `name` String (optional) - The name of the process. i.e. for plugins it might be Flash.
Examples for utility: `Audio Service`, `Content Decryption Module Service`, `Network Service`, `Video Capture`, etc.
Emitted when the child process unexpectedly dissapears. This is normally
because it was crashed or killed. It does not include renderer processes.
### Event: 'accessibility-support-changed' _macOS_ _Windows_ ### Event: 'accessibility-support-changed' _macOS_ _Windows_
Returns: Returns:

View file

@ -803,12 +803,28 @@ void App::BrowserChildProcessCrashed(
const content::ChildProcessData& data, const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) { const content::ChildProcessTerminationInfo& info) {
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle())); ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
BrowserChildProcessCrashedOrKilled(data, info);
} }
void App::BrowserChildProcessKilled( void App::BrowserChildProcessKilled(
const content::ChildProcessData& data, const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) { const content::ChildProcessTerminationInfo& info) {
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle())); ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
BrowserChildProcessCrashedOrKilled(data, info);
}
void App::BrowserChildProcessCrashedOrKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
v8::HandleScope handle_scope(isolate());
auto details = gin_helper::Dictionary::CreateEmpty(isolate());
details.Set("type", content::GetProcessTypeNameInEnglish(data.process_type));
details.Set("reason", info.status);
details.Set("exitCode", info.exit_code);
if (!data.name.empty()) {
details.Set("name", data.name);
}
Emit("child-process-gone", details);
} }
void App::RenderProcessReady(content::RenderProcessHost* host) { void App::RenderProcessReady(content::RenderProcessHost* host) {

View file

@ -157,6 +157,10 @@ class App : public ElectronBrowserClient::Delegate,
const content::ChildProcessTerminationInfo& info) override; const content::ChildProcessTerminationInfo& info) override;
private: private:
void BrowserChildProcessCrashedOrKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info);
void SetAppPath(const base::FilePath& app_path); void SetAppPath(const base::FilePath& app_path);
void ChildProcessLaunched(int process_type, void ChildProcessLaunched(int process_type,
base::ProcessHandle handle, base::ProcessHandle handle,