constellation: prevent panic when constellation receives message from closed pipeline#39745
Conversation
Signed-off-by: gterzian <[email protected]>
|
🔨 Triggering try run (#18387250089) for Linux (WPT) |
|
Test results for linux-wpt from try job (#18387250089): Flaky unexpected result (34)
Stable unexpected results that are known to be intermittent (29)
Stable unexpected results (1)
|
|
|
|
This is a bit odd. It should be impossible for a popup to be opened in same WebView as the opener. The popup code creates an entirely new top level browsing context which is assigned to a new WebView by the embedding layer. I think there must be something deeper going wrong. |
|
🔨 Triggering try run (#18400862229) for Linux (WPT) |
Defenitely, this PR only fixes the panic. The underlying problem is discussed at #39748 |
|
Test results for linux-wpt from try job (#18400862229): Flaky unexpected result (26)
Stable unexpected results that are known to be intermittent (28)
Stable unexpected results (1)
|
|
|
|
Looks like this one is now persistently not crashing: |
|
Ok I can comfirm that servo/components/constellation/constellation.rs Line 1644 in 12e5d1b which goes away with these changes. |
…e-iframe-contentwindow Signed-off-by: gterzian <[email protected]>
| let webview_id = match self | ||
| .pipelines | ||
| .get(&source_pipeline_id) | ||
| .map(|pipeline| pipeline.webview_id) | ||
| { | ||
| None => { | ||
| return warn!( | ||
| "{}: DiscardTopLevelBrowsingContext from closed pipeline", | ||
| source_pipeline_id | ||
| ); | ||
| }, | ||
| Some(ctx) => ctx, | ||
| }; |
There was a problem hiding this comment.
this looks like lot of code duplication, can we do something about it?
There was a problem hiding this comment.
I recommend a helper at the top of the loop like:
let get_webview_id = || {
let webview_id = self
.pipelines
.get(&source_pipeline_id)
.map(|pipeline| pipeline.webview_id);
if webview_id.is_none() {
warn!(ScriptToConstellationMessage on closed pipeline ({source_pipeline_id})");
}
webview_id
};Then in each match arm this could be:
let Some(webview_id) = get_webview_id() else {
return;
}Signed-off-by: gterzian <[email protected]>
90106ff to
e618012
Compare
|
@mrobinson @Taym95 Thanks for the review; comments have been addressed. Note the the new TIMEOUT is dealt with over at #39833 |
As part of #31973, I noticed that the intermittent crash of
/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.htmlappears due to the closing of the of the source webview of the message, which prior to these changes would result in an early return and drop the reply sender, resulting in a panic.This change makes the check for whether the webview is still open specific to certain messages that need the webview and
GetBrowsingContextInfois not one of them.As to exactly what allows a webview to be closed and still send a
GetBrowsingContextInfomessage, it appears that the iframe and the pop-up opened by the iframe share the same webview, and when the pop-up callsclose, that closes the webview but the iframe is still running and then receives a post message from a webview that was already closed(intermittently). See #39748Testing: WPT
Fixes: #22647