[Problem/Bug]: When --single-process is on, print with ShowPrintUI crash
What happened?
We recently added the ability to launch the embedded WebView2 browser with the "--single-process" parameter to optimize system resource usage for viewing static HTML files. We also made it possible to print the HTML file by calling the ShowPrintUI method. The print parameters screen displays correctly, but the WebView2 instance crashes without generating a dump file when printing is initiated. This results in a completely black screen being displayed instead of the embedded browser.
After invoking printing from ShowPrintUI, the ProcessFailed event is called.
We understood that the problem is the fact that the ShowPrintUI method is an asynchronous method and, with the --single-process parameter, it isn't possible to call it. For this reason, we have temporarily removed the --single-process parameter.
We expected asynchronous methods to work regardless of the presence of the --single-process parameter, as we were convinced that they were called with a multi-threaded structure. Is this behavior intended?
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
131.0.2903.99
SDK Version
1.0.2792.45
Framework
Win32
Operating System
Windows 10, Windows 11, Windows Server
OS Version
No response
Repro steps
- Call the creation of the WebView2's istance with the --single-process in the Additional Arguments.
- Call the ShowPrintUI (COREWEBVIEW2_PRINT_DIALOG_KIND_SYSTEM or COREWEBVIEW2_PRINT_DIALOG_KIND_BROWSER).
- Print the page.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
Hi, @MLAEO02!
It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?
WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.
Thank you for your cooperation!
Hi, @MLAEO02!
It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?
WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.
Thank you for your cooperation!
Hi, @sivMSFT Unfortunately, no dump file is generated. I checked the folder returned by the get_FailureReportFolderPath method but it is empty.
@MLAEO02, Please note --single-process flag isn't supported by webview2. Anything that works with the flag enabled is a coincidence and cannot be relied upon to always function. As such, fixes related to getting things working for --single-process will not be taken up.
I am curious to know how much difference the flag is making in resource utilization. Was this optimization required due to any specific constrains is usage of the app?
@ParadoxZero I didn't know that the --single-process parameter was not supported, especially since we verified that, by using it, the WebView2 component consumed fewer resources on the machine where it was executed. With the other parameters being equal, we saw that resource usage was halved when we set the --single-process parameter.
If it is not supported, what does this parameter affect to make it consume less resources?
@MLAEO02 the flag exists mostly debugging and or dev purposes.
This is actively unsupported and using it will result in stability and security risk. This is true not just for webview2 but for chromium-based browsers as well.
Regarding the reduced resource usage - that due to not leveraging the multi process model and the overhead associated with it.
Okay, I understand that the --single-process is not supported. We had already removed it from our application due to all the problems it caused. Are there any other parameters we can enable to reduce the resource consumption?
@MLAEO02 WV2 does have a base memory cost when used. Anything over it can be profiled using devtools to determine why some webapps take more resources. Overall, without a goal or specifics there isn't a flag that you can turn on/off to optimize things.
As if such a flag exists and is supported - it will be used by default for all instances.
My recommendation will be to take a look at the APIs available in ICoreWebView2Settings and see if disabling any of the options you don't want to use helps. Those are all supported.
Since there isn't a specific action item out of this issue. Closing this. Please feel free to open a new one, if you encounter issues.