maui
maui copied to clipboard
WPF & Winforms with Blazor app leak 2 file system handles every time app.css is saved
Steps to reproduce:
- Create a WPF or Winforms app and enable Blazor as described here Build a Windows Presentation Foundation (WPF) Blazor app | Microsoft Learn
- Run the application
- In VS, save wwwroot\css\app.css
- Run the sys internals tool handle.exe on that file path and you will see the number of open handles increase by 2.
- 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
@Eilon any thoughts on who'd be handling the actual file saving?
You mean who owns it in the VS world? Possibly someone on @vijayrkn 's team?
Thanks. Moving back.
Hi Tanay, Is this fixed in .NET 7?
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!
No the internal issue was still open. I'm going to re-open this issue here on GitHub for tracking and investigation.
@BillHiebert just tried this out and wasn't able to repro:
![image](https://user-images.githubusercontent.com/14852843/201228508-93d1c56b-eb88-4e63-ae43-9145834b8908.png)
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?
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.