WebView2 panels become permanently unavailable until restart (shared UDF + incompatible AdditionalBrowserArguments)

オープン
#2,055 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

@Henglie がすでに取り組んでいます。

2026年11月6日 から。

  • #2058 @Henglie による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp
領域
desktop

調査の方向性

Start with the listed WebView2 panel files and trace how each creates its environment and sets AdditionalBrowserArguments; compare the dark theme paths with HTML and Markdown viewers. Then inspect initialization and process failure handling, along with app startup cleanup after the single instance check. Done means shared panels use compatible environment settings and failures can recover without restarting QuickLook.

索引モデルが issue の本文から書いたものです。

説明

bug

Summary / 摘要

All WebView2-based previews (HTML, Markdown, SVG, Font, CHM, etc.) can enter a sticky broken state where every webview panel stays blank until QuickLook is restarted.

所有基于 WebView2 的预览(HTML、Markdown、SVG、字体、CHM 等)可能进入粘滞故障状态:全部 webview 面板空白,只有重启 QuickLook 才能恢复。

Environment / 环境

  • App: QuickLook (current main)
  • Component: Microsoft.Web.WebView2
  • Shared user data folder: local data path → WebView2_Data
  • Especially reproducible under dark theme

Symptoms / 现象

  1. WebView2 previews work normally at first.

  2. After switching among certain file types (notably Font / CHM / PlantUML while other HTML-based viewers are also used), all WebView2 previews become blank/unusable.

  3. Non-WebView2 viewers may still work.

  4. Restarting QuickLook restores WebView2 previews.

  5. 起初 WebView2 预览正常。

  6. 在若干类型间切换后(尤其是字体 / CHM / PlantUML,同时也会用到其它 HTML 类预览),所有 WebView2 预览变为空白/不可用。

  7. 非 WebView2 查看器可能仍可用。

  8. 重启 QuickLook 后 WebView2 恢复正常。

Root cause / 根因

1) One shared browser process for every WebView2 panel

Every panel uses the same UserDataFolder (WebView2_Data). WebView2 shares one browser process per user-data-folder within the host process. If that environment becomes invalid or the browser process dies, all webview panels fail together.

1) 所有 WebView2 面板共享同一个浏览器进程

所有面板共用同一 UserDataFolder(WebView2_Data)。同一宿主进程内,相同用户数据目录会共享一个浏览器进程。一旦该环境失效或浏览器进程退出,全部 webview 会一起挂掉。

2) Incompatible AdditionalBrowserArguments on the same UDF

Some viewers append browser arguments only in dark mode:

  • FontViewer / ChmViewer / PlantUml → --enable-features=WebContentsForceDark
  • HtmlViewer / MarkdownViewer / most image web panels → no such argument

WebView2 requires environment configuration (including AdditionalBrowserArguments) to stay compatible for a given user data folder. Creating a new WebView2 with incompatible args against an already-running browser process fails, commonly with:

  • ERROR_INVALID_STATE / 0x8007139F
2) 同一 UDF 上使用了不兼容的 AdditionalBrowserArguments

部分查看器仅在深色主题下追加浏览器参数(见上)。WebView2 要求同一用户数据目录的环境配置保持兼容;参数冲突时创建失败,常见 0x8007139F。

References / 参考:

3) No recovery path (amplifies a one-time failure into “restart required”)

Previously:

  • No CoreWebView2.ProcessFailed handling
  • CoreWebView2InitializationCompleted ignored !e.IsSuccess
  • No cleanup of leftover EBWebView singleton lock files after a crashed browser process

Therefore a single incompatible-create failure or browser-process crash left QuickLook unable to create any further WebView2 controls until process restart.

3) 没有恢复路径(把一次性失败放大成“必须重启”)

此前未处理 ProcessFailed、忽略初始化失败、也不清理崩溃后的 singleton 锁,因此一次失败就会粘滞到重启宿主进程为止。

Expected behavior / 期望行为

  • All WebView2 panels must use an identical environment configuration for the shared WebView2_Data folder.

  • Browser-process crashes / init failures should be logged and recovered (dispose + recreate, clear stale singleton locks) without requiring a full app restart.

  • 共用 WebView2_Data 的所有 WebView2 面板必须使用完全一致的环境配置。

  • 浏览器进程崩溃 / 初始化失败应记录日志并可自愈(销毁并重建、清理残留 singleton 锁),不应要求整应用重启。

Suggested fix direction / 修复方向

  1. Centralize CoreWebView2CreationProperties / environment creation; never set per-viewer AdditionalBrowserArguments on the shared UDF.

  2. Prefer CoreWebView2Profile.PreferredColorScheme for dark/light instead of WebContentsForceDark browser args.

  3. Handle ProcessFailed (BrowserProcessExited / RenderProcessExited) and failed initialization with one retry after lock cleanup.

  4. On app startup (after single-instance check), delete stale EBWebView\SingletonLock|SingletonCookie|SingletonSocket if present.

  5. 集中创建环境;不要在共享 UDF 上按查看器设置不同的 AdditionalBrowserArguments。

  6. 深浅色改用 PreferredColorScheme,不要用 WebContentsForceDark 浏览器参数。

  7. 处理 ProcessFailed 与初始化失败,清理锁后重试一次。

  8. 启动时(单实例检查之后)清理残留的 singleton 锁文件。

Related code / 相关代码

  • QuickLook.Plugin.HtmlViewer/WebpagePanel.cs
  • QuickLook.Plugin.HtmlViewer/Helper.cs
  • QuickLook.Plugin.FontViewer/WebfontPanel.cs
  • QuickLook.Plugin.ChmViewer/ChmWebpagePanel.cs
  • QuickLook.Plugin.ImageViewer/Webview/PlantUml/PuImagePanel.cs
  • QuickLook.Plugin.ImageViewer/Webview/Svg/SvgImagePanel.cs

Notes / 备注

This matches reports of blank Markdown/HTML previews that only recover after restart. The dark-theme ForceDark argument mismatch is a strong trigger; a browser-process crash without recovery produces the same sticky symptom.

这与“Markdown/HTML 预览空白、重启才恢复”的现象一致。深色主题下 ForceDark 参数不一致是强触发条件;浏览器进程崩溃且无恢复逻辑也会表现为同样的粘滞故障。

Possibly related: #2031

主要言語
C#
スター
25.7k
フォーク
1.4k
平均マージ
4日 8分
マージ済み PR(30日)
3

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

QL-Win/QuickLook のほかの issue

QL-Win/QuickLook の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。