mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibWebView: Increase the open file limit in a more central location
We don't create a ChromeProcess in headless-browser, so it is currently not increasing it's open file limit. This is causing crashes on macOS, which has a very low default limit.
This commit is contained in:
parent
cb4b2ca681
commit
598fabbdd3
Notes:
github-actions[bot]
2024-10-07 18:04:04 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/598fabbdd3e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1668 Reviewed-by: https://github.com/awesomekling ✅
5 changed files with 8 additions and 14 deletions
|
@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
platform_init();
|
platform_init();
|
||||||
|
|
||||||
auto chrome_process = TRY(WebView::ChromeProcess::create());
|
WebView::ChromeProcess chrome_process;
|
||||||
|
|
||||||
if (auto const& chrome_options = WebView::Application::chrome_options(); chrome_options.force_new_process == WebView::ForceNewProcess::No) {
|
if (auto const& chrome_options = WebView::Application::chrome_options(); chrome_options.force_new_process == WebView::ForceNewProcess::No) {
|
||||||
auto disposition = TRY(chrome_process.connect(chrome_options.raw_urls, chrome_options.new_window));
|
auto disposition = TRY(chrome_process.connect(chrome_options.raw_urls, chrome_options.new_window));
|
||||||
|
|
|
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
platform_init();
|
platform_init();
|
||||||
|
|
||||||
auto chrome_process = TRY(WebView::ChromeProcess::create());
|
WebView::ChromeProcess chrome_process;
|
||||||
|
|
||||||
if (app->chrome_options().force_new_process == WebView::ForceNewProcess::No) {
|
if (app->chrome_options().force_new_process == WebView::ForceNewProcess::No) {
|
||||||
auto disposition = TRY(chrome_process.connect(app->chrome_options().raw_urls, app->chrome_options().new_window));
|
auto disposition = TRY(chrome_process.connect(app->chrome_options().raw_urls, app->chrome_options().new_window));
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/Environment.h>
|
#include <LibCore/Environment.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <LibCore/TimeZoneWatcher.h>
|
#include <LibCore/TimeZoneWatcher.h>
|
||||||
#include <LibFileSystem/FileSystem.h>
|
#include <LibFileSystem/FileSystem.h>
|
||||||
#include <LibImageDecoderClient/Client.h>
|
#include <LibImageDecoderClient/Client.h>
|
||||||
|
@ -55,6 +56,10 @@ Application::~Application()
|
||||||
|
|
||||||
void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_page_url)
|
void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_page_url)
|
||||||
{
|
{
|
||||||
|
// Increase the open file limit, as the default limits on Linux cause us to run out of file descriptors with around 15 tabs open.
|
||||||
|
if (auto result = Core::System::set_resource_limits(RLIMIT_NOFILE, 8192); result.is_error())
|
||||||
|
warnln("Unable to increase open file limit: {}", result.error());
|
||||||
|
|
||||||
Vector<ByteString> raw_urls;
|
Vector<ByteString> raw_urls;
|
||||||
Vector<ByteString> certificates;
|
Vector<ByteString> certificates;
|
||||||
bool new_window = false;
|
bool new_window = false;
|
||||||
|
|
|
@ -25,15 +25,6 @@ private:
|
||||||
UIProcessClient(NonnullOwnPtr<Core::LocalSocket>);
|
UIProcessClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorOr<ChromeProcess> ChromeProcess::create()
|
|
||||||
{
|
|
||||||
// Increase the open file limit, as the default limits on Linux cause us to run out of file descriptors with around 15 tabs open.
|
|
||||||
if (auto result = Core::System::set_resource_limits(RLIMIT_NOFILE, 8192); result.is_error())
|
|
||||||
warnln("Unable to increase open file limit: {}", result.error());
|
|
||||||
|
|
||||||
return ChromeProcess {};
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<ChromeProcess::ProcessDisposition> ChromeProcess::connect(Vector<ByteString> const& raw_urls, NewWindow new_window)
|
ErrorOr<ChromeProcess::ProcessDisposition> ChromeProcess::connect(Vector<ByteString> const& raw_urls, NewWindow new_window)
|
||||||
{
|
{
|
||||||
static constexpr auto process_name = "Ladybird"sv;
|
static constexpr auto process_name = "Ladybird"sv;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
ExitProcess,
|
ExitProcess,
|
||||||
};
|
};
|
||||||
|
|
||||||
static ErrorOr<ChromeProcess> create();
|
ChromeProcess() = default;
|
||||||
~ChromeProcess();
|
~ChromeProcess();
|
||||||
|
|
||||||
ErrorOr<ProcessDisposition> connect(Vector<ByteString> const& raw_urls, NewWindow new_window);
|
ErrorOr<ProcessDisposition> connect(Vector<ByteString> const& raw_urls, NewWindow new_window);
|
||||||
|
@ -58,8 +58,6 @@ public:
|
||||||
Function<void(Vector<URL::URL> const&)> on_new_window;
|
Function<void(Vector<URL::URL> const&)> on_new_window;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChromeProcess() = default;
|
|
||||||
|
|
||||||
ErrorOr<void> connect_as_client(ByteString const& socket_path, Vector<ByteString> const& raw_urls, NewWindow new_window);
|
ErrorOr<void> connect_as_client(ByteString const& socket_path, Vector<ByteString> const& raw_urls, NewWindow new_window);
|
||||||
ErrorOr<void> connect_as_server(ByteString const& socket_path);
|
ErrorOr<void> connect_as_server(ByteString const& socket_path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue