SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.38k stars 3.18k forks source link

Ladybird: Chrome<->WebContent IPC gets deadlocked on reddit.com #22847

Open ADKaster opened 7 months ago

ADKaster commented 7 months ago

Repro:

On exit, I saw 261619.516 WebContent(404363): WebContent client disconnected during DidSetCookie. Exiting peacefully. which suggests that both of the IPC sockets are trying to do sync communication at the same time?

cc @trflynn89

ADKaster commented 7 months ago

Hrm maybe not both doing sync, but both sending for sure. In the GDB session I loaded up for each of the processes, I saw that the chrome was trying to send a mouse move (which is async) at the same time that the WebContent process was trying to send something. Possible Unix socket queue length problem?

trflynn89 commented 7 months ago

Hmm, the site is slow as molasses, but I'm not seeing the GUI totally freeze. I'm seeing the WebContentClient::DidSetCookie request from WC->UI. Then that blocks while the UI executes a few SQLServer::ExecuteStatement requests (also sync). Then that response goes from UI->WC and the WC wakes up.

ADKaster commented 7 months ago

Hrm. On my ubuntu 22.04 it is slow as molasses, but then it eventually gets to a point where Ladybird is here, after waving the mouse about a bit:

#0  __libc_send (flags=<optimized out>, len=40, buf=0x7fff11ebbf88, fd=24) at ../sysdeps/unix/sysv/linux/send.c:28
#1  __libc_send (fd=24, buf=0x7fff11ebbf88, len=40, flags=0) at ../sysdeps/unix/sysv/linux/send.c:23
#2  0x00007fd7ae3a4b14 in Core::System::send(int, void const*, unsigned long, int) (sockfd=24, buffer=0x7fff11ebbf88, buffer_length=40, flags=0)
    at /home/andrew/serenity/Userland/Libraries/LibCore/System.cpp:1467
#3  0x00007fd7ae39aec7 in Core::PosixSocketHelper::write(AK::Span<unsigned char const>, int) (this=<optimized out>, buffer=..., flags=0)
    at /home/andrew/serenity/Userland/Libraries/LibCore/Socket.cpp:125
<snip ...>
#8  0x00005568d12b693c in WebContentServerProxy<WebContentClientEndpoint, WebContentServerEndpoint>::async_mouse_move(Gfx::Point<AK::DistinctNumeric<int, Web::__DevicePixels_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::CastToUnderlying, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment> >, Gfx::Point<AK::DistinctNumeric<int, Web::__DevicePixels_tag, AK::DistinctNumericFeature::Arithmetic, AK::DistinctNumericFeature::CastToUnderlying, AK::DistinctNumericFeature::Comparison, AK::DistinctNumericFeature::Increment> >, unsigned int, unsigned int, unsigned int) (this=0x5568d2103fb0, position=..., screen_position=..., button=0, buttons=0, modifiers=0)
    at Userland/Services/WebContent/WebContentServerEndpoint.h:4610
#9  Ladybird::WebContentView::mouseMoveEvent(QMouseEvent*) (this=0x5568d2e22090, event=<optimized out>) at /home/andrew/serenity/Ladybird/Qt/WebContentView.cpp:326

Sending a mouseMove

And WebContent is here:

#0  0x00007fa6f03278b0 in __libc_send (fd=25, buf=0x7ffe2b910068, len=16, flags=0) at ../sysdeps/unix/sysv/linux/send.c:28
#1  0x00007fa6f29a4b14 in Core::System::send (sockfd=25, buffer=0x7ffe2b910068, buffer_length=16, flags=0) at /home/andrew/serenity/Userland/Libraries/LibCore/System.cpp:1467
#2  0x00007fa6f299aec7 in Core::PosixSocketHelper::write (this=<optimized out>, buffer=..., flags=0) at /home/andrew/serenity/Userland/Libraries/LibCore/Socket.cpp:125
#3  0x00007fa6f2f9054d in Core::LocalSocket::write_some (this=0x564335c9e030, buffer=...) at /home/andrew/serenity/Meta/Lagom/../../Userland/Libraries/LibCore/Socket.h:314
#4  IPC::MessageBuffer::transfer_message (this=0x7ffe2b910058, fd_passing_socket=..., data_socket=...) at /home/andrew/serenity/Userland/Libraries/LibIPC/Message.cpp:58
#5  0x00007fa6f2f8a400 in IPC::ConnectionBase::post_message (this=this@entry=0x564335d04140, buffer=...) at /home/andrew/serenity/Userland/Libraries/LibIPC/Connection.cpp:62
#6  0x00007fa6f2f8a32e in IPC::ConnectionBase::post_message (this=0x564335d04140, message=...) at /home/andrew/serenity/Userland/Libraries/LibIPC/Connection.cpp:52
#7  0x00005643348bf5ae in WebContentClientProxy<WebContentServerEndpoint, WebContentClientEndpoint>::async_did_request_cursor_change (this=<optimized out>, cursor_type=<optimized out>)
    at Userland/Services/WebContent/WebContentClientEndpoint.h:4802
#8  WebContent::PageClient::page_did_request_cursor_change (this=<optimized out>, cursor=<optimized out>) at /home/andrew/serenity/Userland/Services/WebContent/PageClient.cpp:218
#9  0x00007fa6f20100dc in Web::EventHandler::handle_mousemove (this=0x7fa6eea1e078, position=..., screen_position=..., buttons=<optimized out>, modifiers=<optimized out>)
    at /home/andrew/serenity/Userland/Libraries/LibWeb/Page/EventHandler.cpp:530
#10 0x000056433486776a in WebContent::ConnectionFromClient::process_next_input_event()::$_1::operator()(WebContent::ConnectionFromClient::QueuedMouseEvent const&) const (event=..., 
    this=<optimized out>) at /home/andrew/serenity/Userland/Services/WebContent/ConnectionFromClient.cpp:181
<snip....>
#13 WebContent::ConnectionFromClient::process_next_input_event (this=0x564335d04140) at /home/andrew/serenity/Userland/Services/WebContent/ConnectionFromClient.cpp:162

And neither is making any progress (GUI greyed out).