«Pagina iniziale» solo finché Alberto guida, e la vista che non si blocca (#52)
Una verifica indipendente di 654076d ha trovato tre punti deboli.
- «Pagina iniziale» guardava il permesso di guida una volta sola, prima di
aspettare fino a 15 s la fine della sessione e 15 s il turno della pagina
(che poi prendeva comunque). Se nel frattempo Alberto chiudeva la finestra,
Febe navigava senza permesso e fuori dal Governatore (regole 7 e 8). Ora la
pressione vale finché dura il permesso di chi l'ha premuta: la finestra di
Windows passa un gettone che si annulla con il suo permesso, la vista remota
quello della propria vita. Con il turno della pagina in mano la connessione
guarda di nuovo che Alberto guidi ancora; senza turno rinuncia invece di
prendere la pagina a un passo della ricerca. L'attesa del turno è
BrowserConnectionService.PageTurnWait (15 s, le prove la accorciano).
- Nella vista remota «Pagina iniziale» aspettava dentro il ciclo di ricezione:
la vista restava ferma fino a mezzo minuto e poi riversava clic e tasti sulla
pagina nuova. Ora la pressione corre a parte, una per volta, e intanto clic,
tasti, «Indietro» e «Ricarica» si scartano.
- Repaint chiedeva un ridisegno sincrono (RDW_UPDATENOW) a finestre figlie del
processo del browser di WebView2: uno bloccato avrebbe fermato il thread
dell'interfaccia. Ora si chiede solo di ridisegnare.
Prove nuove, che senza le correzioni non passano: la pressione dimenticata se
Alberto lascia il browser, quella che finisce con il permesso di chi l'ha
premuta, la pagina mai tolta a un passo della ricerca, la vista che non si
blocca e scarta l'input; su Windows con WebView2 vero, il gettone che si
annulla quando la finestra si chiude. PROTOCOLLO.md, la guida e decisioni.md
dicono il comportamento nuovo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
654076d280
commit
2bbad2e9b7
12 files changed
+340
-24
No files matched your search
@@ -128,6 +128,12 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
/// </summary>
|
||||
public TimeSpan DrivingGrace { get; set; } = TimeSpan.FromMinutes(2);
|
||||
|
||||
/// <summary>
|
||||
/// How long Alberto's page waits for its turn while a step of the profile search holds it (real time). Read at every
|
||||
/// wait; tests shorten it.
|
||||
/// </summary>
|
||||
public TimeSpan PageTurnWait { get; set; } = TimeSpan.FromSeconds(15);
|
||||
|
||||
/// <summary>The engine, once it exists (it is built after the browser).</summary>
|
||||
public void AttachEngine(EngineHost engine) => _engine = engine ?? throw new ArgumentNullException(nameof(engine));
|
||||
|
||||
@@ -212,6 +218,17 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
/// with the page's turn, so that no step of a session or of the profile search has its page swapped under it. Only
|
||||
/// while he is at the browser: otherwise the page is the engine's and nothing happens.
|
||||
/// </summary>
|
||||
/// <param name="ct">
|
||||
/// Cancelled when the lease of whoever pressed the button ends (the window closed, the remote view closed): the press
|
||||
/// is then forgotten, whatever it was waiting for.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// The waits can last up to <see cref="PageTurnWait"/> and more: Alberto may have let go of the browser meanwhile, and
|
||||
/// then the page is the engine's again (rules 7 and 8: no navigation without his lease, outside the Governor). So
|
||||
/// right before navigating, with the page's turn in hand, it looks again: he still drives and the caller's lease still
|
||||
/// holds. Without the page's turn (a step of the search kept it) nothing happens either: the page is not taken from
|
||||
/// under the step.
|
||||
/// </remarks>
|
||||
public async Task OpenStartPageAsync(CancellationToken ct)
|
||||
{
|
||||
if (!_browser.IsAvailable)
|
||||
@@ -219,7 +236,15 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
return;
|
||||
}
|
||||
|
||||
await _commands.WaitAsync(ct).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _commands.WaitAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!_browser.UserIsDriving)
|
||||
@@ -229,6 +254,20 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
|
||||
await WaitForSessionEndAsync(ct).ConfigureAwait(false);
|
||||
using var turn = await TakePageAsync(ct).ConfigureAwait(false);
|
||||
if (_engine is not null && turn is null)
|
||||
{
|
||||
_log.Info("collegamento", "«Pagina iniziale» non aperta: la pagina è ancora occupata dalla ricerca dei profili. Riprova fra poco.");
|
||||
return;
|
||||
}
|
||||
|
||||
// The last look, with the page's turn in hand (no recipe and no search step can open a page until it is given
|
||||
// back): Alberto still drives and the caller's lease still holds.
|
||||
if (ct.IsCancellationRequested || !_browser.UserIsDriving)
|
||||
{
|
||||
_log.Info("collegamento", "«Pagina iniziale» non aperta: nel frattempo hai lasciato il browser.");
|
||||
return;
|
||||
}
|
||||
|
||||
var target = StartPageUrl;
|
||||
var what = target == _loginUrl ? "pagina di accesso" : "pagina iniziale del sito";
|
||||
var result = await _browser.Cdp.NavigateAsync(target, ct).ConfigureAwait(false);
|
||||
@@ -236,6 +275,10 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
? $"«Pagina iniziale»: {what} aperta."
|
||||
: $"«Pagina iniziale»: {what} non aperta (errore di rete del browser).");
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
_log.Info("collegamento", "«Pagina iniziale» non aperta: nel frattempo hai lasciato il browser.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_commands.Release();
|
||||
@@ -686,8 +729,9 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The page turn for Alberto's login page, so that no step of the profile search runs under it; after 15 seconds
|
||||
/// the page is taken anyway (Alberto asked for it), and null comes back.
|
||||
/// The page turn for Alberto's own navigation, so that no step of the profile search runs under it; null after
|
||||
/// <see cref="PageTurnWait"/> (and always without an engine). The login and the start page from the rest page then
|
||||
/// take the page anyway (Alberto asked for it, under his lease); «Pagina iniziale» gives up.
|
||||
/// </summary>
|
||||
private async Task<PageTurn?> TakePageAsync(CancellationToken ct)
|
||||
{
|
||||
@@ -697,7 +741,7 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
|
||||
}
|
||||
|
||||
using var limit = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
limit.CancelAfter(TimeSpan.FromSeconds(15));
|
||||
limit.CancelAfter(PageTurnWait);
|
||||
try
|
||||
{
|
||||
return await engine.Services.PageTurns.TakeAsync(PageUser.Engine, limit.Token).ConfigureAwait(false);
|
||||
|
||||
Reference in new issue
Block a user