Skip to content

Truly independent web browser

LibWebView: Skip initializing views during renderer navigation cleanup

Andreas Kling44021806a64d
diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h
index 85d09835eef..24e574ead96 100644
--- a/Libraries/LibWebView/ViewImplementation.h
+++ b/Libraries/LibWebView/ViewImplementation.h
@@ -115,6 +115,7 @@ public:
Optional<u64> owner_view_id() const { return m_owner_view_id; }
CanonicalTraversable& traversable() const;
+ bool has_traversable() const { return m_top_level_traversable != nullptr; }
// A page that comes to host any navigable of the tab gets the tab's settings: the spoofed User-Agent and
// navigator compatibility mode, the preferred languages and color scheme, the window geometry, and the rest of
// what the UI decides for the tab. A page that displays the tab gets its viewport and focus on top of that.
diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cpp
index 3d26afe4518..5964a9c1129 100644
--- a/Libraries/LibWebView/WebContentClient.cpp
+++ b/Libraries/LibWebView/WebContentClient.cpp
@@ -585,6 +585,9 @@ void WebContentClient::did_save_crash_report(ByteString const& report_name)
void WebContentClient::cancel_navigation_transactions()
{
ViewImplementation::for_each_view([this](ViewImplementation& view) {
+ // NB: A helper spawn can deliver an older child's exit before a new view has its traversable.
+ if (!view.has_traversable())
+ return IterationDecision::Continue;
view.traversable().for_each_in_inclusive_subtree([this](CanonicalNavigable& navigable) {
navigable.cancel_navigation_for_client(*this);
return IterationDecision::Continue;