mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibWebView: Add a browser flag to collect garbage after each allocation
This commit is contained in:
parent
171af8de33
commit
be1d400369
Notes:
github-actions[bot]
2024-10-31 23:37:36 +00:00
Author: https://github.com/trflynn89
Commit: be1d400369
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2088
4 changed files with 17 additions and 0 deletions
|
@ -104,6 +104,9 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
|
||||||
arguments.append("--force-cpu-painting"sv);
|
arguments.append("--force-cpu-painting"sv);
|
||||||
if (web_content_options.force_fontconfig == WebView::ForceFontconfig::Yes)
|
if (web_content_options.force_fontconfig == WebView::ForceFontconfig::Yes)
|
||||||
arguments.append("--force-fontconfig"sv);
|
arguments.append("--force-fontconfig"sv);
|
||||||
|
if (web_content_options.collect_garbage_on_every_allocation == WebView::CollectGarbageOnEveryAllocation::Yes)
|
||||||
|
arguments.append("--collect-garbage-on-every-allocation"sv);
|
||||||
|
|
||||||
if (auto server = mach_server_name(); server.has_value()) {
|
if (auto server = mach_server_name(); server.has_value()) {
|
||||||
arguments.append("--mach-server-name"sv);
|
arguments.append("--mach-server-name"sv);
|
||||||
arguments.append(server.value());
|
arguments.append(server.value());
|
||||||
|
|
|
@ -105,6 +105,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
bool enable_http_cache = false;
|
bool enable_http_cache = false;
|
||||||
bool force_cpu_painting = false;
|
bool force_cpu_painting = false;
|
||||||
bool force_fontconfig = false;
|
bool force_fontconfig = false;
|
||||||
|
bool collect_garbage_on_every_allocation = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_option(command_line, "Chrome process command line", "command-line", 0, "command_line");
|
args_parser.add_option(command_line, "Chrome process command line", "command-line", 0, "command_line");
|
||||||
|
@ -122,6 +123,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
|
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
|
||||||
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
|
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
|
||||||
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
|
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
|
||||||
|
args_parser.add_option(collect_garbage_on_every_allocation, "Collect garbage after every JS heap allocation", "collect-garbage-on-every-allocation");
|
||||||
|
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
@ -171,6 +173,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Window));
|
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Window));
|
||||||
|
|
||||||
|
if (collect_garbage_on_every_allocation)
|
||||||
|
Web::Bindings::main_thread_vm().heap().set_should_collect_on_every_allocation(true);
|
||||||
|
|
||||||
TRY(initialize_resource_loader(Web::Bindings::main_thread_vm().heap(), request_server_socket));
|
TRY(initialize_resource_loader(Web::Bindings::main_thread_vm().heap(), request_server_socket));
|
||||||
|
|
||||||
if (log_all_js_exceptions) {
|
if (log_all_js_exceptions) {
|
||||||
|
|
|
@ -78,6 +78,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
|
||||||
bool expose_internals_object = false;
|
bool expose_internals_object = false;
|
||||||
bool force_cpu_painting = false;
|
bool force_cpu_painting = false;
|
||||||
bool force_fontconfig = false;
|
bool force_fontconfig = false;
|
||||||
|
bool collect_garbage_on_every_allocation = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("The Ladybird web browser :^)");
|
args_parser.set_general_help("The Ladybird web browser :^)");
|
||||||
|
@ -98,6 +99,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
|
||||||
args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object");
|
args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object");
|
||||||
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
|
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
|
||||||
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
|
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
|
||||||
|
args_parser.add_option(collect_garbage_on_every_allocation, "Collect garbage after every JS heap allocation", "collect-garbage-on-every-allocation", 'g');
|
||||||
args_parser.add_option(Core::ArgsParser::Option {
|
args_parser.add_option(Core::ArgsParser::Option {
|
||||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||||
.help_string = "Name of the User-Agent preset to use in place of the default User-Agent",
|
.help_string = "Name of the User-Agent preset to use in place of the default User-Agent",
|
||||||
|
@ -153,6 +155,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
|
||||||
.force_cpu_painting = force_cpu_painting ? ForceCPUPainting::Yes : ForceCPUPainting::No,
|
.force_cpu_painting = force_cpu_painting ? ForceCPUPainting::Yes : ForceCPUPainting::No,
|
||||||
.force_fontconfig = force_fontconfig ? ForceFontconfig::Yes : ForceFontconfig::No,
|
.force_fontconfig = force_fontconfig ? ForceFontconfig::Yes : ForceFontconfig::No,
|
||||||
.enable_autoplay = enable_autoplay ? EnableAutoplay::Yes : EnableAutoplay::No,
|
.enable_autoplay = enable_autoplay ? EnableAutoplay::Yes : EnableAutoplay::No,
|
||||||
|
.collect_garbage_on_every_allocation = collect_garbage_on_every_allocation ? CollectGarbageOnEveryAllocation::Yes : CollectGarbageOnEveryAllocation::No,
|
||||||
};
|
};
|
||||||
|
|
||||||
create_platform_options(m_chrome_options, m_web_content_options);
|
create_platform_options(m_chrome_options, m_web_content_options);
|
||||||
|
|
|
@ -95,6 +95,11 @@ enum class ForceFontconfig {
|
||||||
Yes,
|
Yes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class CollectGarbageOnEveryAllocation {
|
||||||
|
No,
|
||||||
|
Yes,
|
||||||
|
};
|
||||||
|
|
||||||
struct WebContentOptions {
|
struct WebContentOptions {
|
||||||
String command_line;
|
String command_line;
|
||||||
String executable_path;
|
String executable_path;
|
||||||
|
@ -108,6 +113,7 @@ struct WebContentOptions {
|
||||||
ForceCPUPainting force_cpu_painting { ForceCPUPainting::No };
|
ForceCPUPainting force_cpu_painting { ForceCPUPainting::No };
|
||||||
ForceFontconfig force_fontconfig { ForceFontconfig::No };
|
ForceFontconfig force_fontconfig { ForceFontconfig::No };
|
||||||
EnableAutoplay enable_autoplay { EnableAutoplay::No };
|
EnableAutoplay enable_autoplay { EnableAutoplay::No };
|
||||||
|
CollectGarbageOnEveryAllocation collect_garbage_on_every_allocation { CollectGarbageOnEveryAllocation::No };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue