mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibWeb: Defer the handling of WebContent process crashes
Handling crashes synchronously is finicky since we're modifying the m_client_state struct while in a callback lambda owned by it. Let's avoid all the footguns here by simply using deferred_invoke() and handling the crash on next event loop iteration instead.
This commit is contained in:
parent
38781cb131
commit
e405a8f730
2 changed files with 28 additions and 19 deletions
|
@ -52,12 +52,8 @@ OutOfProcessWebView::~OutOfProcessWebView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutOfProcessWebView::create_client()
|
void OutOfProcessWebView::handle_web_content_process_crash()
|
||||||
{
|
{
|
||||||
m_client_state = {};
|
|
||||||
|
|
||||||
m_client_state.client = WebContentClient::construct(*this);
|
|
||||||
m_client_state.client->on_web_content_process_crash = [this] {
|
|
||||||
create_client();
|
create_client();
|
||||||
ASSERT(m_client_state.client);
|
ASSERT(m_client_state.client);
|
||||||
|
|
||||||
|
@ -77,6 +73,17 @@ void OutOfProcessWebView::create_client()
|
||||||
builder.appendff("The web page <a href=\"{}\">{}</a> has crashed.<br><br>You can reload the page to try again.", escape_html_entities(m_url.to_string_encoded()), escape_html_entities(m_url.to_string()));
|
builder.appendff("The web page <a href=\"{}\">{}</a> has crashed.<br><br>You can reload the page to try again.", escape_html_entities(m_url.to_string_encoded()), escape_html_entities(m_url.to_string()));
|
||||||
builder.append("</body></html>");
|
builder.append("</body></html>");
|
||||||
load_html(builder.to_string(), m_url);
|
load_html(builder.to_string(), m_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutOfProcessWebView::create_client()
|
||||||
|
{
|
||||||
|
m_client_state = {};
|
||||||
|
|
||||||
|
m_client_state.client = WebContentClient::construct(*this);
|
||||||
|
m_client_state.client->on_web_content_process_crash = [this] {
|
||||||
|
deferred_invoke([this] {
|
||||||
|
handle_web_content_process_crash();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
|
client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
|
||||||
|
|
|
@ -90,6 +90,8 @@ private:
|
||||||
void create_client();
|
void create_client();
|
||||||
WebContentClient& client();
|
WebContentClient& client();
|
||||||
|
|
||||||
|
void handle_web_content_process_crash();
|
||||||
|
|
||||||
URL m_url;
|
URL m_url;
|
||||||
|
|
||||||
struct ClientState {
|
struct ClientState {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue