maui icon indicating copy to clipboard operation
maui copied to clipboard

WPF & Winforms with Blazor app leak 2 file system handles every time app.css is saved

Open TanayParikh opened this issue 1 year ago • 8 comments

Steps to reproduce:

  1. Create a WPF or Winforms app and enable Blazor as described here Build a Windows Presentation Foundation (WPF) Blazor app | Microsoft Learn
  2. Run the application
  3. In VS, save wwwroot\css\app.css
  4. Run the sys internals tool handle.exe on that file path and you will see the number of open handles increase by 2.
  5. Save it again and run handle.exe and 2 more open handles are charged to the app.

These open handles seem to cause some issues with the way VS saves the file. It saves correctly but it seems to generate 2 save events, so we process the file change twice.

Here's a proc mon trace showing this. Note the 3 calls o CreateFile but only one CloseFile.

11:47:22.4461876 AM              WpfApp1.exe            23308       CreateFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened

11:47:22.4462182 AM              WpfApp1.exe            23308                  QueryNetworkOpenInformationFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  CreationTime: 5/9/2022 9:56:21 AM, LastAccessTime: 10/27/2022 11:47:22 AM, LastWriteTime: 10/27/2022 11:47:22 AM, ChangeTime: 10/27/2022 11:47:22 AM, AllocationSize: 4096, EndOfFile: 693, FileAttributes: A

11:47:22.4462266 AM              WpfApp1.exe            23308       CloseFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS 

11:47:22.4462380 AM              WpfApp1.exe            23308       FileSystemControl          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  Control: FSCTL_QUERY_FILE_REGIONS

11:47:22.4463240 AM              WpfApp1.exe            23308       CreateFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened

11:47:22.4463757 AM              WpfApp1.exe            23308       QueryEAFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS 

11:47:22.4520798 AM              WpfApp1.exe            23308       CreateFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened

11:47:22.4521047 AM              WpfApp1.exe            23308                  QueryNetworkOpenInformationFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  CreationTime: 5/9/2022 9:56:21 AM, LastAccessTime: 10/27/2022 11:47:22 AM, LastWriteTime: 10/27/2022 11:47:22 AM, ChangeTime: 10/27/2022 11:47:22 AM, AllocationSize: 4096, EndOfFile: 693, FileAttributes: A

11:47:22.4521134 AM              WpfApp1.exe            23308       CloseFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS 

11:47:22.4521969 AM              WpfApp1.exe            23308       CreateFile          C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css                  SUCCESS  Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1659321

TanayParikh avatar Nov 02 '22 16:11 TanayParikh

@Eilon any thoughts on who'd be handling the actual file saving?

TanayParikh avatar Nov 02 '22 16:11 TanayParikh

You mean who owns it in the VS world? Possibly someone on @vijayrkn 's team?

Eilon avatar Nov 02 '22 16:11 Eilon

Thanks. Moving back.

TanayParikh avatar Nov 02 '22 16:11 TanayParikh

Hi Tanay, Is this fixed in .NET 7?

akhanalcs avatar Nov 09 '22 20:11 akhanalcs

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

msftbot[bot] avatar Nov 09 '22 20:11 msftbot[bot]

No the internal issue was still open. I'm going to re-open this issue here on GitHub for tracking and investigation.

TanayParikh avatar Nov 09 '22 20:11 TanayParikh

@BillHiebert just tried this out and wasn't able to repro:

image

Version 17.5.0 Preview 2.0 [33109.374.main] Microsoft.AspNetCore.Components.WebView 6.0.10

Any other tips on repro'ing the issue?

TanayParikh avatar Nov 10 '22 23:11 TanayParikh

Hi @TanayParikh. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

msftbot[bot] avatar Nov 10 '22 23:11 msftbot[bot]