Compare commits

...

25 Commits

Author SHA1 Message Date
Sparticuz cd113882ea 130.0.0 2024-10-17 12:45:36 -04:00
Kyle McNally f664837067
Merge pull request #310 from Sparticuz/chromium/130 2024-10-17 12:40:34 -04:00
Kyle McNally 1dbbfc7ac4 Add chromium 130 2024-10-17 12:36:02 -04:00
Sparticuz dfd47f4102 129.0.0 2024-10-04 12:09:12 -04:00
Kyle McNally 540387d11a
Merge pull request #306 from Sparticuz/chromium/129 2024-10-04 12:04:40 -04:00
Kyle McNally a64b8612f6 Update chromium to 129 2024-10-04 11:53:55 -04:00
Kyle McNally c031905fbf Update package deps 2024-10-04 11:53:33 -04:00
Sparticuz 517b6c43a4 127.0.0 2024-08-19 16:11:13 -04:00
Kyle McNally f9f32ca64c
Merge pull request #290 from Sparticuz/chromium/127 2024-08-19 16:09:26 -04:00
Kyle McNally 2f7267da42 Update deps 2024-08-19 16:01:01 -04:00
Kyle McNally b580ec7aae Chromium 127 2024-08-19 16:00:50 -04:00
Kyle McNally 58613272ad Puppeteer updates for tests 2024-08-19 15:59:14 -04:00
Sparticuz 8028819dfe 126.0.0 2024-07-16 11:18:59 -04:00
Kyle McNally 995bc5a604
Merge pull request #284 from Sparticuz/chromium/126 2024-07-16 11:17:57 -04:00
Kyle McNally c51ae58407 don't disable the graphics stack https://github.com/Sparticuz/chromium/issues/247 2024-07-16 11:08:53 -04:00
Kyle McNally 2c715c4e97 update to chromium 126 2024-07-16 11:06:49 -04:00
Kyle McNally 2bcd54a6c8 ignore internal docker folder 2024-07-16 11:05:49 -04:00
Kyle McNally bd9c5e9014 update deps 2024-07-16 11:05:35 -04:00
Sparticuz 3e6aa79fb8 123.0.1 2024-04-04 09:41:54 -04:00
Kyle McNally d0543e6139
Merge pull request #252 from Sparticuz/fix/misc-fixes 2024-04-04 09:40:25 -04:00
Kyle McNally 41223a10e9 Disable turning off accelerated graphics
https://github.com/Sparticuz/chromium/issues/247
2024-04-03 14:42:23 -04:00
Kyle McNally e4de013045 update deps 2024-04-03 13:27:08 -04:00
Kyle McNally 4ce60bdd4d more info on closing chromium 2024-04-03 13:07:27 -04:00
Kyle McNally 0f12e5f2d7 closes #113 2024-04-03 11:33:02 -04:00
Kyle McNally 94b8687686 closes #148 2024-04-03 11:23:54 -04:00
15 changed files with 132 additions and 80 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ _/amazon/.aws-sam
*.tgz
examples/**/package-lock.json
examples/**/.serverless
docker

View File

@ -10,11 +10,17 @@ pretest:
test:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node20
test16:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node16
test18:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node18
%.zip:
npm install --fund=false --package-lock=false
npm run build
mkdir -p nodejs
npm install --prefix nodejs/ tar-fs@3.0.5 follow-redirects@1.15.6 --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
npm install --prefix nodejs/ tar-fs@3.0.6 follow-redirects@1.15.9 --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
npm pack
mkdir -p nodejs/node_modules/@sparticuz/chromium/
tar --directory nodejs/node_modules/@sparticuz/chromium/ --extract --file sparticuz-chromium-*.tgz --strip-components=1

View File

@ -204,6 +204,50 @@ From what I can tell, `headless_shell` does not seem to include support for the
Try marking this package as an external. Ref: https://webpack.js.org/configuration/externals/
### I'm experiencing timeouts or failures closing Chromium
This is a common issue. Chromium sometimes opens up more pages than you ask for. You can try the following
```typescript
for (const page of await browser.pages()) {
await page.close();
}
await browser.close();
```
You can also try the following if one of the calls is hanging for some reason.
```typescript
await Promise.race([browser.close(), browser.close(), browser.close()]);
```
Always `await browser.close()`, even if your script is returning an error.
### I need Accessible pdf files
This is due to the way @sparticuz/chromium is built. If you require accessible pdf's, you'll need to
recompile chromium yourself with the following patch. You can then use that binary with @sparticuz/chromium-min.
_Note_: This will increase the time required to generate a PDF.
```patch
diff --git a/_/ansible/plays/chromium.yml b/_/ansible/plays/chromium.yml
index b42c740..49111d7 100644
--- a/_/ansible/plays/chromium.yml
+++ b/_/ansible/plays/chromium.yml
@@ -249,8 +249,9 @@
blink_symbol_level = 0
dcheck_always_on = false
disable_histogram_support = false
- enable_basic_print_dialog = false
enable_basic_printing = true
+ enable_pdf = true
+ enable_tagged_pdf = true
enable_keystone_registration_framework = false
enable_linux_installer = false
enable_media_remoting = false
```
## Fonts
The Amazon Linux 2 AWS Lambda runtime is not provisioned with any font faces.

View File

@ -3,14 +3,14 @@
"url": "https://example.com",
"expected": {
"title": "Example Domain",
"screenshot": "835f3ccc8fdbcb3a4a067666f1e9648e9e513570"
"screenshot": "e610a8be5568f23c453b08928460aae3ae0b4b0a"
}
},
{
"url": "https://get.webgl.org",
"expected": {
"remove": "logo-container",
"screenshot": "7b4110af7294ae55452d636dd8e900574b21ea2d"
"screenshot": "ec6c79a571b4cb5727c6fc23f9da30de3868138c"
}
}
]

View File

@ -1,5 +1,5 @@
const { ok } = require("assert");
const { createHash } = require("crypto");
const { ok } = require("node:assert");
const { createHash } = require("node:crypto");
const puppeteer = require("puppeteer-core");
const chromium = require("@sparticuz/chromium");
@ -13,20 +13,13 @@ exports.handler = async (event, context) => {
dumpio: true,
executablePath: await chromium.executablePath(),
headless: chromium.headless,
ignoreHTTPSErrors: true,
acceptInsecureCerts: true,
});
console.log("Chromium version", await browser.version());
const contexts = [browser.defaultBrowserContext()];
while (contexts.length < event.length) {
contexts.push(await browser.createBrowserContext());
}
for (let context of contexts) {
const job = event.shift();
const page = await context.newPage();
for (let job of event) {
const page = await browser.newPage();
if (job.hasOwnProperty("url") === true) {
await page.goto(job.url, { waitUntil: ["domcontentloaded", "load"] });
@ -45,7 +38,7 @@ exports.handler = async (event, context) => {
document.getElementById(selector).remove();
}, job.expected.remove);
}
const screenshot = await page.screenshot();
const screenshot = Buffer.from(await page.screenshot());
/*
console.log(
`data:image/png;base64,${screenshot.toString("base64")}`,
@ -68,6 +61,9 @@ exports.handler = async (event, context) => {
throw error.message;
} finally {
if (browser !== null) {
for (const page of await browser.pages()) {
await page.close();
}
await browser.close();
}
}

0
_/ansible/ansible.cfg Executable file → Normal file
View File

View File

@ -4,9 +4,9 @@
[localhost:vars]
ansible_connection=local
ansible_python_interpreter=python
image=ami-08d090f841c8435e9
image=ami-06c68f701d8090592
region=us-east-1
instance_size=c6i.12xlarge
instance_size=c7i.12xlarge
[aws]
@ -14,4 +14,4 @@ instance_size=c6i.12xlarge
ansible_connection=ssh
ansible_python_interpreter=auto_silent
ansible_ssh_private_key_file=ansible.pem
chromium_revision=1262506
chromium_revision=1343869

View File

@ -236,12 +236,6 @@
path: /srv/source/chromium/src/out/Headless
state: directory
- name: Mounting Build Directory in Memory
become: true
become_user: root
shell: |
mount --types tmpfs --options size=24G,nr_inodes=128k,mode=1777 tmpfs /srv/source/chromium/src/out/Headless
- name: Creating Headless Chromium Configuration
copy:
content: |

Binary file not shown.

Binary file not shown.

77
package-lock.json generated
View File

@ -1,40 +1,40 @@
{
"name": "@sparticuz/chromium",
"version": "123.0.0",
"version": "130.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@sparticuz/chromium",
"version": "123.0.0",
"version": "130.0.0",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"tar-fs": "^3.0.5"
"follow-redirects": "^1.15.9",
"tar-fs": "^3.0.6"
},
"devDependencies": {
"@tsconfig/node16": "^16.1.1",
"@tsconfig/strictest": "^2.0.3",
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"@types/follow-redirects": "^1.14.4",
"@types/node": "^20.11.30",
"@types/node": "^20.16.10",
"@types/tar-fs": "^2.0.4",
"clean-modules": "^3.0.5",
"typescript": "^5.4.2"
"clean-modules": "^3.1.1",
"typescript": "^5.6.2"
},
"engines": {
"node": ">= 16"
}
},
"node_modules/@tsconfig/node16": {
"version": "16.1.1",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-16.1.1.tgz",
"integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==",
"node_modules/@tsconfig/node20": {
"version": "20.1.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.4.tgz",
"integrity": "sha512-sqgsT69YFeLWf5NtJ4Xq/xAF8p4ZQHlmGW74Nu2tD4+g5fAsposc4ZfaaPixVu4y01BEiDCWLRDCvDM5JOsRxg==",
"dev": true
},
"node_modules/@tsconfig/strictest": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.3.tgz",
"integrity": "sha512-MroLvRhMbqtXI5WBSwoomro6OQS4xnCoudUrMb20JO0vLKUs0bAaCEcvM/immEBSJjFAK1l6jW1oAO8q3Ancrg==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.5.tgz",
"integrity": "sha512-ec4tjL2Rr0pkZ5hww65c+EEPYwxOi4Ryv+0MtjeaSQRJyq322Q27eOQiFbuNgw2hpL4hB1/W/HBGk3VKS43osg==",
"dev": true
},
"node_modules/@types/follow-redirects": {
@ -47,12 +47,13 @@
}
},
"node_modules/@types/node": {
"version": "20.11.30",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz",
"integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==",
"version": "20.16.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz",
"integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~5.26.4"
"undici-types": "~6.19.2"
}
},
"node_modules/@types/tar-fs": {
@ -113,10 +114,11 @@
}
},
"node_modules/clean-modules": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.5.tgz",
"integrity": "sha512-gRW2hxNEE+xunuv/lkdPQ6UAqhs6CGoshLxOZ6eqy2ytkUAyzSoQ4fFj8/51jAfmJhrbuBGd/8hnvplIp8KRDg==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.1.1.tgz",
"integrity": "sha512-t/7dNtn6vQYxujYxdwZeLa0NsLE92KQ0XeV3CDJ2TXgLTvn3ijmjlQN0Dm9wjYQgC0miZiF66ClTQzgIeYw96A==",
"dev": true,
"license": "ISC",
"dependencies": {
"clipanion": "^3.2.1",
"picomatch": "^2.3.0",
@ -157,15 +159,16 @@
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
},
"node_modules/follow-redirects": {
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
@ -270,9 +273,9 @@
}
},
"node_modules/tar-fs": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.5.tgz",
"integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==",
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.6.tgz",
"integrity": "sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==",
"dependencies": {
"pump": "^3.0.0",
"tar-stream": "^3.1.5"
@ -299,10 +302,11 @@
"dev": true
},
"node_modules/typescript": {
"version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"version": "5.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@ -312,10 +316,11 @@
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
"version": "6.19.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz",
"integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==",
"dev": true,
"license": "MIT"
},
"node_modules/wrappy": {
"version": "1.0.2",

View File

@ -1,6 +1,6 @@
{
"name": "@sparticuz/chromium",
"version": "123.0.0",
"version": "130.0.0",
"description": "Chromium Binary for Serverless Platforms",
"keywords": [
"aws",
@ -36,17 +36,17 @@
"test": "make clean && make && make pretest && make test"
},
"dependencies": {
"follow-redirects": "^1.15.6",
"tar-fs": "^3.0.5"
"follow-redirects": "^1.15.9",
"tar-fs": "^3.0.6"
},
"devDependencies": {
"@tsconfig/node16": "^16.1.1",
"@tsconfig/strictest": "^2.0.3",
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"@types/follow-redirects": "^1.14.4",
"@types/node": "^20.11.30",
"@types/node": "^20.16.10",
"@types/tar-fs": "^2.0.4",
"clean-modules": "^3.0.5",
"typescript": "^5.4.2"
"clean-modules": "^3.1.1",
"typescript": "^5.6.2"
},
"engines": {
"node": ">= 16"

View File

@ -240,9 +240,11 @@ class Chromium {
];
// https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md
this.graphics
? graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader")
: graphicsFlags.push("--disable-webgl");
// Blocked by https://github.com/Sparticuz/chromium/issues/247
//this.graphics
// ? graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader")
// : graphicsFlags.push("--disable-webgl");
graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader");
const insecureFlags = [
"--allow-running-insecure-content", // https://source.chromium.org/search?q=lang:cpp+symbol:kAllowRunningInsecureContent&ss=chromium
@ -398,7 +400,11 @@ class Chromium {
`Graphics mode must be a boolean, you entered '${value}'`
);
}
this.graphicsMode = value;
// Disabling 'disabling the gpu'
// Blocked by https://github.com/Sparticuz/chromium/issues/247
// this.graphicsMode = value;
this.graphicsMode = true;
}
}

View File

@ -72,4 +72,4 @@ class LambdaFS {
}
}
export = LambdaFS;
export default LambdaFS;

View File

@ -1,10 +1,10 @@
{
"extends": ["@tsconfig/node16/tsconfig", "@tsconfig/strictest"],
"extends": ["@tsconfig/node20/tsconfig", "@tsconfig/strictest"],
"compilerOptions": {
"declaration": true,
"lib": ["dom", "ES2021"],
"module": "Node16",
"moduleResolution": "Node16",
"lib": ["dom", "ES2023"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "build"
},
"include": ["source"]