Vista remota: l'avvio dei fotogrammi si ritenta mentre la pagina cambia documento

Da ReadyToCommitNavigation al commit di una navigazione con un nuovo
RenderFrameHost (con RenderDocument: ogni navigazione, anche verso la
pagina di riposo) Chromium rifiuta Page.startScreencast con -32000
«Not attached to an active page». La vista aperta in quel momento
(insieme alla pagina di accesso, dopo un riposo del motore, durante una
sessione) finiva in «Il browser di Febe non risponde».

Ora ScreencastSession rimanda l'avvio solo su quella risposta, con pause
da 100 a 500 ms e per al più 5 s sull'orologio vero (IClock, iniettabile
nelle prove); ogni altro errore sale subito com'era. Nessun comando CDP
nuovo. Vale anche per il riavvio dei fotogrammi dopo un riavvio del browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-20 16:54:50 +02:00
1 parent edade61b72
commit 724c0752cf
3 files changed
+81 -14

No files matched your search

+20
View File
@@ -92,11 +92,31 @@ public sealed class CdpCommandNotAllowedException(string method, string message)
public sealed class CdpCommandException(string method, int code, string browserMessage)
: Exception($"Il comando CDP «{method}» è fallito: {browserMessage} (codice {code}).")
{
/// <summary>Chromium's generic «server error» code.</summary>
public const int ServerErrorCode = -32000;
/// <summary>
/// What Chromium answers to a browser-side page command (<c>Page.startScreencast</c>, <c>Page.captureScreenshot</c>)
/// while the page's current document is not «active»: from <c>ReadyToCommitNavigation</c> of a navigation that uses
/// a new RenderFrameHost until that navigation commits, DevTools already points at the new, still uncommitted frame
/// (content/browser/devtools/protocol/page_handler.cc, <c>AssureTopLevelActiveFrame</c>;
/// render_frame_devtools_agent_host.cc, <c>ReadyToCommitNavigation</c>). A new RenderFrameHost comes with a process
/// swap, a cross-site or back-forward-cache swap and, with RenderDocument (on by default in current Chromium), with
/// every navigation of the page to a new document — the rest page included.
/// </summary>
public const string InactivePageMessage = "Not attached to an active page";
public string Method { get; } = method;
public int Code { get; } = code;
public string BrowserMessage { get; } = browserMessage;
/// <summary>
/// The page is between two documents (see <see cref="InactivePageMessage"/>): the same command a moment later finds
/// the new document committed. A browser that is gone answers differently (closed connection, no answer).
/// </summary>
public bool IsInactivePage => Code == ServerErrorCode && string.Equals(BrowserMessage, InactivePageMessage, StringComparison.Ordinal);
}
/// <summary>The connection to the browser is closed (browser exited, crashed or is restarting).</summary>