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

DownloadStarting event not firing when selecting "Save as" from context menu #4562

Open
mikkelmogensen opened this issue May 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@mikkelmogensen
Copy link

mikkelmogensen commented May 16, 2024

What happened?

Run the code and right click a white area. Afterwards select Save as from context menu

Expected behavior:
MessageBox shows

Actual behavior:
MessageBox does not show

However if the google logo is rightclicked the behavior is as expected

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

1.0.2526-prerelease

Framework

WPF

Operating System

Windows 11

OS Version

OS build 22621.3593

Repro steps

using System.Windows;
using Microsoft.Web.WebView2.Wpf;
using Microsoft.Web.WebView2.Core;
public partial class App: Window {
public App() {
var wv = new WebView2();
Dispatcher.Invoke(() => {
wv.EnsureCoreWebView2Async(null);
});
Content = wv;
wv.CoreWebView2InitializationCompleted += (o2, e2) => {
wv.Source = new Uri("https://google.com");
wv.CoreWebView2.DownloadStarting += (o, e) => {
MessageBox.Show("----");
};
};
}
[STAThread]
static void Main(string[] sa) {
new Application().Run(new App());
}
}

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

AB#51156725

@mikkelmogensen mikkelmogensen added the bug Something isn't working label May 16, 2024
@vickiez
Copy link
Contributor

vickiez commented May 20, 2024

Hi @mikkelmogensen, can you share what you would like to accomplish using the DownloadStarting API? We are adding a separate API for handling the Save As dialog. Will this meet your needs?

cc: @Master-Ukulele

@mikkelmogensen
Copy link
Author

@vickiez as I pointed out in issue #1090 there is no TotalBytesToReceive property available and @Master-Ukulele is correct in the fact that issue only pertains to the ui.

I would like to know how large the download is for my app, among other things to be able to warn the user if they don't have enough storage available

For completeness it seems like a fairly good idea to have SaveAs hand it off to DownloadStarting in all cases

@vickiez vickiez added the tracked We are tracking this work internally. label May 21, 2024
@vickiez
Copy link
Contributor

vickiez commented May 21, 2024

@mikkelmogensen we'll look into adding support for this scenario. Because Save As downloads are handled differently, certain properties on the DownloadStarting API like ResultFilePath might not be available. We'll share updates here

@vickiez vickiez added tracked We are tracking this work internally. and removed tracked We are tracking this work internally. labels May 21, 2024
@Master-Ukulele Master-Ukulele added tracked We are tracking this work internally. and removed tracked We are tracking this work internally. labels May 21, 2024
@Master-Ukulele
Copy link

After the investigation, unfortunately this scenario is not able to be supported currently. Right click a white area save as is a special case for save web page. It's handled differently because it needs to support 3 save page types. If we integrate it into the DownloadStarting as a regular download, it will lose all save page special features. This will be a breaking change, and impact many users, so, we can't support.

@mikkelmogensen - In your request, I see you want to know and control if the downloading file size is larger than the remain disk storge. Here's more details might help. The save web page special case doesn't know the real size (even if the original UI may show the size, it still depends on the real web page content). So, save page download is designed to save a temp file to a temp folder (e.g. C drive, it will assume the temp folder has enough space). After that, the process attempts to move it to user's assigned location. If this step fails because of no enough space, the process stops silently. Users won't know this happens.

In your App, is it possible to do an additional check if the file exists at the assigned location, after save page process completes? This might be a solution. Thanks for your patience.

@mikkelmogensen
Copy link
Author

thanks for replying
@Master-Ukulele: it might be a possible solution, but i would still need to know the final download size, perhaps by knowing the temp file/folder location somehow and then counting up all the file sizes. but like you wrote, the temp drive might not have enough storage, so knowing the size in advance would of course be preferable

this issue is somewhat similar to another issue i have raised #4609

in my app i have custom dialogs for downloadstarting, save as and preferably also screenshot that allow the user to choose drive, folder and filename. i would like to know the total download size to prevent starting a download onto a drive that does not have enough storage available and instead tell the user how much storage they need to free up before the download can be started

cc: @maurawinstanley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

3 participants