Sparticuz / chromium

Chromium (x86-64) for Serverless Platforms
MIT License
1.02k stars 69 forks source link

[BUG] Segmentation fault when launching inside aws lambda docker image #70

Closed Myztiq closed 1 year ago

Myztiq commented 1 year ago

Environment

Expected Behavior

Browser launch should not trigger a segfault

Current Behavior

When trying to launch the browser it crashes with:

browserType.launch: Browser closed.
        ==================== Browser output: ====================
        <launching> /tmp/chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --allow-running-insecure-content --autoplay-policy=user-gesture-required --disable-background-timer-throttling --disable-component-update --disable-domain-reliability --disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process --disable-ipc-flooding-protection --disable-print-preview --disable-dev-shm-usage --disable-setuid-sandbox --disable-site-isolation-trials --disable-speech-api --disable-web-security --disk-cache-size=33554432 --enable-features=SharedArrayBuffer --hide-scrollbars --ignore-gpu-blocklist --in-process-gpu --mute-audio --no-default-browser-check --no-first-run --no-pings --no-sandbox --no-zygote --use-gl=angle --use-angle=swiftshader --window-size=1920,1080 --single-process --user-data-dir=/tmp/playwright_chromiumdev_profile-kPCJGx --remote-debugging-pipe --no-startup-window
        <launched> pid=42
        [pid=42][err] qemu: uncaught target signal 11 (Segmentation fault) - core dumped
        =========================== logs ===========================
        <launching> /tmp/chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --allow-running-insecure-content --autoplay-policy=user-gesture-required --disable-background-timer-throttling --disable-component-update --disable-domain-reliability --disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process --disable-ipc-flooding-protection --disable-print-preview --disable-dev-shm-usage --disable-setuid-sandbox --disable-site-isolation-trials --disable-speech-api --disable-web-security --disk-cache-size=33554432 --enable-features=SharedArrayBuffer --hide-scrollbars --ignore-gpu-blocklist --in-process-gpu --mute-audio --no-default-browser-check --no-first-run --no-pings --no-sandbox --no-zygote --use-gl=angle --use-angle=swiftshader --window-size=1920,1080 --single-process --user-data-dir=/tmp/playwright_chromiumdev_profile-kPCJGx --remote-debugging-pipe --no-startup-window
        <launched> pid=42
        [pid=42][err] qemu: uncaught target signal 11 (Segmentation fault) - core dumped
        ============================================================

Steps to Reproduce

https://github.com/Myztiq/lambda-playwright-chromium-crash

  1. docker build --platform linux/x86_64 . -t lambda-test
  2. docker run --platform linux/x86_64 -p 9000:8080 lambda-test
  3. In another terminal window curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -H 'Content-Type: application/json' -d {}

I looked through playwright's version support and it looks like we should be locking it to 1.31.0 as that was tested agains Chromium 111.0.5563.19 and stable Google Chrome 110. I'm trying to get my lambdas updated to node 18 and I can no longer use chrome-aws-lambda to do that.

I should add that I can get everything to work when I don't use docker, but I am running into an issue that can only be reproduced on the remote lambda server so I need to get this running in docker to be able to reproduce and debug locally.

Myztiq commented 1 year ago

Based on some reading https://github.com/docker/for-mac/issues/6204 seems to be the issue. Once https://github.com/Sparticuz/chrome-aws-lambda/pull/11 is there this should get resolved which relies on https://github.com/aws/aws-lambda-base-images/issues/59 .

I'll close the ticket for now.