Integrazione 0.1.1: Febe per Windows si collega, VS Code, prove su Windows, storico e vista remota #4

Merged
Alby96 merged 49 commits from integrazione/0.1.1 into main 2026-10-20 19:05:36 +02:00
2 changed files with 21 additions and 6 deletions
Showing only changes of commit a6623e5736 - Show all commits

No files matched your search

+9 -4
View File
@@ -68,10 +68,6 @@ internal sealed class WebView2Browser : IFebeBrowser
try
{
await Host.StartAsync(_options, ct).ConfigureAwait(false);
_started = true;
_lastError = null;
_context.Log.Info("browser", $"Browser di Febe pronto: WebView2 {Host.Version}, pagina {WindowWidth.ToString(CultureInfo.InvariantCulture)}×{WindowHeight.ToString(CultureInfo.InvariantCulture)}, {BrowserHostingNames.Name(_settings.Hosting)}, fuori vista.");
return;
}
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
@@ -91,7 +87,16 @@ internal sealed class WebView2Browser : IFebeBrowser
{
return;
}
continue;
}
// Outside the retries: what follows a start that worked never undoes it. This runs on a thread of the
// composition, so it reads only plain values of the host (the version was read on the UI thread).
_started = true;
_lastError = null;
_context.Log.Info("browser", $"Browser di Febe pronto: WebView2 {Host.Version}, pagina {WindowWidth.ToString(CultureInfo.InvariantCulture)}×{WindowHeight.ToString(CultureInfo.InvariantCulture)}, {BrowserHostingNames.Name(_settings.Hosting)}, fuori vista.");
return;
}
}
+12 -2
View File
@@ -57,6 +57,9 @@ internal sealed class WebView2Host : IBrowserHost
private bool _closing;
private bool _restarting;
// Read on the UI thread during the start: a plain value that any thread may read.
private volatile string? _version;
public WebView2Host(Dispatcher ui, WebView2HostOptions settings, FebeLog log)
{
_ui = ui ?? throw new ArgumentNullException(nameof(ui));
@@ -79,8 +82,11 @@ internal sealed class WebView2Host : IBrowserHost
/// <summary>True while a WebView is attached (commands can be sent).</summary>
public bool IsAttached => _session.IsAttached;
/// <summary>The version of the WebView2 runtime in use (for the log).</summary>
public string? Version => _environment?.BrowserVersionString;
/// <summary>
/// The version of the WebView2 runtime of the browser in use (for the log), read on the UI thread when it started;
/// null before the first start. Any thread: it is a plain value, never a member of a WebView2 object.
/// </summary>
public string? Version => _version;
/// <summary>Raised on the UI thread when the browser process of WebView2 went away by itself (the owner restarts).</summary>
public event EventHandler? BrowserProcessFailed;
@@ -200,6 +206,10 @@ internal sealed class WebView2Host : IBrowserHost
_exited = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
_environment.BrowserProcessExited += OnBrowserProcessExited;
// Read here, on the UI thread, for the log line the composition writes from another thread: a member of the
// environment read there throws «CoreWebView2Environment members can only be accessed from the UI thread».
_version = _environment.BrowserVersionString;
var hwnd = _window.Handle;
if (_settings.Hosting == BrowserHosting.Composition)
{