Puppeteer and Docker for Mac (Apple M1)
Asked Answered
C

1

7

Chromium is crashing when opened via puppeteer navigation with the following stack trace on my M1. I'm looking for some help from the community as non m1 based machines don't seem to have an issue with our puppeteer container.

[0613/204124.018517:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
[0613/204124.746267:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
[0613/204124.751355:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
[0613/204124.981155:FATAL:nacl_helper_linux.cc(440)] Check failed: nacl_sandbox->IsSingleThreaded().

qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[130:130:0613/204125.140482:FATAL:zygote_main_linux.cc(162)] Check failed: sandbox::ThreadHelpers::IsSingleThreaded().
#0 0x0040072b9339 <unknown>
#1 0x00400722ff23 <unknown>
#2 0x00400722d070 <unknown>
#3 0x00400722dc6e <unknown>
#4 0x004006dae926 <unknown>
#5 0x004006da973e <unknown>
#6 0x004006daa369 <unknown>
#7 0x004006dab0cb <unknown>
#8 0x004006da838e <unknown>
#9 0x004006da8d4e <unknown>
#10 0x0040036e1227 <unknown>
#11 0x00400faba0b3 <unknown>
#12 0x0040036e102a <unknown>
Crash keys:
  "switch-7" = "--enable-crashpad"
  "switch-6" = "--change-stack-guard-on-fork=enable"
  "switch-5" = "--user-data-dir=/tmp/puppeteer_dev_chrome_profile-5BphEe"
  "switch-4" = "--enable-crash-reporter=,"
  "switch-3" = "--crashpad-handler-pid=117"
  "switch-2" = "--enable-crashpad"
  "switch-1" = "--no-sandbox"
  "num-switches" = "8"

qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[112:138:0613/204125.830241:ERROR:file_path_watcher_inotify.cc(329)] inotify_init() failed: Function not implemented (38)
[0613/204125.946536:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Function not implemented (38)
Assertion failed: p_rcu_reader->depth != 0 (/qemu/include/qemu/rcu.h: rcu_read_unlock: 101)


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

Error scraping url: <my - url>: 
Error: Unable to launch chrome

I'm launching puppeteer with the following options:

  const args = [
    '--no-first-run',
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--single-process',
    '--disable-dev-shm-usage',
    '--ignore-certificate-errors',
    '--ignore-urlfetcher-cert-requests',
    '--disable-blink-features=AutomationControlled'
  ];

And I'm installing chromium into by ubuntu based container via:

# Install Chrome for Ubuntu
RUN apt-get update \
 && apt-get install -y chromium-browser

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium
Commandant answered 13/6, 2022 at 20:51 Comment(0)
F
2

Spent all day trying to fix it. In the end running docker with colima solved the issue. The thing is that some stuff simply will not work on arm and there is no point in fighting it. Colima allows you to run everything via Rosetta, hence emulating x86 all the way.

  1. First install colima with brew install colima.
  2. Shut down docker desktop if it's running.
  3. Start colima with colima start --arch aarch64 --vm-type=vz (check readme for more info)
  4. Now you have docker running fully via Rossetta. When running images, use "--platform linux/amd64".
Fracas answered 8/1, 2023 at 11:50 Comment(1)
Does this still work for you? colima changed sometime in early 2023 where the options to specify Rosetta have changed (need to specify --vz-rosetta, I'm also using --arch x86_64), but no matter what I do I still always get "target closed" errors when launching the browser.Peroxidize

© 2022 - 2024 — McMap. All rights reserved.