dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.99k stars 1.72k forks source link

In Blazor webview after viewing image I can't delete it #8776

Closed MG1376 closed 2 years ago

MG1376 commented 2 years ago

I use a radzen Blazor datagrid to show some image links, when user clicks the link and Image shows, then deleting the image or record fails and says 'The process cannot access the file because it is being used by another process.' I tested showing the image with a built in new window and also a radzen dialog service, with the same error. I also tested this with audio and video.

Only if I don't see the image or the audio/video preload='none' and I don't play the media, the file is deletable. I use .Net 6 with windows forms and Blazor and Microsoft.AspNetCore.Components.WebView.WindowsForms webview package. Is this a webview problem or there is a solution?

Eilon commented 2 years ago

Hi @MG1376 , how are the images being loaded, and how are they being deleted? We'll need to see what code you're using so that we can try to reproduce this and debug it.

MG1376 commented 2 years ago

Hi, The component that image resides is opened using 'Radzen Dialog' with an 'img' tag inside the component to load the image with a src that points to file on disk. I implement IDisposable in the component and dispose the reference (<img @ref="img" />) and then set it to null in the dispose method.

I had to change the code and rewrite it with an api action method, Now it works. But since using src that directly references a file on disk is easier, I wanted to know why using the original way interfere with deleting. For video/audio the same thing happens and I had to rewrite the code using api method.

Eilon commented 2 years ago

BTW I transfered the issue to the .NET MAUI repo, which is where we support the BlazorWebView that you appear to be using.

Eilon commented 2 years ago

with a src that points to file on disk

Can you show the exact code you're using? There are many possibilities here and we'll need to see exactly what code you have so that we can investigate the right thing.

ghost commented 2 years ago

Hi @MG1376. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

javiercn commented 2 years ago

@Eilon we have seen this in a different form (with CSS) I believe this is due to the way webview2 accesses the files that locks them in place.

Eilon commented 2 years ago

@javiercn oh that issue? Certainly could be. Do you have a link?

mkArtakMSFT commented 2 years ago

Thanks for contacting us. This is a dupe of https://github.com/dotnet/maui/issues/7479