mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibWeb: Close WebSockets when document is unloaded
Previously, they would stay open for the entire WebContent lifetime, or until the server closed the connection. This was particularly noticeable on collaborative websites/games such as https://jigsawpuzzles.io/, where the user using Ladybird would stick around even after they had navigated away.
This commit is contained in:
parent
3224f8acb5
commit
12a07b4fad
Notes:
github-actions[bot]
2025-02-26 10:48:29 +00:00
Author: https://github.com/Lubrsi
Commit: 12a07b4fad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3694
5 changed files with 66 additions and 3 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/HTML/ImageBitmap.h>
|
||||
#include <LibWeb/PerformanceTimeline/PerformanceEntry.h>
|
||||
#include <LibWeb/PerformanceTimeline/PerformanceEntryTuple.h>
|
||||
#include <LibWeb/WebSockets/WebSocket.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -63,6 +64,15 @@ public:
|
|||
void unregister_event_source(Badge<EventSource>, GC::Ref<EventSource>);
|
||||
void forcibly_close_all_event_sources();
|
||||
|
||||
void register_web_socket(Badge<WebSockets::WebSocket>, GC::Ref<WebSockets::WebSocket>);
|
||||
void unregister_web_socket(Badge<WebSockets::WebSocket>, GC::Ref<WebSockets::WebSocket>);
|
||||
|
||||
enum class AffectedAnyWebSockets {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
AffectedAnyWebSockets make_disappear_all_web_sockets();
|
||||
|
||||
void run_steps_after_a_timeout(i32 timeout, Function<void()> completion_step);
|
||||
|
||||
[[nodiscard]] GC::Ref<HighResolutionTime::Performance> performance();
|
||||
|
@ -123,6 +133,8 @@ private:
|
|||
GC::Ptr<Crypto::Crypto> m_crypto;
|
||||
|
||||
bool m_error_reporting_mode { false };
|
||||
|
||||
WebSockets::WebSocket::List m_registered_web_sockets;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue