CsWinRT
CsWinRT copied to clipboard
PdfDocument spawns zombie process
Describe the bug
When I use PdfDocument in WPF, the process remains even after closing the app.
To Reproduce
- Run PdfPage.RenderToStreamAsync() no longer terminates the app.
- GC.Collect() increases the recall of this phenomenon to 100%. Relevance to the phenomenon is unknown.
- There is no problem when debugging with VisualStudio2022. "Start without debugging" reproduces it.
Expected behavior
App should be terminated normally
Version Info
- Windows 10 Pro 64bit 21H2 19044.1889
- Radeon RX 560, AMD Software: Adrenalin Edition 22.5.1
- VisualStudio2022 Version 17.2.6
- WPF Application
- TargetFramework: net6.0-windows10.0.17763.0
Additional context
Below is the reproducible code.
public partial class App : Application
{
private async void Application_Startup(object sender, StartupEventArgs e)
{
await GetPdfPageStream(@"sample.pdf", 0);
GC.Collect();
this.Shutdown();
}
private static async Task<MemoryStream> GetPdfPageStream(string path, uint index)
{
using var pdfStream = File.OpenRead(path);
using var winrtStream = pdfStream.AsRandomAccessStream();
var pdfDocument = await PdfDocument.LoadFromStreamAsync(winrtStream);
using var pdfPage = pdfDocument.GetPage((uint)index);
var ms = new MemoryStream();
var outStream = ms.AsRandomAccessStream();
await pdfPage.RenderToStreamAsync(outStream);
ms.Seek(0, SeekOrigin.Begin);
return ms;
}
}
See also: https://stackoverflow.com/questions/50930684/wpf-app-not-exiting-because-of-uwp-pdfdocument
Added the graphics driver version to the post. AMD's latest version of the driver.
The debug run appeared to complete successfully, but actually ended with an error.
The program '[23248] PdfTest.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.