Repository navigation
feat(aws-lambda): arm64 video function image from the handler ZIP - #6064
Conversation
vanceingalls
left a comment
There was a problem hiding this comment.
Reviewed at dcdeefc2, only the one-commit delta on #6062's head f43fc696. The staging design is sound. The blocker is that the PR's own image smoke fails, and the reason is in the smoke setup, not the image.
What holds
- The Chrome pin is right. I downloaded
chromium-v148.0.0-pack.arm64.tarfrom the Sparticuz release. Its sha256 isc18a5241…5f0e, the value pinned inCHROMIUM_ARM64_PACK_SHA256. It holds the same four files the npm package ships inbin/(chromium.br,al2023.tar.br,fonts.tar.br,swiftshader.tar.br), so untarring overbin/replaces every x64 file and leaves none behind. - The ffmpeg swap lands where the rpath expects. #6062's tarball is
hf-media/{bin,lib,share}.--strip-components=1gives/var/task/bin+/var/task/lib, and$ORIGIN/../libresolves. The ZIP stages bothbin/ffmpegandbin/ffprobe(build-zip.ts:434), so the non-forcingrmSyncs can't hit a missing file. - Locally:
bun test scripts/stage-arm64-image.test.tspasses 5/5 on Bun 1.4.4, run twice. My box has nozip, so I used a shim; the ubuntu runners have it, and the Windows suite skips aws-lambda (windows-render.yml:420). - In CI,
Handler ZIP, bothffmpegbuilds andffmpeg builds matchare green, and the bundled ffmpeg printsffmpeg version 7.0.2inside the image.
Blocker: Chrome can't launch in the image smoke, because the smoke never inflates the AL2023 libraries
Image smoke fails at "ffmpeg and Chrome run in the image" (job 119910604065):
/tmp/chromium: error while loading shared libraries: libnspr4.so: cannot open shared object file
- Why:
@sparticuz/chromium148 inflatesal2023.tar.brand puts/tmp/al2023/libonLD_LIBRARY_PATHonly whenisRunningInAmazonLinux2023()seesAWS_EXECUTION_ENV(orAWS_LAMBDA_JS_RUNTIME/CODEBUILD_BUILD_IMAGE) naming node 20/22/24. Real Lambda sets that variable. - The gap: the pinned base image's config doesn't set it. Its
Envis onlyLANG,TZ,PATH,LD_LIBRARY_PATH,LAMBDA_TASK_ROOTandLAMBDA_RUNTIME_DIR. Anddocker run --entrypoint /var/lang/bin/node(lambda-arm64-image.yml:88) skips the runtime, so the smoke never inflates the libraries. - What's missing: that pack holds
libnspr4,libnss3,libexpatand the rest. None of them are in the base layers; I listed all six arm64 layers. - Effect: the step doesn't yet prove "Chrome renders, launched the way
src/chromium.tslaunches it". Theal2023half of the arm64 pack is never exercised. - Fix: add
-e AWS_EXECUTION_ENV=AWS_Lambda_nodejs22.xto thatdocker run, so the smoke takes the same branch as Lambda.
Important (non-blocking)
- No workflow runs on a
@sparticuz/chromiumbump. The workflow'spaths(:10-13) coverimage/**, the stage script and the workflow. A version bump only touchespackages/aws-lambda/package.json+bun.lock, so the "fails the staging until its arm64 pack is pinned" guard doesn't run on that PR. It first fails at the next image build, after the bump has merged. - Same gap for ZIP layout changes. A
build-zip.tschange to whereffmpeg,ffprobeor Chrome land isn't covered either. - Fix: add
packages/aws-lambda/package.jsonandpackages/aws-lambda/scripts/build-zip.tstopaths. This matters once the deploy PR ships the image.
Nit
/var/task/libis on the baseLD_LIBRARY_PATH, so the bundled gnutls/nettle libraries are visible to every process in the function, not just ffmpeg. They come from the same AL2023 release as the base, and/lib64resolves first, so I see no conflict today. The$ORIGINrpath means they could live underbin/../libanywhere, if you'd rather keep them off the shared path.
CI: Lambda arm64 image is red at dcdeefc2 (Image smoke, above). As a stacked PR (base build/lambda-arm64-ffmpeg), ci.yml's required checks don't run here. Comments and regression are green.
Verdict: REQUEST CHANGES
Reasoning: The image smoke is this PR's main evidence, and it fails. The cause is a missing AWS_EXECUTION_ENV, so Chrome's AL2023 libraries never load. It's a one-line fix. The staging script, the pins and the ffmpeg swap all check out.
— Via
dcdeefc to
04eef55
Compare
|
Thanks, both fixed at 04eef55 (rebased onto #6062's a51fd1d).
|
|
Follow-up at 003729a: the image is no longer smoked with an env the image doesn't carry.
The live render on the dev account is the final proof that Chrome launches in a real Lambda invoke. |
vanceingalls
left a comment
There was a problem hiding this comment.
Re-reviewed at 003729ae. It sits on #6062's new head a51fd1db, and #6064's own first commit is unchanged by the restack (git range-diff: dcdeefc2 = 661c98b8). Two commits are new. This resolves my change request (5616554077).
What's fixed
- The Chrome smoke now goes through the image's own Lambda bootstrap.
smoke-video.mjsis now a handler, and the workflow invokes it assmoke-video.handlervia the runtime interface emulator. No env vars are set by hand. - The smoke passes in CI (Image smoke). The handler reports
"executionEnv":"AWS_Lambda_nodejs22.x","arch":"arm64","ffmpeg":"ffmpeg version 7.0.2 …","chrome":"HeadlessChrome/148.0.7778.0","screenshotBytes":182. So the bootstrap setsAWS_EXECUTION_ENVas Lambda does,@sparticuz/chromiuminflates the arm64al2023libraries, and Chrome renders. - The
jq -egate checks arch, a non-empty screenshot and the ffmpeg version, so a smoke that silently falls back can't pass. The handler-load step still answersno recognised Action. - The workflow
pathsnow includepackages/aws-lambda/package.jsonandscripts/build-zip.ts. That closes the important note from my last review: a@sparticuz/chromiumbump now re-stages the image on its own PR.
CI: Lambda arm64 image is green at 003729ae: both ffmpeg builds, ffmpeg builds match, Handler ZIP and Image smoke. Comments and regression are green too. As a stacked PR (base build/lambda-arm64-ffmpeg), ci.yml's required checks don't run here. #6062's new 10-bit x265 commit is the base, so I didn't review it here.
The earlier nit (bundled gnutls/nettle on the shared /var/task/lib path) still stands as a taste call, not a blocker.
Verdict: APPROVE
Reasoning: The image smoke now launches Chrome through Lambda's own bootstrap and renders on arm64 with the pinned pack. That was the evidence missing at dcdeefc2, and the trigger paths now cover a Chromium bump.
— Via
003729a to
b1f62bb
Compare
a51fd1d to
295c5a7
Compare
The base branch was changed.
The image is the release handler ZIP with its x86 ffmpeg and Chrome swapped for the native ffmpeg tree and the sha256-pinned Sparticuz arm64 Chrome pack, so the x86 and arm64 functions run the same handler code. The image stage only copies, so any host builds it. CI builds it and runs ffmpeg, a real Chrome render and the Lambda runtime on an ARM runner.
@sparticuz/chromium inflates its AL2023 libraries only when AWS_EXECUTION_ENV names a Node runtime; Lambda sets it, a bare docker run does not. The workflow also runs on @sparticuz/chromium bumps and handler ZIP layout changes, which re-stage the image.
The smoke is now a handler invoked through the image's entrypoint, whose bootstrap sets AWS_EXECUTION_ENV the way Lambda does, so @sparticuz/chromium takes its Lambda branch with nothing set by hand. It returns the value it saw.
b1f62bb to
325339f
Compare
…checked pack to tar in memory
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 0 nits
Re-reviewed at 0a6af61f. The only change since my approval at c4889c0c is one commit to scripts/stage-arm64-image.ts (+12/−10).
- The URL comes from the pin table. It is built from the matched pin key, which equals the installed version, so the request goes to the same URL as before. A version with no pin still throws before any fetch.
- Only checksum-matched bytes reach tar. The pack is hashed first and then piped to
tar -xf -over stdin, so no temp file is written. A mismatch throws beforerun.inputwith a piped stdin is correct forspawnSync, andmaxBufferlimits only stdout and stderr. - Both CodeQL threads are resolved, and CodeQL is green at this head.
bun test scripts/stage-arm64-image.test.tspasses 5/5 locally (Bun 1.4.4). The "swaps Chrome" test exercises the stdin extraction path.
CI
Lambda arm64 image, CI, CodeQL, regression, preview-regression, PR captures, Player perf and Comments are green at 0a6af61f. Windows render verification was still running when I posted, and it skips aws-lambda. The earlier /var/task/lib nit is still a taste call.
— Via
What
The container image for an arm64 Lambda video function, and CI that builds it and runs it on a native ARM runner. Stacked on #6062, which adds the native ffmpeg build.
Nothing deploys this image yet: the release artifact and the
lambda deployoption come next. The default x86 ZIP deploy is untouched.Why
Lambda arm64 needs native binaries for ffmpeg (#6062) and Chrome. Everything else in the handler ZIP is architecture-neutral JavaScript. Building the image from that same ZIP means the x86 and arm64 functions run identical handler code.
How
scripts/stage-arm64-image.tsunzips the handler ZIP into a staging/var/task. It replacesbin/ffmpegandbin/ffprobewith the native tree from build(aws-lambda): pinned native ffmpeg build for an arm64 Lambda image #6062's artifact (binaries, their two bundled libraries, licenses), then asserts both are 64-bit arm64 ELF.@sparticuz/chromiumpackage ships x64 Chrome only. The script downloads Sparticuz's arm64 pack for the exact installed version, checks it against a sha256 pinned per version, and unpacks it over the package'sbin/.src/chromium.tscallsexecutablePath()unchanged.@sparticuz/chromiumfails the staging until its arm64 pack is pinned. A handler ZIP built withchrome-headless-shellis refused.image/Dockerfilegains avideostage that only copies the staged directory onto the same pinned Lambda Node 22 base the ffmpeg was built on. OneARGowns that pin, and any host can build the stage without emulation.lambda-arm64-image.yml) keeps build(aws-lambda): pinned native ffmpeg build for an arm64 Lambda image #6062's two ARM ffmpeg builds and byte-identical comparison. It adds two jobs:executablePath()andargsassrc/chromium.ts;Test plan
bun test scripts/stage-arm64-image.test.ts: 5 pass, 0 fail, exit 0, three runs in a rowchrome-headless-shell, never swap ChromeLambda arm64 imageworkflow (ARM ffmpeg x2 + match, handler ZIP, image smoke on ARM)Not exercised here: the image running in Lambda itself. That is proven with the deploy PR.