Browser di Febe per Windows: all'uscita l'avvio non resta appeso a WebView2
Il limite di 30 s all'arresto copriva solo un «Scollega» in corso (rilievo R3 della revisione). FebeApp aspetta RunAsync prima di chiudere il browser, e RunAsync e il ciclo di ripartenza aspettavano WebView2 senza limite: con un WebView2 che non risponde, «Esci» restava fermo. Ora WebView2Host.StartAsync onora il suo token. Chi chiama smette subito di aspettare, un avvio non ancora cominciato non comincia più, uno in corso finisce da sé e chiude ciò che ha creato se l'arresto è già passato. Il ciclo di ripartenza usa lo stesso avvio, e WebView2Browser.DisposeAsync lo aspetta al più 30 s. «Scollega», una volta cominciato, va invece fino in fondo: il profilo con la sessione deve sparire e il motore deve ripartire. Nuova prova: con il thread dell'interfaccia occupato, RunAsync torna subito alla cancellazione e dopo l'uscita non si apre nessuna finestra. Rossa prima della correzione (ancora in attesa dopo 10 s), verde dopo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a144d611ac
commit
7aaa93fe3b
4 files changed
+106
-6
No files matched your search
@@ -25,6 +25,9 @@ internal sealed class WebView2Browser : IFebeBrowser
|
||||
{
|
||||
private static readonly TimeSpan[] Retry = [TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(30), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(5)];
|
||||
|
||||
/// <summary>How long stopping waits for the restart loop to end before closing WebView2 anyway.</summary>
|
||||
private static readonly TimeSpan StopWait = TimeSpan.FromSeconds(30);
|
||||
|
||||
private readonly WebView2BrowserSettings _settings;
|
||||
private readonly FebePlatformContext _context;
|
||||
private readonly IClock _wallClock;
|
||||
@@ -133,8 +136,9 @@ internal sealed class WebView2Browser : IFebeBrowser
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the retries, waits for a restart in progress, then closes WebView2 and its window. <c>_lifetime</c> stays
|
||||
/// undisposed on purpose: a late caller may still read its (cancelled) token.
|
||||
/// Stops the retries, waits for the restart loop to notice (it stops waiting for WebView2 as soon as
|
||||
/// <c>_lifetime</c> is cancelled; at most <see cref="StopWait"/> in any case), then closes WebView2 and its window.
|
||||
/// <c>_lifetime</c> stays undisposed on purpose: a late caller may still read its (cancelled) token.
|
||||
/// </summary>
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
@@ -147,7 +151,14 @@ internal sealed class WebView2Browser : IFebeBrowser
|
||||
|
||||
if (restarting is not null)
|
||||
{
|
||||
await restarting.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await restarting.WaitAsync(StopWait).ConfigureAwait(false);
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
_context.Log.Warn("browser", "WebView2: la ripartenza del browser non si è fermata in tempo; Febe si chiude lo stesso.");
|
||||
}
|
||||
}
|
||||
|
||||
await Host.DisposeAsync().ConfigureAwait(false);
|
||||
|
||||
Reference in new issue
Block a user