问题
We have a .NET program to run headless Chrome to snapshot web page to image, and here is the sample code:
class Program
{
static void Main(string[] args)
{
var p = Process.Start(
@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
$@"--headless --screenshot=E:\test{DateTime.Now:HHmmss}.png --disable-gpu --window-size=320,568 http://www.microsoft.com");
p.WaitForExit();
}
}
The console application is scheduled in Windows Task Scheduler with "Run whether user is logged on or not" option. The program works fine for months but failed yesterday, we noticed the Chrome version is 73 now. Luckily we found a computer in which Chrome is still 72, so we tested the background scheduled task once, upgraded Chrome to 73 and tested it again, finally got the conclusion - Headless Chrome 72 can run in background, but Chrome 73 can't.
Does anybody find the same issue on Chrome 73?
[updated on 2019/6/23]
It's a bug of Chromium (bug 942023) and has been fixed on Chrome 74.0.3729.108.
For Chrome 73, you can use --disable-features=VizDisplayCompositor
argument as a workaround.
回答1:
Yes, we have the same issue here. We're running Chrome through Selenium WebDriver and after the update to Chrome 73 our background tasks no longer function correctly. Downgrading to Chrome 72 fixes the problem.
Our diagnostics logs show that when running Chrome 73 in headless mode that certain calls to the Chrome process seem to hang. For instance, resizing the browser or trying to take a screenshot via the WebDriver API. We tried a number of things to fix this including updating Selenium, WebDriver and chromedriver to the latest versions but all had identical behaviours.
There certainly seems to be an issue with running Chrome 73 in headless mode after the update.
来源:https://stackoverflow.com/questions/55388995/chrome-73-stop-supporting-headless-mode-in-background-scheduled-task