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:
Timothy Flynn 2024-10-07 13:36:17 -04:00 committed by Tim Flynn
parent cb4b2ca681
commit 598fabbdd3
Notes: github-actions[bot] 2024-10-07 18:04:04 +00:00
5 changed files with 8 additions and 14 deletions

View file

@ -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));

View file

@ -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));

View file

@ -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;

View file

@ -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;

View file

@ -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);