[Problem/Bug]: Printing page to PDF bypasses download/saveAs event handlers, may cause browser crash #5039
Description
What happened?
Our application registers handlers for both the DownloadStarting and SaveAsUiShowing events. Both handlers should suppress the default UI since we implemented our own download UI. This is mostly working as expected, but there is one use case where neither of these handlers is called and the default SaveAs and Download UI is displayed instead:
- Open any arbitrary page.
- Use shortcut CTRL+P or context menu "Print" to open the print page UI.
- In the device selection combo, choose "Save as PDF file"
--> first the default "Save as" dialog is shown and then the default download popup in the top right corner of the canvas.
If the user tries to close the browser tab containing the download popup, the whole browser process crashes. See bug #5035. The crash can be mitigated by closing the download popup before attempting to close the tab. Luckily Webview2 has an API to programmatically check and close open default download UIs, so I could implement a workaround.
However, we expect that the described use case is also covered by the DownloadStarting and SaveAsUiShowing events so it blends with our custom UI.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
131.0.0.0
SDK Version
1.0.2903.40
Framework
Win32
Operating System
Windows 11
OS Version
No response
Repro steps
- Open any arbitrary page.
- Use shortcut CTRL+P or context menu "Print" to open the print page UI.
- In the device selection combo, choose "Save as PDF file"
--> first the default "Save as" dialog is shown and then the default download popup in the top right corner of the canvas.
Expected: Our application registers handlers for both the DownloadStarting and SaveAsUiShowing events. Both handlers should suppress the default UI since we implemented our own download UI.
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