Repository navigation
[Bug] 「打开方式」列出所有已注册处理器,选中非适用程序后助手进程永久挂起(Windows) #10349
Replies: 4 comments 1 reply
|
列表里出现不相关的程序,是因为枚举时传的过滤器是
static void Visit(string path, Action<IHandler> visit) {
var extension = Path.GetExtension(path);
if (extension.Length == 0) return;
SHAssocEnumHandlers(extension, 0, out handlers);
这一条和旁边那条 500 是同一个函数的两个出口: 至于选完之后永久挂起、留下两个 如果只能提一条,我建议提"过滤器传了 0 + 遍历无逐项容错",因为它们在同一段代码里、一次就能改完;挂起那条单独提,附上进程树和选中的具体程序对。 |
|
谢谢,位置对得很准, 1)
2)filter=0 / filter=1 的实际数量(本机,Windows 10 22H2 19045.6466)
3)关于拆报告:同意,挂起确实是另一个问题,混在一起会稀释。我另开一条,会带上:
发出来我 @ 你。 |
|
挂起问题已按建议单独成条 → #10369 (含两个 helper 的完整命令行、 |
|
按你测的数据, fallback 的料这个文件里已经有了:
你那条" 逐项容错还是我上一条指的位置, |

Uh oh!
There was an error while loading. Please reload this page.
[Bug] 「打开方式」会列出所有已注册处理器,选中非适用程序后助手进程永久挂起(Windows)
环境
0.2.1-rc.2(@deepseek-ai/dsh-desktop,Electron)19045.6466(x64).cmd与一个.ps1复现步骤
.cmd(批处理)和一个.ps1文件,两者都会出现在文件卡片里。.cmd选择 Adobe Premiere Pro CC 2019(列表里确实会出现它),为.ps1选择 Sublime Text。实际结果
Window Dialog。两者父进程均为
DeepSeek Harness.exe,存活十余分钟不退出。期望结果
ASSOC_FILTER_RECOMMENDED的项排前面)。根因分析
1. 应用列表未做相关性过滤
助手脚本中通过
SHAssocEnumHandlers(extension, 0, out handlers)枚举处理器,第二个参数0表示不做推荐项过滤,因此凡是往系统注册过 shell 集成的程序(例如 Adobe 全家桶、编辑器、压缩软件)都会出现在任何扩展名的候选列表里。用户很容易误选。2. 用
IHandler::Invoke直接启动,且外层加了一个「等 Shell 引用计数归零」的排空循环脚本里的核心逻辑是:
action是OpenRegistered(path, application),内部调用handler.Invoke(data)。注释里写明了意图:「Shell handlers may return before their asynchronous launch work releases the host」,所以要用引用计数来等异步启动完成。但如果被选中的 handler 启动路径较慢、或者(更常见)它并不真正处理该扩展名,Shell 的线程引用计数就不会回落到基线,
while循环便永不退出——助手进程挂死,调用方(Electron 主进程)拿不到结果,UI 就停在「正在打开…」。对比测试:同一批文件选择 记事本 打开时,handler 立即返回,助手进程正常退出,无僵尸。
3. 僵尸窗口的来源
SetTimer(IntPtr.Zero, ...)+ 该进程-STA的消息循环,使这个挂起的 PowerShell 进程持有并显示了一个顶层窗口(窗口类Static,标题Window Dialog),在任务栏里表现为一个点不开的条目。建议修复
SHAssocEnumHandlers的ASSOC_FILTER_RECOMMENDED(值1)只展示推荐项,其余折叠到「选择其他应用…」里。ShellExecuteEx(SEE_MASK_NOASYNC)按 AUMID/ProgID 启动,避免走IHandler::Invoke后还要等待引用计数。dsh-native-command-*助手进程。-WindowStyle Hidden,避免再制造任务栏僵尸窗口。用户侧的临时绕过(供其他遇到者参考)
powershell.exe -File ...。English summary
On Windows, the file-card "Open" flow enumerates association handlers with
SHAssocEnumHandlers(ext, 0, ...)(noASSOC_FILTER_RECOMMENDEDfilter), so irrelevantapps such as Adobe Premiere Pro appear for
.cmd. After the user picks one, the helper(
associations.ps1) callsIHandler::Invokeinside aWithShellLifetimedrain loop thatspins until the shell thread-reference count returns to its baseline. When the chosen
handler does not release that reference, the loop never exits: the UI stays on
"Opening…" forever, a visible
Window Dialogwindow is left in the taskbar, and thepowershell.exehelper stays alive indefinitely. Choosing Notepad for the same filereturns normally and leaves no zombie.
Suggested: filter handlers to recommended ones, bound the drain loop with a timeout,
prefer
ShellExecuteExfor launching, and terminatedsh-native-command-*helpers whenthe app exits.
All reactions