LibWebView+UI: Raise the chrome process open file limit

The default limit (at least on Linux) causes us to run out of file
descriptors at around 15 tabs. Increase this limit to 8k. This is a
rather arbitrary number, but matches the limit set by Chrome.
This commit is contained in:
Timothy Flynn 2024-07-22 10:17:44 -04:00 committed by Andreas Kling
parent 4451b4fda0
commit d58a8b5146
Notes: github-actions[bot] 2024-07-23 07:40:33 +00:00
4 changed files with 15 additions and 4 deletions

View file

@ -103,7 +103,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(allow_popups, "Disable popup blocking by default", "allow-popups");
args_parser.parse(arguments);
WebView::ChromeProcess chrome_process;
auto chrome_process = TRY(WebView::ChromeProcess::create());
if (!force_new_process && TRY(chrome_process.connect(raw_urls, new_window)) == WebView::ChromeProcess::ProcessDisposition::ExitProcess) {
outln("Opening in existing process");
return 0;

View file

@ -119,7 +119,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(allow_popups, "Disable popup blocking by default", "allow-popups");
args_parser.parse(arguments);
WebView::ChromeProcess chrome_process;
auto chrome_process = TRY(WebView::ChromeProcess::create());
if (!force_new_process && TRY(chrome_process.connect(raw_urls, new_window)) == WebView::ChromeProcess::ProcessDisposition::ExitProcess) {
outln("Opening in existing process");
return 0;

View file

@ -7,6 +7,7 @@
#include <AK/ByteString.h>
#include <LibCore/Process.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/System.h>
#include <LibIPC/ConnectionToServer.h>
#include <LibWebView/ChromeProcess.h>
@ -22,6 +23,14 @@ private:
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.
TRY(Core::System::set_resource_limits(RLIMIT_NOFILE, 8192));
return ChromeProcess {};
}
ErrorOr<ChromeProcess::ProcessDisposition> ChromeProcess::connect(Vector<ByteString> const& raw_urls, bool new_window)
{
static constexpr auto process_name = "Ladybird"sv;

View file

@ -40,7 +40,7 @@ private:
class ChromeProcess {
AK_MAKE_NONCOPYABLE(ChromeProcess);
AK_MAKE_NONMOVABLE(ChromeProcess);
AK_MAKE_DEFAULT_MOVABLE(ChromeProcess);
public:
enum class ProcessDisposition : u8 {
@ -48,7 +48,7 @@ public:
ExitProcess,
};
ChromeProcess() = default;
static ErrorOr<ChromeProcess> create();
~ChromeProcess();
ErrorOr<ProcessDisposition> connect(Vector<ByteString> const& raw_urls, bool new_window);
@ -57,6 +57,8 @@ public:
Function<void(Vector<ByteString> const& raw_urls)> on_new_window;
private:
ChromeProcess() = default;
ErrorOr<void> connect_as_client(ByteString const& socket_path, Vector<ByteString> const& raw_urls, bool new_window);
ErrorOr<void> connect_as_server(ByteString const& socket_path);