WebView2 panels become permanently unavailable until restart (shared UDF + incompatible AdditionalBrowserArguments)
维护者通常 4 天内回复
评估
调研方向
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 内容生成。
描述
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 / 现象
-
WebView2 previews work normally at first.
-
After switching among certain file types (notably Font / CHM / PlantUML while other HTML-based viewers are also used), all WebView2 previews become blank/unusable.
-
Non-WebView2 viewers may still work.
-
Restarting QuickLook restores WebView2 previews.
-
起初 WebView2 预览正常。
-
在若干类型间切换后(尤其是字体 / CHM / PlantUML,同时也会用到其它 HTML 类预览),所有 WebView2 预览变为空白/不可用。
-
非 WebView2 查看器可能仍可用。
-
重启 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=WebContentsForceDarkHtmlViewer/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 / 参考:
- https://github.com/MicrosoftEdge/WebView2Feedback/issues/3389
- https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-related-events
3) No recovery path (amplifies a one-time failure into “restart required”)
Previously:
- No
CoreWebView2.ProcessFailedhandling CoreWebView2InitializationCompletedignored!e.IsSuccess- No cleanup of leftover
EBWebViewsingleton 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_Datafolder. -
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 / 修复方向
-
Centralize
CoreWebView2CreationProperties/ environment creation; never set per-viewerAdditionalBrowserArgumentson the shared UDF. -
Prefer
CoreWebView2Profile.PreferredColorSchemefor dark/light instead ofWebContentsForceDarkbrowser args. -
Handle
ProcessFailed(BrowserProcessExited/RenderProcessExited) and failed initialization with one retry after lock cleanup. -
On app startup (after single-instance check), delete stale
EBWebView\SingletonLock|SingletonCookie|SingletonSocketif present. -
集中创建环境;不要在共享 UDF 上按查看器设置不同的
AdditionalBrowserArguments。 -
深浅色改用
PreferredColorScheme,不要用WebContentsForceDark浏览器参数。 -
处理
ProcessFailed与初始化失败,清理锁后重试一次。 -
启动时(单实例检查之后)清理残留的 singleton 锁文件。
Related code / 相关代码
QuickLook.Plugin.HtmlViewer/WebpagePanel.csQuickLook.Plugin.HtmlViewer/Helper.csQuickLook.Plugin.FontViewer/WebfontPanel.csQuickLook.Plugin.ChmViewer/ChmWebpagePanel.csQuickLook.Plugin.ImageViewer/Webview/PlantUml/PuImagePanel.csQuickLook.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 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
QL-Win/QuickLook 的其他 Issue
-
[MarkdownViewer] Mermaid classDiagram with <<annotation>> fails with "Syntax error in text"可能已有人在做 @suhyun-nam 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 60/100
QL-Win/QuickLook#2028 · 3 条评论 ·
维护者通常 4 天内回复
-
[Bug] If the first character entered into the search box is a space, the preview window will close.可能已有人在做 @MORTEM3845 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 4 天内回复
-
[Crash] Fatal CLR error (80131506) previewing any SVG when WebView2 controller creation fails — initialization failure is silently ignored可能已有人在做 @Henglie 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 48/100
QL-Win/QuickLook#2056 · 1 条评论 ·
维护者通常 4 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
juandresrodca/AdminForge#54 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
要トリアージ 辞書
难度 1/5 1-3 小时 新手友好度 86/100
yksr-melt/Meltype#1625 · 1 个 reaction ·
维护者通常 1 天内回复
-
Docs typo未关闭
难度 1/5 1 小时以内 新手友好度 78/100
MonoGame/docs.monogame.github.io#328 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
space-wizards/RobustToolbox#7197 ·
维护者通常 1 天内回复