mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
feat: enable WASM trap handlers in all Node.js processes (#48983)
fix: enable WASM trap handlers in all Node.js processes ``` Original reason for revert: Some apps started throwing exception on startup https://github.com/electron/electron/issues/48956 ``` We now move the trap handler registeration before any user script execution. Add a fuse to support disabling the feature is application needs to run in memory constrained environments.
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "content/public/common/process_type.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/fuses.h"
|
||||
#include "media/base/localized_strings.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h"
|
||||
@@ -62,6 +63,7 @@
|
||||
#include "shell/common/logging.h"
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/v8_util.h"
|
||||
#include "ui/base/idle/idle.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
@@ -238,6 +240,15 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
||||
v8::Isolate* const isolate = js_env_->isolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
// Enable trap handlers before user script execution.
|
||||
#if ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)) && \
|
||||
defined(ARCH_CPU_X86_64)) || \
|
||||
((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)) && defined(ARCH_CPU_ARM64))
|
||||
if (electron::fuses::IsWasmTrapHandlersEnabled()) {
|
||||
electron::SetUpWebAssemblyTrapHandler();
|
||||
}
|
||||
#endif
|
||||
|
||||
node_bindings_->Initialize(isolate, isolate->GetCurrentContext());
|
||||
// Create the global environment.
|
||||
node_env_ = node_bindings_->CreateEnvironment(
|
||||
|
||||
Reference in New Issue
Block a user