Repository: elastic/kibana
Pull request #216688: [Reporting] Use google headless binary for reporting
Author: login: eokoneyo
Labels: name: release_note:skip
description: Skip the PR/issue when compiling release notes
name: Team:SharedUX
description: Platform AppEx-SharedUX (formerly Global Experience) t//
name: v9.1.0
name: v8.19.0
name: v8.18.1
name: v9.0.1
name: v8.17.6
Created: 2025-04-01T15:59:35Z | Merged: 2025-04-20T14:41:36Z

## Summary

This PR switches the chromium binary used for reporting to new headless-shell binary provided by google, we only use said binaries for Mac and Windows, and will keep the same our current approach for linux because there's no support for ARM linux. 

The current installed version of puppeteer is `24.4.0`, with an expectation for chromium of revision `1415337` and version `134.0.6998.35`, which has been selected.


## How to verify this change;

- Attempt generating exports of PDFs and PNG, with print option enabled and disabled
- Verify that we are able to generate a report, and the reports match previous ones. 

### Binary Verification

- Mac Arm
	<img width="864" alt="Screenshot 2025-04-04 at 12 15 31" src="https://github.com/user-attachments/assets/00b22c69-6839-4056-ac67-c6001e16413d" />

- Windows
	<img width="1395" alt="Screenshot 2025-04-19 at 14 51 09" src="https://github.com/user-attachments/assets/499b67ff-ab6a-41bb-ae4e-598c15e1bef4" />

P.S. This PR is a prerequisite for https://github.com/elastic/kibana/pull/212674

<!-- 
### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
- [ ] The PR  description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

-->



<!--ONMERGE {"backportTargets":["8.17","8.18","8.19","9.0"]} ONMERGE-->


Diff:
diff --git a/src/platform/packages/private/kbn-screenshotting-server/src/paths.ts b/src/platform/packages/private/kbn-screenshotting-server/src/paths.ts
index 820ab90633f3f..945cf8232542b 100644
--- a/src/platform/packages/private/kbn-screenshotting-server/src/paths.ts
+++ b/src/platform/packages/private/kbn-screenshotting-server/src/paths.ts
@@ -17,53 +17,55 @@ export interface PackageInfo {
   binaryChecksum: string;
   binaryRelativePath: string;
   isPreInstalled: boolean;
-  location: 'custom' | 'common';
-  revision: number;
+  location: 'custom' | 'chromeForTesting';
 }
 
 enum BaseUrl {
-  // see https://www.chromium.org/getting-involved/download-chromium
-  common = 'https://commondatastorage.googleapis.com/chromium-browser-snapshots',
   // A GCS bucket under the Kibana team
   custom = 'https://storage.googleapis.com/headless_shell',
+  // GCS bucket for headless chrome provided by the chrome team, see
+  // https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
+  chromeForTesting = 'https://storage.googleapis.com/chrome-for-testing-public',
 }
 
 interface CustomPackageInfo extends PackageInfo {
   location: 'custom';
 }
-interface CommonPackageInfo extends PackageInfo {
-  location: 'common';
+
+interface ChromeForTestingPackageInfo extends PackageInfo {
+  version: string;
+  location: 'chromeForTesting';
   archivePath: string;
 }
 
-function isCommonPackage(p: PackageInfo): p is CommonPackageInfo {
-  return p.location === 'common';
+function isChromeForTestingPackage(p: PackageInfo): p is ChromeForTestingPackageInfo {
+  return p.location === 'chromeForTesting';
 }
 
 export class ChromiumArchivePaths {
-  public readonly packages: Array<CustomPackageInfo | CommonPackageInfo> = [
+  public readonly packages: Array<CustomPackageInfo | ChromeForTestingPackageInfo> = [
     {
       platform: 'darwin',
       architecture: 'x64',
-      archiveFilename: 'chrome-mac.zip',
-      archiveChecksum: '481e48cbe90b1f904594a4658bcd5152e54cb11108cec8e2df08f959f75bdf5d',
-      binaryChecksum: 'a634013f8596f8a35e324acfc48ba7a986b328a5f58ee925d47fa9aee1195ce4',
-      binaryRelativePath: 'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
-      revision: 1415334,
-      location: 'common',
-      archivePath: 'Mac',
+      archiveFilename: 'chrome-headless-shell-mac-x64.zip',
+      archiveChecksum: 'e09bd8cc7b381a20d7738c3026a359e5ddd6a587ecb33f8326c0818f243f50e2',
+      binaryChecksum: '7bef5a84fe90d2a243e1e9c45e86f53525b1a3adec598c0b6ce009792abd5f34',
+      binaryRelativePath: 'chrome-headless-shell-mac-x64/chrome-headless-shell',
+      version: '134.0.6998.35',
+      location: 'chromeForTesting',
+      archivePath: 'mac-x64',
       isPreInstalled: false,
     },
     {
       platform: 'darwin',
       architecture: 'arm64',
-      archiveFilename: 'chrome-mac.zip',
-      archiveChecksum: '37d77b21dd0085c845d610d1a63c2bf0e7b07aa75c8cef5bd1a251a6d86411df',
-      binaryChecksum: '35a2b8a456e71f6d1df58a324d983b86944ce60443a1fe24d460a18f88c53216',
-      binaryRelativePath: 'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
-      revision: 1415336,
-      location: 'common',
-      archivePath: 'Mac_Arm',
+      archiveFilename: 'chrome-headless-shell-mac-arm64.zip',
+      archiveChecksum: 'ead60a22ae13e93a74b88fe43df3aa547ca599d9f9b7fd4b060e5c595fd890cb',
+      binaryChecksum: '8f60afb3cabee80b3e7efa6898d589997d5f6e3669b1bdc1bca4b8685e500e7f',
+      binaryRelativePath: 'chrome-headless-shell-mac-arm64/chrome-headless-shell',
+      version: '134.0.6998.35',
+      location: 'chromeForTesting',
+      archivePath: 'mac-arm64',
       isPreInstalled: false,
     },
     {
@@ -73,7 +75,6 @@ export class ChromiumArchivePaths {
       archiveChecksum: '98db5f4ae704a0cf4d1612721334b0466908bf642ac547798aa303d17105e782',
       binaryChecksum: '2ed0cbce8358e86b5c44719d1ccd50f711b879088946b6ffdeed22b4ce2e47ea',
       binaryRelativePath: 'headless_shell-linux_x64/headless_shell',
-      revision: 1415337,
       location: 'custom',
       isPreInstalled: true,
     },
@@ -84,20 +85,19 @@ export class ChromiumArchivePaths {
       archiveChecksum: '9b3bf295794f0d4fe5e52813aa31a5ed4ca4389384f7fff2a8465777709174ea',
       binaryChecksum: '382c7f30a57b1096c7567d3a2cba0353aae80ec11790cd271601fb1b2ebb85cd',
       binaryRelativePath: 'headless_shell-linux_arm64/headless_shell',
-      revision: 1415337,
       location: 'custom',
       isPreInstalled: true,
     },
     {
       platform: 'win32',
       architecture: 'x64',
-      archiveFilename: 'chrome-win.zip',
-      archiveChecksum: 'b76935f051c3f386372a0dbb79b657f5179430fea3e8014cc054cb44a5c138e0',
-      binaryChecksum: '78d4e3a27130a3589e8bd51f3dc6cce061ccd80ab5bcfc77430ac014f17a9be9',
-      binaryRelativePath: path.join('chrome-win', 'chrome.exe'),
-      revision: 1415337,
-      location: 'common',
-      archivePath: 'Win',
+      archiveFilename: 'chrome-headless-shell-win64.zip',
+      archiveChecksum: '3bda1b7b1dc59fe4d79d68c5ca2384f8e7a743253e041eb731664b05a1e73343',
+      binaryChecksum: 'fffdc5e77fae67391e154d92f2084f84fec410632a48211ae0ab652dc64aeacf',
+      binaryRelativePath: path.join('chrome-headless-shell-win64', 'chrome-headless-shell.exe'),
+      version: '134.0.6998.35',
+      location: 'chromeForTesting',
+      archivePath: 'win64',
       isPreInstalled: true,
     },
   ];
@@ -119,11 +119,14 @@ export class ChromiumArchivePaths {
   }
 
   public getDownloadUrl(p: PackageInfo) {
-    if (isCommonPackage(p)) {
-      const { common } = BaseUrl;
-      const { archivePath, revision, archiveFilename } = p;
-      return `${common}/${archivePath}/${revision}/${archiveFilename}`;
+    if (isChromeForTestingPackage(p)) {
+      const { chromeForTesting } = BaseUrl;
+      const { archivePath, version, archiveFilename } = p;
+      // returned string matches download value found at the following endpoint;
+      // https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
+      return `${chromeForTesting}/${version}/${archivePath}/${archiveFilename}`;
     }
+
     return BaseUrl.custom + '/' + p.archiveFilename; // revision is not used for URL if package is a custom build
   }
 
diff --git a/x-pack/platform/plugins/shared/screenshotting/server/browsers/download/index.test.ts b/x-pack/platform/plugins/shared/screenshotting/server/browsers/download/index.test.ts
index 24725c811f5d1..5233909105fdd 100644
--- a/x-pack/platform/plugins/shared/screenshotting/server/browsers/download/index.test.ts
+++ b/x-pack/platform/plugins/shared/screenshotting/server/browsers/download/index.test.ts
@@ -86,14 +86,14 @@ describe('ensureDownloaded', () => {
       expect(fetch).not.toHaveBeenCalled();
       await expect(readdir(path.resolve(`${paths.archivesPath}/x64`))).resolves.toEqual(
         expect.arrayContaining([
-          'chrome-mac.zip',
-          'chrome-win.zip',
+          'chrome-headless-shell-mac-x64.zip',
+          'chrome-headless-shell-win64.zip',
           expect.stringMatching(/^chromium-[0-9a-f]{7}-locales-linux_x64\.zip$/),
         ])
       );
       await expect(readdir(path.resolve(`${paths.archivesPath}/arm64`))).resolves.toEqual(
         expect.arrayContaining([
-          'chrome-mac.zip',
+          'chrome-headless-shell-mac-arm64.zip',
           expect.stringMatching(/^chromium-[0-9a-f]{7}-locales-linux_arm64\.zip$/),
         ])
       );


Reviews:
user: login: pmuellr
body: LGTM; running locally, I can see the version that got installed matches, and produces PDFs with "for print" true and false, and PNGs.
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T18:31:56Z
user: login: tsullivan
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-16T16:39:03Z
user: login: tsullivan
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-16T16:43:56Z
user: login: tsullivan
body: Left a nit comment and a question
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-16T16:44:34Z
user: login: eokoneyo
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-17T07:55:33Z
user: login: tsullivan
body: LGTM
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-18T15:57:41Z

Review comments:
diff_hunk: @@ -17,53 +17,58 @@ export interface PackageInfo {
   binaryChecksum: string;
   binaryRelativePath: string;
   isPreInstalled: boolean;
-  location: 'custom' | 'common';
+  location: 'custom' | 'CfT';
path: src/platform/packages/private/kbn-screenshotting-server/src/paths.ts
user: login: tsullivan
body: nit:
```suggestion
  location: 'custom' | 'chromeForTesting';
```
created_at: 2025-04-16T16:39:02Z
author_association: MEMBER
diff_hunk: @@ -17,53 +17,58 @@ export interface PackageInfo {
   binaryChecksum: string;
   binaryRelativePath: string;
   isPreInstalled: boolean;
-  location: 'custom' | 'common';
+  location: 'custom' | 'CfT';
   revision: number;
path: src/platform/packages/private/kbn-screenshotting-server/src/paths.ts
user: login: tsullivan
body: It seems we are not using revision anymore for anything. Can we remove it?
created_at: 2025-04-16T16:43:56Z
author_association: MEMBER
diff_hunk: @@ -17,53 +17,58 @@ export interface PackageInfo {
   binaryChecksum: string;
   binaryRelativePath: string;
   isPreInstalled: boolean;
-  location: 'custom' | 'common';
+  location: 'custom' | 'CfT';
   revision: number;
path: src/platform/packages/private/kbn-screenshotting-server/src/paths.ts
user: login: eokoneyo
body: You're right, I'd kept it around to somewhat denote the revision we are using, but I suppose that all information we can easily verify without having it specified.
created_at: 2025-04-17T07:55:32Z
author_association: CONTRIBUTOR

PR comments:
user: login: eokoneyo
created_at: 2025-04-04T11:20:12Z
body: /ci
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-04T11:29:24Z
body: /ci
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-04T13:59:46Z
body: /ci
author_association: CONTRIBUTOR
user: login: elasticmachine
created_at: 2025-04-14T09:25:43Z
body: Pinging @elastic/appex-sharedux (Team:SharedUX)
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-14T09:27:33Z
body: @elasticmachine merge upstream
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-16T12:48:40Z
body: @elasticmachine merge upstream
author_association: CONTRIBUTOR
user: login: elasticmachine
created_at: 2025-04-17T11:07:38Z
body: ## :green_heart: Build Succeeded
* [Buildkite Build](https://buildkite.com/elastic/kibana-pull-request/builds/294067)
* Commit: 46ee7c8970f55f269efea63a7db0c2bc726b2ca4

### Metrics [[docs](https://www.elastic.co/guide/en/kibana/master/ci-metrics.html)]
#### Public APIs missing comments
> Total count of every public API that lacks a comment. Target amount is 0. Run `node scripts/build_api_docs --plugin [yourplugin] --stats comments` for more detailed information.


| id | [before](https://github.com/elastic/kibana/commit/265b46f8ddb148a59e8a2619dcc6f4c355640258) | [after](https://github.com/elastic/kibana/commit/46ee7c8970f55f269efea63a7db0c2bc726b2ca4) | diff |
| --- | --- | --- | --- |
| `@kbn/screenshotting-server` | 34 | 33 | -1 |

<details><summary>Unknown metric groups</summary>

#### API count
| id | [before](https://github.com/elastic/kibana/commit/265b46f8ddb148a59e8a2619dcc6f4c355640258) | [after](https://github.com/elastic/kibana/commit/46ee7c8970f55f269efea63a7db0c2bc726b2ca4) | diff |
| --- | --- | --- | --- |
| `@kbn/screenshotting-server` | 35 | 34 | -1 |


</details>


### History
* :broken_heart: [Build #294023](https://buildkite.com/elastic/kibana-pull-request/builds/294023) failed 67efc4dce5613c42ccc35db043a480c14556363c
* :green_heart: [Build #290325](https://buildkite.com/elastic/kibana-pull-request/builds/290325) succeeded 9bd374617cfb6d7c48b0a4413f893cce561cfcd3
* :broken_heart: [Build #290241](https://buildkite.com/elastic/kibana-pull-request/builds/290241) failed 3b0007f68a8a48b8ba0dc3f8999e36390589d9e8
* :broken_heart: [Build #289688](https://buildkite.com/elastic/kibana-pull-request/builds/289688) failed 36fdc034957d137703c55b61c041f7dd8a9f352a
* :broken_heart: [Build #289633](https://buildkite.com/elastic/kibana-pull-request/builds/289633) failed 7e19197859c9477ce15096e60987203fd5b5cc8b

cc @eokoneyo

<!--buildkite-pr-comment-kibana-pull-request
{"builds":[{"buildStatus":{"state":"passed","success":true,"hasRetries":true,"hasNonPreemptionRetries":false},"url":"https://buildkite.com/elastic/kibana-pull-request/builds/294067","number":294067,"commit":"46ee7c8970f55f269efea63a7db0c2bc726b2ca4"},{"buildStatus":{"state":"failed","success":false,"hasRetries":false,"hasNonPreemptionRetries":false},"url":"https://buildkite.com/elastic/kibana-pull-request/builds/294023","number":294023,"commit":"67efc4dce5613c42ccc35db043a480c14556363c"},{"buildStatus":{"state":"passed","success":true,"hasRetries":true,"hasNonPreemptionRetries":false},"url":"https://buildkite.com/elastic/kibana-pull-request/builds/290325","number":290325,"commit":"9bd374617cfb6d7c48b0a4413f893cce561cfcd3"},{"buildStatus":{"state":"failed","success":false,"hasRetries":true,"hasNonPreemptionRetries":true},"url":"https://buildkite.com/elastic/kibana-pull-request/builds/290241","number":290241,"commit":"3b0007f68a8a48b8ba0dc3f8999e36390589d9e8"},{"buildStatus":{"state":"failing","success":false,"hasRetries":true,"hasNonPreemptionRetries":true},"url":"https://buildkite.com/elastic/kibana-pull-request/builds/289688","number":289688,"commit":"36fdc034957d137703c55b61c041f7dd8a9f352a"},{"buildStatus":{"state":"failed","success":false,"hasRetries":false,"hasNonPreemptionRetries":false},"url":"https://buildkite.com/elastic/kibana-pull-request/builds/289633","number":289633,"commit":"7e19197859c9477ce15096e60987203fd5b5cc8b"}],"number":294067}
buildkite-pr-comment-->
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-17T11:15:55Z
body: > Left a nit comment and a question

Thanks for the review @tsullivan, I addressed the nit comment and resolved the question.
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-20T09:09:08Z
body: @elasticmachine merge upstream
author_association: CONTRIBUTOR
user: login: kibanamachine
created_at: 2025-04-20T14:41:55Z
body: Starting backport for target branches: 8.17, 8.18, 8.19, 9.0

https://github.com/elastic/kibana/actions/runs/14560535852
author_association: CONTRIBUTOR
user: login: kibanamachine
created_at: 2025-04-20T14:49:13Z
body: ## 💔 Some backports could not be created

| Status | Branch | Result |
|:------:|:------:|:------|
|❌|8.17|Backport failed because of merge conflicts|
|❌|8.18|Backport failed because of merge conflicts|
|✅|8.19|[<img src="https://img.shields.io/github/pulls/detail/state/elastic/kibana/218699">](https://github.com/elastic/kibana/pull/218699)|
|✅|9.0|[<img src="https://img.shields.io/github/pulls/detail/state/elastic/kibana/218700">](https://github.com/elastic/kibana/pull/218700)|

Note: Successful backport PRs will be merged automatically after passing CI.

### Manual backport
To create the backport manually run:
```
node scripts/backport --pr 216688
```

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)

<!--- Backport version: 9.6.6 -->
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-29T20:21:35Z
body: ## 💔 Some backports could not be created

| Status | Branch | Result |
|:------:|:------:|:------|
|✅|8.18|[<img src="https://img.shields.io/github/pulls/detail/state/elastic/kibana/219631">](https://github.com/elastic/kibana/pull/219631)|
|❌|8.17|An unhandled error occurred. Please see the logs for details|

Note: Successful backport PRs will be merged automatically after passing CI.

### Manual backport
To create the backport manually run:
```
node scripts/backport --pr 216688
```

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)

<!--- Backport version: 9.6.6 -->
author_association: CONTRIBUTOR
user: login: eokoneyo
created_at: 2025-04-29T20:31:48Z
body: ## 💚 All backports created successfully

| Status | Branch | Result |
|:------:|:------:|:------|
|✅|8.17|[<img src="https://img.shields.io/github/pulls/detail/state/elastic/kibana/219632">](https://github.com/elastic/kibana/pull/219632)|

Note: Successful backport PRs will be merged automatically after passing CI.

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)

<!--- Backport version: 9.6.6 -->
author_association: CONTRIBUTOR