You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

M1芯片Mac Docker环境Puppeteer启动Chromium崩溃问题求助

问题描述
  • 运行环境:搭载Apple M1芯片的Mac设备
  • 异常表现:通过Puppeteer执行页面导航操作时,容器内Chromium出现崩溃,直接抛出「无法启动Chrome」错误导致网页抓取流程中断;同一套Puppeteer容器在非M1架构设备上运行无任何异常
崩溃触发时完整堆栈日志
[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)

Error scraping url: <my - url>: 
Error: Unable to launch chrome
当前运行配置

Puppeteer启动参数

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'
];

容器内Chromium安装配置(基于Ubuntu基础镜像构建)

# 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
问题根因

日志中明确出现qemu相关转译报错,核心原因是当前构建的Ubuntu容器为x86/amd64架构,在M1(arm64架构)设备上运行时,Docker默认通过QEMU做跨架构指令转译。Chromium的沙箱校验、NativeClient组件、zygote进程单线程检查、inotify/ptrace系统调用均存在QEMU转译兼容问题,直接触发进程崩溃。该问题和Puppeteer版本、Chromium安装逻辑无直接关联,这也是同镜像在非M1设备上运行正常的核心原因。

修复方案
  • 优先构建支持arm64/amd64的多架构容器镜像,M1设备运行时直接调度arm64版本镜像,完全跳过QEMU跨架构转译,是最彻底的解决方式
  • 临时调试场景下,启动容器时显式指定--platform=linux/amd64参数,同时移除Puppeteer启动参数中的--single-process配置,追加--disable-gpu、--disable-software-rasterizer、--disable-features=NativeClient参数,关闭易触发转译冲突的组件,可解决大部分启动崩溃问题
  • 避免直接通过apt源安装chromium-browser包,该包在arm64架构下存在多处依赖缺失,建议直接使用官方维护的多架构Chromium基础镜像构建运行环境,减少手动安装带来的兼容问题

内容的提问来源于stack exchange,提问作者Jesse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 17:27:41