From 43ada96f1d9b4ee88a928b424521b181ba78cc22 Mon Sep 17 00:00:00 2001 From: Sander De la Marche Date: Fri, 31 Mar 2023 15:05:04 +0200 Subject: [PATCH 1/3] Add support for the new Chrome headless mode without breaking BC --- src/Browser/BrowserProcess.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Browser/BrowserProcess.php b/src/Browser/BrowserProcess.php index 0390a0a..116351f 100644 --- a/src/Browser/BrowserProcess.php +++ b/src/Browser/BrowserProcess.php @@ -321,7 +321,13 @@ private function getArgsFromOptions($binary, array $options) // enable headless mode if (!\array_key_exists('headless', $options) || $options['headless']) { - $args[] = '--headless'; + // enable the new headless mode available from Chrome 112 and up + if ($options['headless'] === 'new') { + $args[] = '--headless=new'; + } else { + $args[] = '--headless'; + } + $args[] = '--disable-gpu'; $args[] = '--font-render-hinting=none'; $args[] = '--hide-scrollbars'; From f4f23227235509b757ee88ec96f23352ec757490 Mon Sep 17 00:00:00 2001 From: Sander De la Marche Date: Fri, 31 Mar 2023 15:12:01 +0200 Subject: [PATCH 2/3] Comply with style checks --- src/Browser/BrowserProcess.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Browser/BrowserProcess.php b/src/Browser/BrowserProcess.php index 116351f..28c3053 100644 --- a/src/Browser/BrowserProcess.php +++ b/src/Browser/BrowserProcess.php @@ -322,7 +322,7 @@ private function getArgsFromOptions($binary, array $options) // enable headless mode if (!\array_key_exists('headless', $options) || $options['headless']) { // enable the new headless mode available from Chrome 112 and up - if ($options['headless'] === 'new') { + if ('new' === $options['headless']) { $args[] = '--headless=new'; } else { $args[] = '--headless'; From 2e6c8998e6854b408d70889d5044623356176f2e Mon Sep 17 00:00:00 2001 From: Sander De la Marche Date: Fri, 31 Mar 2023 15:15:05 +0200 Subject: [PATCH 3/3] Add extra key check to make sure headless is actually set --- src/Browser/BrowserProcess.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Browser/BrowserProcess.php b/src/Browser/BrowserProcess.php index 28c3053..19361b9 100644 --- a/src/Browser/BrowserProcess.php +++ b/src/Browser/BrowserProcess.php @@ -322,7 +322,7 @@ private function getArgsFromOptions($binary, array $options) // enable headless mode if (!\array_key_exists('headless', $options) || $options['headless']) { // enable the new headless mode available from Chrome 112 and up - if ('new' === $options['headless']) { + if (\array_key_exists('headless', $options) && 'new' === $options['headless']) { $args[] = '--headless=new'; } else { $args[] = '--headless';