Open ppyds opened 3 weeks ago
We've found some similar issues:
If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.
Note: You can give me feedback by 👍 or 👎 this comment.
@ppyds
Thank you for the bug report. Could you please provide more information about what you were doing when you experienced the bug? For example:
This will help us track down the issue more effectively. Thank you!
所有文本类型的文件(.js | .text | .css)等每次都不能预览,图片可以。 我是当前版本出现的问题
I've recently encountered a problem where I cannot preview any text files (.js, .text, .css, etc.). This issue has started happening in the current version. Image previews are unaffected.
每次都会出现 Every time, I cannot preview any text-type files (.js, .text, .css, etc.), but images can be previewed. This is a problem that has occurred in the current version.
My OS is Windows 11, 24H2 Chinese version.
Thanks, @ppyds.
Could you first try updating PowerToys to version 0.86. I have tried previewing .txt, .js, .css and other filetypes in that version and there weren't any issues.
If that doesn't fix the bug on your machine, please could you:
The file includes the logs for each of the PowerToys tools, and will help to investigate the bug.
Thanks again!
@ppyds
The issue seems to be related to missing files in the following location:
C:\Users\<your-username>\AppData\Local\PowerToys\WinUI3Apps\Assets\Monaco\
Looking at the installer logs, the folder and files were created here instead:
C:\Users\<your-username>\AppData\Local\PowerToys\Assets\Monaco\
(Missing the WinUI3Apps
folder.)
As a quick fix for this version, you could try copying the Monaco
folder from C:\Users\<your-username>\AppData\Local\PowerToys\Assets\
to C:\Users\<your-username>\AppData\Local\PowerToys\WinUI3Apps\Assets\
. However, I don't think this is a permanent fix - I suspect that installing a new version could reintroduce the problem.
I will ask if anyone knows the root cause of the bug.
Finally: how did you install and upgrade PowerToys? Has it always been the same way?
Thanks!
@htcfreek Could you direct someone with knowledge of the installer here, please?
@Aaron-Junker , @stefansjfw , @jaimecbernardo Can you plz look at this. Is this an individual or general bug?
@davidegiacometti Is this related to the changes for Registry Preview?
Hi everyone!
I checked what the installer is doing and also inspected the 0.85.0 installer: I can confirm that we aren't shipping Monaco sources in INSTALLDIR\WinUI3Apps\Assets
but only in INSTALLDIR\Assets
.
This is weird that the user is mentioning Peek but the error is related to Monaco PreviewHandler. This seems to another case #35831
My suspect is that the Peek Monaco previewer fail to be initialized due to the "missing file" and then Peek fallbacks to the shell preview handler previewer.
This is how the directory is determined.
EDIT: based on installationFolderStructure.txt
inside the bug report the first folder exists for the user.
WinUI3Apps
...
Assets
...
Monaco
index.html None efb13e18ef19d5db95447392e4621dc4
@ppyds deleting C:\Users\11535\AppData\Local\PowerToys\WinUI3Apps\Assets\Monaco
should fix your issue 😃
@davidegiacometti
@ppyds deleting C:\Users\11535\AppData\Local\PowerToys\WinUI3Apps\Assets\Monaco should fix your issue 😃 删除应该可以解决你的问题。
按照这个步骤就好了,good Thanks you
@davidegiacometti Thanks very much for analysing this in depth!
Peek uses MonacoHelper
to render the same files that are supported by the Explorer shell preview handler via the WebBrowserPreviewer
(which is called before the ShellPreviewHandlerPreviewer
in PreviewerFactory.Create()
).
I assume the preview handler in Explorer was failing as well, but this isn't reported to the user. There are lots of errors in the user's file-explorer-log
which look like this:
[2024-11-07 19:18:44.596167] [p-53456] [t-69488] [info] isApplied of HKCU\Software\Classes\CLSID\{D8034CFA-F34B-41FE-AD45-62FCBB52A6DA}\DisplayName:Monaco Preview Handler: RegOpenKeyExW failed: unknown error
[2024-11-07 19:18:44.596288] [p-53456] [t-69488] [info] isApplied of HKCU\Software\Classes\CLSID\{A5A41CC7-02CB-41D4-8C9B-9087040D6098}\DisplayName:Pdf Preview Handler: RegOpenKeyExW failed: unknown error
[2024-11-07 19:18:44.596692] [p-53456] [t-69488] [info] isApplied of HKCU\Software\Classes\CLSID\{D8BB9942-93BD-412D-87E4-33FAB214DC1A}\DisplayName:Pdf Thumbnail Provider: RegOpenKeyExW failed: unknown error
[2024-11-07 19:18:44.621855] [p-53456] [t-69488] [info] isApplied of HKCU\Software\Classes\CLSID\{D8034CFA-F34B-41FE-AD45-62FCBB52A6DA}\DisplayName:Monaco Preview Handler: RegOpenKeyExW failed: unknown error
I wonder if this is related, or whether it's just a by-product of the Monaco language files being in the wrong place 🤔
Prompt in Chinese:
是的我的资源管理器也无法预览文本格式的文件
English translation:
"Yes, my File Explorer is also unable to preview text format files."
@daverayment Monaco preview pane is running out of process (even when hosted by Peek) under PowerToys.MonacoPreviewHandler.exe
process and doesn't have issue when that folder exists.
I can repro the issue for Peek after creating INSTALLDIR\WinUI3Apps\Assets\Monaco
folder but Explorer preview pane is working.
I guess the preview pane not working is a different problem.
@davidegiacometti This is interesting! When the WinUI3Apps\Assets\Monaco
folder exists, the Monaco Preview Handler and Peek will resolve different MonacoDirectory
paths because of the difference in where their executables are; Peek's executable is under WinUI3Apps
and PowerToys.MonacoPreviewHandler.exe
lives a level up. This is fine if the WinUI3Apps\Assets\Monaco
folder doesn't exist, but FilePreviewCommon's GetRuntimeMonacoDirectory()
only checks the existence of Assets\Monaco
relative to the executable's location, not whether the Monaco asset files are present inside (which is a perfectly understandable assumption!). If there are issues during installation or after which end up creating this folder under WinUI3Apps
then the issue will happen for Peek but it won't affect the Explorer preview pane, as you saw in your repro.
I think the solution would be to do an explicit check that the executing assembly's location is WinUI3Apps
in GetRuntimeMonacoDirectory()
. The issue can't be fixed from within Peek's code.
This would change the code in FilePreviewCommon.MonacoHelper.GetRuntimeMonacoDirectory
to something like:
private static string GetRuntimeMonacoDirectory()
{
string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
// If the executable is within "WinUI3Apps", correct the path first.
if (Path.GetFileName(exePath) == "WinUI3Apps")
{
exePath = Path.Combine(exePath, "..");
}
string monacoPath = Path.Combine(exePath, "Assets", "Monaco");
return Directory.Exists(monacoPath) ?
monacoPath :
throw new DirectoryNotFoundException($"Monaco assets directory not found at {monacoPath}");
}
Of course, we still don't know why the WinUI3Apps\Assets\Monaco
folder was created in the first place on the user's machine, but it's a start ☺️
I will put a PR in to handle this.
Microsoft PowerToys version
0.85.1
Installation method
Microsoft Store
Running as admin
Yes
Area(s) with issue?
Peek
Steps to reproduce
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
✔️ Expected Behavior
No response
❌ Actual Behavior
No response
Other Software
No response