Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] (likely) Chromium Segfault on ARM - Graviton lambdas, Apple Silicon + Docker Lambda #19

Closed
alessbelli opened this issue Nov 23, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@alessbelli
Copy link

Environment

  • chromium Version: 107
  • puppeteer / puppeteer-core Version: ^18.1.0
  • Node.js Version: 16.x
  • Lambda / GCF Runtime: nodejs16.x, arm64

Expected Behavior

chrome doesn't crash

Current Behavior

on puppeteer browser start,

Error: Failed to launch the browser process!
/tmp/chromium: /tmp/chromium: cannot execute binary file

Steps to Reproduce

create a lambda with arm64 architecture (Architectures: ["arm64"])
invoke the following code

const chromium = require('@sparticuz/chromium')
const puppeteer = require('puppeteer-core')

exports.handler = async (event, context, callback) => {
  let result = null;
  let browser = null;

  try {
    browser = await puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: await chromium.executablePath,
      headless: chromium.headless,
      ignoreHTTPSErrors: true,
    });

  } catch (error) {
    return callback(error);
  } finally {
    if (browser !== null) {
      await browser.close();
    }
  }

  return callback(null, result);
};

Possible Solution

This is likely because the chromium binary is compiled using x64 as a target.
I believe that for it to work properly, there should be ansible steps to compile for arm, and two different binaries should be present here, then either based on runtime environment detection or based on arguments, the correct executable should be used.

@alessbelli alessbelli added the bug Something isn't working label Nov 23, 2022
@alessbelli
Copy link
Author

The above are the exact set of repro steps on lambda. While it's not critical for us to make this work on slightly cheaper lambdas, I believe the same issue prevents development on Apple Silicon macs - which run lambdas using AWS's provided images (amazon/aws-lambda-nodejs), which I believe run natively, and therefore run into the same incompatibility when launching chromium built for x86-64

@Sparticuz
Copy link
Owner

Yes, currently this is only for x86-64. This PR from the old package explains more. If you are able to get it working send in a PR! Sparticuz/chrome-aws-lambda#11

@alessbelli
Copy link
Author

Thanks for confirming. I guess it's either waiting for lambda on AL2022, trying to find someone who compiled glibc2.29+ on AL2, or figuring out how to compile chromium with the older lib?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants