Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peek bug #35728

Open
ppyds opened this issue Nov 3, 2024 · 17 comments
Open

peek bug #35728

ppyds opened this issue Nov 3, 2024 · 17 comments
Labels
Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Product-Peek Refers to Peek Powertoys

Comments

@ppyds
Copy link

ppyds commented Nov 3, 2024

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.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x8007139F): 组或资源的状态不是执行请求操作的正确状态。 (0x8007139F)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateCoreWebView2ControllerAsync(IntPtr ParentWindow)
   at Microsoft.Web.WebView2.WinForms.WebView2.InitCoreWebView2Async(CoreWebView2Environment environment, CoreWebView2ControllerOptions controllerOptions)
   at Microsoft.PowerToys.PreviewHandler.Monaco.MonacoPreviewHandlerControl.<>c__DisplayClass13_0`1.<<DoPreview>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at InvokeStub_SendOrPostCallback.Invoke(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)


************** Loaded Assemblies **************
System.Private.CoreLib
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Private.CoreLib.dll
----------------------------------------
PowerToys.MonacoPreviewHandler
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.MonacoPreviewHandler.dll
----------------------------------------
System.Runtime
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.dll
----------------------------------------
WinRT.Runtime
    Assembly Version: 2.1.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\WinRT.Runtime.dll
----------------------------------------
System.Collections
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Collections.dll
----------------------------------------
System.Collections.Concurrent
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Collections.Concurrent.dll
----------------------------------------
System.Runtime.InteropServices
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.InteropServices.dll
----------------------------------------
System.Drawing.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Drawing.Primitives.dll
----------------------------------------
PowerToys.ManagedCommon
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.ManagedCommon.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Windows.Forms.dll
----------------------------------------
PowerToys.PreviewHandlerCommon
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.PreviewHandlerCommon.dll
----------------------------------------
System.ComponentModel.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.ComponentModel.Primitives.dll
----------------------------------------
System.Windows.Forms.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Windows.Forms.Primitives.dll
----------------------------------------
System.Collections.Specialized
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Collections.Specialized.dll
----------------------------------------
WindowsBase
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\WindowsBase.dll
----------------------------------------
PowerToys.Common.UI
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.Common.UI.dll
----------------------------------------
System.IO.Abstractions
    Assembly Version: 17.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.IO.Abstractions.dll
----------------------------------------
System.Security.AccessControl
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Security.AccessControl.dll
----------------------------------------
System.Diagnostics.TraceSource
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Diagnostics.TraceSource.dll
----------------------------------------
System.Diagnostics.TextWriterTraceListener
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Diagnostics.TextWriterTraceListener.dll
----------------------------------------
System.Diagnostics.FileVersionInfo
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Diagnostics.FileVersionInfo.dll
----------------------------------------
System.Threading
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Threading.dll
----------------------------------------
System.Drawing.Common
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Drawing.Common.dll
----------------------------------------
Microsoft.Win32.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\Microsoft.Win32.Primitives.dll
----------------------------------------
System.ComponentModel.EventBasedAsync
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.ComponentModel.EventBasedAsync.dll
----------------------------------------
System.Threading.Thread
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Threading.Thread.dll
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\Accessibility.dll
----------------------------------------
Microsoft.Win32.SystemEvents
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\Microsoft.Win32.SystemEvents.dll
----------------------------------------
System.Memory
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Memory.dll
----------------------------------------
System.Diagnostics.StackTrace
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Diagnostics.StackTrace.dll
----------------------------------------
System.Text.Encoding.Extensions
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Text.Encoding.Extensions.dll
----------------------------------------
ControlzEx
    Assembly Version: 6.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\ControlzEx.dll
----------------------------------------
PresentationCore
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PresentationCore.dll
----------------------------------------
PresentationFramework
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PresentationFramework.dll
----------------------------------------
DirectWriteForwarder
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\DirectWriteForwarder.dll
----------------------------------------
System.Runtime.Extensions
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.Extensions.dll
----------------------------------------
System.Diagnostics.Debug
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Diagnostics.Debug.dll
----------------------------------------
System.Runtime.CompilerServices.VisualC
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.CompilerServices.VisualC.dll
----------------------------------------
System.Collections.NonGeneric
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Collections.NonGeneric.dll
----------------------------------------
System.ObjectModel
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.ObjectModel.dll
----------------------------------------
Microsoft.Win32.Registry
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\Microsoft.Win32.Registry.dll
----------------------------------------
System.ComponentModel.TypeConverter
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.ComponentModel.TypeConverter.dll
----------------------------------------
System.ComponentModel
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.ComponentModel.dll
----------------------------------------
System.Xaml
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Xaml.dll
----------------------------------------
System.Private.Uri
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Private.Uri.dll
----------------------------------------
System.Configuration.ConfigurationManager
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Configuration.ConfigurationManager.dll
----------------------------------------
System.Xml.ReaderWriter
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Xml.ReaderWriter.dll
----------------------------------------
System.Private.Xml
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Private.Xml.dll
----------------------------------------
System.Net.WebClient
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Net.WebClient.dll
----------------------------------------
System.Linq
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Linq.dll
----------------------------------------
PresentationFramework-SystemXml
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PresentationFramework-SystemXml.dll
----------------------------------------
Microsoft.Web.WebView2.Core
    Assembly Version: 1.0.2739.15
    Location: C:\Users\11535\AppData\Local\PowerToys\Microsoft.Web.WebView2.Core.dll
----------------------------------------
mscorlib
    Assembly Version: 4.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\mscorlib.dll
----------------------------------------
Microsoft.Web.WebView2.WinForms
    Assembly Version: 1.0.2739.15
    Location: C:\Users\11535\AppData\Local\PowerToys\Microsoft.Web.WebView2.WinForms.dll
----------------------------------------
System.Runtime.CompilerServices.Unsafe
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.CompilerServices.Unsafe.dll
----------------------------------------
System.Numerics.Vectors
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Numerics.Vectors.dll
----------------------------------------
PowerToys.MonacoPreviewHandler.resources
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\zh-CN\PowerToys.MonacoPreviewHandler.resources.dll
----------------------------------------
System.Drawing
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Drawing.dll
----------------------------------------
PowerToys.Settings.UI.Lib
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.Settings.UI.Lib.dll
----------------------------------------
System.Security.Principal.Windows
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Security.Principal.Windows.dll
----------------------------------------
System.Security.Claims
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Security.Claims.dll
----------------------------------------
System.Text.Json
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Text.Json.dll
----------------------------------------
System.Text.Encodings.Web
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Text.Encodings.Web.dll
----------------------------------------
System.Runtime.Intrinsics
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.Intrinsics.dll
----------------------------------------
System.Reflection.Emit.Lightweight
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Reflection.Emit.Lightweight.dll
----------------------------------------
System.Reflection.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Reflection.Primitives.dll
----------------------------------------
System.Reflection.Emit.ILGeneration
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Reflection.Emit.ILGeneration.dll
----------------------------------------
PowerToys.ManagedTelemetry
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.ManagedTelemetry.dll
----------------------------------------
System.Diagnostics.Tracing
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Diagnostics.Tracing.dll
----------------------------------------
PowerToys.FilePreviewCommon
    Assembly Version: 0.85.1.0
    Location: C:\Users\11535\AppData\Local\PowerToys\PowerToys.FilePreviewCommon.dll
----------------------------------------
UtfUnknown
    Assembly Version: 2.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\UtfUnknown.dll
----------------------------------------
System.Text.Encoding.CodePages
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Text.Encoding.CodePages.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.dll
----------------------------------------
System.Threading.ThreadPool
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Threading.ThreadPool.dll
----------------------------------------
System.Threading.Tasks
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Threading.Tasks.dll
----------------------------------------
System.Runtime.Loader
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Runtime.Loader.dll
----------------------------------------
System.Reflection.Metadata
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Reflection.Metadata.dll
----------------------------------------
System.Collections.Immutable
    Assembly Version: 8.0.0.0
    Location: C:\Users\11535\AppData\Local\PowerToys\System.Collections.Immutable.dll
----------------------------------------

************** JIT Debugging **************

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

Other Software

No response

@ppyds ppyds added Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Nov 3, 2024
@daverayment
Copy link
Contributor

@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:

  • Which file type were you previewing?
  • Was this a one-off problem, or does it happen consistently with the same file?
  • Have you been able to preview other files of the same type with this version of Peek?
  • Has this just started happening with the current version of Peek, or has it always been a problem?

This will help us track down the issue more effectively. Thank you!

@ppyds
Copy link
Author

ppyds commented Nov 7, 2024

所有文本类型的文件(.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.

@ppyds
Copy link
Author

ppyds commented Nov 7, 2024

每次都会出现
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.

@ppyds
Copy link
Author

ppyds commented Nov 7, 2024

My OS is Windows 11, 24H2 Chinese version.

@daverayment
Copy link
Contributor

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:

  1. Access the System Tray area of the Windows Taskbar (you may need to click the ^ icon to show this):

Image

  1. Right-click on the PowerToys icon there and click Report Bug:

Image

  1. A file will be created on your desktop. (This may take several seconds.) Please attach this file to your next message.

Image

The file includes the logs for each of the PowerToys tools, and will help to investigate the bug.

Thanks again!

@ppyds
Copy link
Author

ppyds commented Nov 8, 2024

PowerToysReport_2024-11-09-00-22-26.zip
还是不行

@daverayment
Copy link
Contributor

@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!

@daverayment
Copy link
Contributor

@htcfreek Could you direct someone with knowledge of the installer here, please?

@htcfreek
Copy link
Collaborator

htcfreek commented Nov 8, 2024

@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?

@davidegiacometti davidegiacometti added the Product-Peek Refers to Peek Powertoys label Nov 9, 2024
@davidegiacometti
Copy link
Collaborator

davidegiacometti commented Nov 9, 2024

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.

public static string GetRuntimeMonacoDirectory()
{
string codeBase = Assembly.GetExecutingAssembly().Location;
string path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase) ?? string.Empty, "Assets", "Monaco"));
if (Path.Exists(path))
{
return path;
}
else
{
// We're likely in WinUI3Apps directory and need to go back to the base directory.
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase) ?? string.Empty, "..", "Assets", "Monaco"));
}
}

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 😃

@ppyds
Copy link
Author

ppyds commented Nov 10, 2024

@davidegiacometti

@ppyds deleting C:\Users\11535\AppData\Local\PowerToys\WinUI3Apps\Assets\Monaco should fix your issue 😃
删除应该可以解决你的问题。

按照这个步骤就好了,good Thanks you

@daverayment
Copy link
Contributor

@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 🤔

@ppyds
Copy link
Author

ppyds commented Nov 11, 2024

Image

@ppyds
Copy link
Author

ppyds commented Nov 11, 2024

Prompt in Chinese:

是的我的资源管理器也无法预览文本格式的文件

English translation:

"Yes, my File Explorer is also unable to preview text format files."

@davidegiacometti
Copy link
Collaborator

@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.

@daverayment
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Product-Peek Refers to Peek Powertoys
Projects
None yet
Development

No branches or pull requests

4 participants