Web panel host fix round 1: non-fatal process kinds, late failures, thread restart, focus and permission guards
- ProcessFailed: only BrowserProcessExited (teardown) and RenderProcessExited (about:blank, recreate on the next Open) fail the panel, as WebView2's docs describe the kinds; GPU, utility, sandbox, PPAPI and frame-only renderer exits are logged only. RenderProcessUnresponsive fails it at 3 reports within 30 s. The handler acts on the panel being served now. - Fail decides "ignored" under the lock first and hides the panel only when the failure is live: a late failure for a superseded handle no longer hides the newer panel. - The panel thread's finally restarts the thread when an Open is still queued and the host is not shutting down; _threadDone goes false only after StartStaThread returns. - Show takes the foreground only when a window of this process (or of this panel's WebView2 browser process) holds it, never while the foreground is null. The visibility rule counts the browser process (CoreWebView2.BrowserProcessId) as ours, so the page's own dialogs do not hide the panel. - ClipboardRead is allowed only for an allowlisted origin. NavigationStarting and NewWindowRequested fail closed on an exception. - WebPanelApiRules: the ABI glue's pure parts (refusals, GetState Size check, state write), tested in WebPanelTests with WebPanelNativeArgs. WebPanelApi.LiveHandle and the browser pid in Describe for Task 4. - Harness: GpuProcessCrashKeepsPanel and LateFailureForSupersededHandle (both RED before the fix), UnloadWhileVisibleCollected reports UNVERIFIED when the window was not visible, the game-side key count is informational. EngineSettingsTests: WebPanel default-on round trip and setter case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f130be3d2b
commit
388f3fd908
9 changed files with 427 additions and 64 deletions
|
|
@ -21,8 +21,8 @@ internal static unsafe class WebPanelApi
|
|||
{
|
||||
try
|
||||
{
|
||||
if (s_shutdown || EngineLifecycle.IsShuttingDown) return (int)WebPanelCode.ShuttingDown;
|
||||
if (!EngineSettings.WebPanel) return (int)WebPanelCode.Unavailable;
|
||||
int refusal = WebPanelApiRules.OpenRefusal(s_shutdown || EngineLifecycle.IsShuttingDown, EngineSettings.WebPanel);
|
||||
if (refusal != 0) return refusal;
|
||||
EngineWebPanelEnvironment env;
|
||||
WebPanelHost host;
|
||||
lock (Sync)
|
||||
|
|
@ -46,7 +46,8 @@ internal static unsafe class WebPanelApi
|
|||
{
|
||||
try
|
||||
{
|
||||
if (s_shutdown) return (int)WebPanelCode.ShuttingDown;
|
||||
int refusal = WebPanelApiRules.CallRefusal(s_shutdown);
|
||||
if (refusal != 0) return refusal;
|
||||
if (!WebPanelNativeArgs.TryReadUtf8(urlUtf8, WebPanelUrlPolicy.MaxUrlBytes, true, out string url)) return (int)WebPanelCode.BadArgs;
|
||||
WebPanelHost? host = s_host;
|
||||
return host == null ? (int)WebPanelCode.StaleHandle : host.Navigate(handle, url);
|
||||
|
|
@ -62,7 +63,8 @@ internal static unsafe class WebPanelApi
|
|||
{
|
||||
try
|
||||
{
|
||||
if (s_shutdown) return (int)WebPanelCode.ShuttingDown;
|
||||
int refusal = WebPanelApiRules.CallRefusal(s_shutdown);
|
||||
if (refusal != 0) return refusal;
|
||||
WebPanelHost? host = s_host;
|
||||
return host == null ? (int)WebPanelCode.StaleHandle : host.Close(handle);
|
||||
}
|
||||
|
|
@ -77,26 +79,22 @@ internal static unsafe class WebPanelApi
|
|||
{
|
||||
try
|
||||
{
|
||||
if (state == null || state->Size < (uint)((byte*)state->Reserved - (byte*)state)) return (int)WebPanelCode.BadArgs;
|
||||
if (s_shutdown) return (int)WebPanelCode.ShuttingDown;
|
||||
if (!WebPanelApiRules.StateArgsOk(state)) return (int)WebPanelCode.BadArgs;
|
||||
int refusal = WebPanelApiRules.CallRefusal(s_shutdown);
|
||||
if (refusal != 0) return refusal;
|
||||
WebPanelHost? host = s_host;
|
||||
WebPanelSnapshot s;
|
||||
int r;
|
||||
if (host == null)
|
||||
{
|
||||
s = new WebPanelSnapshot(handle, (int)WebPanelStatusCode.Superseded, 0, 0, 0, 0);
|
||||
r = (int)WebPanelStatusCode.Superseded;
|
||||
s = WebPanelApiRules.NoPanel(handle);
|
||||
r = s.Status;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = host.GetState(handle, out s);
|
||||
}
|
||||
state->Handle = s.Handle;
|
||||
state->Status = s.Status;
|
||||
state->Flags = s.Flags;
|
||||
state->Error = s.Error;
|
||||
state->LastHttpStatus = s.LastHttpStatus;
|
||||
state->NavigationCount = s.NavigationCount;
|
||||
WebPanelApiRules.WriteState(state, s);
|
||||
return r;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
|
|
@ -118,7 +116,10 @@ internal static unsafe class WebPanelApi
|
|||
host?.Shutdown(ShutdownBudgetMs);
|
||||
}
|
||||
|
||||
/// <summary>Redacted one-liner (no query, fragment or userinfo).</summary>
|
||||
/// <summary>The live panel handle, 0 when none was opened: lets the engine close it (WebPanelApi.Close(LiveHandle)).</summary>
|
||||
internal static int LiveHandle => s_host?.LiveHandle ?? 0;
|
||||
|
||||
/// <summary>Redacted one-liner (no query, fragment or userinfo); includes the WebView2 browser pid.</summary>
|
||||
internal static string Describe()
|
||||
{
|
||||
WebPanelHost? host = s_host;
|
||||
|
|
@ -135,6 +136,7 @@ internal static unsafe class WebPanelApi
|
|||
internal static int Close(int handle) => (int)WebPanelCode.Unavailable;
|
||||
internal static int GetState(int handle, WebPanelStateNative* state) => (int)WebPanelCode.Unavailable;
|
||||
internal static void Shutdown() { }
|
||||
internal static int LiveHandle => 0;
|
||||
internal static string Describe() => "web panel: not available in this engine build";
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue