Obscura:用 Rust 重写无头浏览器,内存从 200MB 降到 30MB,登顶 GitHub Trending

Obscura: Headless Browser Rewritten in Rust — Memory Down From 200MB to 30MB, GitHub Trending #1

Tech-Experiment #Rust#浏览器#AI Agent#爬虫#MCP#开源#Playwright#Puppeteer#无头浏览器#自动化
更新于
🇨🇳 中文

你的 AI Agent 要操作浏览器,标准方案是什么?

大概率是:装 Node.js、装 Chromium、用 Playwright 或 Puppeteer,然后发现每启动一个浏览器实例就要吃掉 200MB 内存,启动要等 2 秒,批量任务跑起来服务器内存告警。

Obscura 说:Chrome 太重了,我们用 Rust 重写一个。

2.7 万+ Stars,GitHub Trending 第一,并且直接启发了 Cloudflare 新一代 Agent 浏览器 Kitesurf 的原型。

GitHub:h4ckf0r0day/obscura


关键数字对比

指标ObscuraHeadless Chrome
内存占用30 MB200+ MB
二进制大小70 MB300+ MB
页面加载85 ms~500 ms
启动时间即时~2 秒
反检测内置无
Puppeteer 兼容✓✓
Playwright 兼容✓✓

内存降低到原来的 1/7,页面加载快 6 倍,启动从 2 秒变成即时——这不是边际优化,而是一个量级的差距。


技术原理:为什么可以这么轻

Obscura 是从头用 Rust 编写的无头浏览器引擎,不是对 Chrome 的封装。

JavaScript 执行:嵌入 V8(Chrome 的 JavaScript 引擎),但只有 V8,没有 Chrome 的其他重量级组件(Blink 渲染器、完整 Chromium 架构)。

渲染层:自研的 CSS 布局和绘制引擎,提供视口截图、全页面截图、滚动感知的 fixed/sticky 几何处理、基于活动驱动的 CDP 屏幕流,以及无需启动 Chromium 的 PDF 导出。

协议层:完整实现 Chrome DevTools Protocol(CDP),所以 Puppeteer 和 Playwright 可以直接连接——对它们来说,Obscura 就是一个正常的 Chrome。

这个设计的关键洞察:大多数网页自动化场景不需要 Chromium 的全部功能,需要的只是:

  1. 能跑 JavaScript(V8)
  2. 能操作 DOM
  3. 能截图和导出
  4. 符合 Puppeteer/Playwright 的接口

Obscura 只做这四件事,做得更快更轻。


核心功能

无依赖安装

# macOS Apple Silicon
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-aarch64-macos.tar.gz
tar xzf obscura-aarch64-macos.tar.gz

# 立即使用
./obscura fetch https://example.com --eval "document.title"

没有 Node.js,没有 npm,没有 Chrome——一个二进制文件搞定。

CLI 常用命令

# 抓取页面标题
obscura fetch https://example.com --eval "document.title"

# 渲染 JavaScript 后导出 HTML
obscura fetch https://news.ycombinator.com --dump html

# 截图
obscura fetch https://example.com --screenshot page.png

# 提取所有链接
obscura fetch https://example.com --dump links

# 纯文本
obscura fetch https://example.com --dump text

# 列出所有子资源 URL(NDJSON 格式)
obscura fetch https://example.com --dump assets

# 通过代理抓取
obscura fetch https://example.com --proxy socks5://127.0.0.1:1080

Puppeteer/Playwright 替代

作为 CDP 服务器启动:

# 启动 CDP 服务器,Puppeteer/Playwright 直接连接
obscura serve --port 9222

代码层面无需修改,把 Chrome 的 WebSocket 地址换成 ws://localhost:9222 即可。

MCP 集成

Obscura 原生支持 MCP(Model Context Protocol),可以直接作为 AI Agent 的浏览器工具。配套的 epicsagas/obscura-plugin 提供了专门面向 AI Agent 的 MCP server 封装,包含网页抓取、JavaScript 渲染和浏览器自动化能力。

Docker 部署

docker run -d --name obscura -p 127.0.0.1:9222:9222 h4ckf0r0day/obscura

基于 distroless/cc:nonroot 多阶段构建,压缩后约 57 MB,无 shell,无包管理器,以 uid 65532 运行。

反检测(Stealth 构建)

带 -stealth 后缀的版本内置反检测传输层(通过 BoringSSL),对抗常见的爬虫检测机制。四个构建变体:

变体渲染反检测
默认✓✗
-stealth✓✓
-no-render✗✗
-no-render-stealth✗✓

无需渲染的场景(只抓取 HTML,不需要截图)可以用 -no-render 版本,体积更小、速度更快。


Cloudflare Kitesurf:最好的背书

README 里有一段值得注意的信息:

Cloudflare began by porting Obscura to Workers while developing its new agent-first browser — Kitesurf.

Cloudflare 在开发 Kitesurf(专为 AI Agent 设计的浏览器服务)时,从 Obscura 出发写了第一个原型。这不是普通的”灵感来源”,而是 Cloudflare 工程团队直接基于 Obscura 的设计进行 Workers 移植。


适合的场景

最适合:

  • 批量网页抓取:内存低,可以同时跑大量实例
  • AI Agent 浏览器工具:MCP 集成,响应速度快
  • 截图服务:内置原生渲染,无需 Chromium
  • 本地 MCP 工具:单二进制,无依赖,本地运行成本极低
  • CI/CD 中的浏览器测试:70MB 镜像,Playwright 兼容

不适合:

  • 需要完整 CSS/渲染规范兼容性的场景(Obscura 自研渲染层,可能有细微差异)
  • 需要处理 WebGL/Canvas 密集型页面
  • 需要 Chrome Extension 支持

当前状态与路线图

项目正在活跃开发,Obscura Cloud(托管版本,含住宅代理和管理基础设施)在等待名单阶段。开源引擎保持 Apache-2.0,承诺不做功能锁定。

支持平台:Linux x86_64/ARM64、macOS Apple Silicon/Intel、Windows;也可以通过 AUR(Arch)和 NixOS 安装。


相关链接

🇬🇧 English

What’s your standard setup when an AI agent needs to control a browser?

Probably: install Node.js, install Chromium, use Playwright or Puppeteer — then discover each browser instance eats 200MB of RAM, startup takes 2 seconds, and running batch tasks triggers server memory alerts.

Obscura says: Chrome is too heavy. We rewrote a browser in Rust.

27k+ stars, GitHub Trending #1, and it directly inspired the prototype for Cloudflare’s next-generation agent browser, Kitesurf.

GitHub: h4ckf0r0day/obscura


The Numbers

MetricObscuraHeadless Chrome
Memory30 MB200+ MB
Binary size70 MB300+ MB
Page load85 ms~500 ms
StartupInstant~2s
Anti-detectBuilt-inNone
Puppeteer✓✓
Playwright✓✓

Memory reduced to 1/7th, page loading 6× faster, startup from 2 seconds to instant — this isn’t incremental improvement, it’s an order of magnitude.


Why It Can Be This Light

Obscura is a headless browser engine written from scratch in Rust, not a Chrome wrapper.

JavaScript: Embeds V8 (Chrome’s JavaScript engine) — just V8, without Chrome’s other heavyweight components (Blink renderer, full Chromium architecture).

Rendering: A custom CSS layout and paint engine providing viewport screenshots, full-page screenshots, scroll-aware fixed/sticky geometry, activity-driven CDP screencasting, and raster PDF export — all without starting Chromium.

Protocol: Full Chrome DevTools Protocol (CDP) implementation. To Puppeteer and Playwright, Obscura looks like a normal Chrome.

The key insight: most web automation scenarios don’t need all of Chromium’s capabilities. What they need is:

  1. JavaScript execution (V8)
  2. DOM manipulation
  3. Screenshots and export
  4. Puppeteer/Playwright interface compatibility

Obscura does exactly these four things, faster and lighter.


Key Features

Zero-dependency install: One binary, no Node, no npm, no Chrome.

CLI: fetch, dump, screenshot, eval, scrape (parallel with obscura-worker).

Puppeteer/Playwright drop-in: Start as CDP server on port 9222; change the WebSocket URL in your code and nothing else needs to change.

MCP integration: Native MCP support for AI agents. The companion obscura-plugin provides an MCP server wrapper with web scraping, JavaScript rendering, and browser automation tools.

Docker: h4ckf0r0day/obscura image, distroless-based, ~57 MB compressed, runs as non-root.

Stealth builds: BoringSSL-based transport for anti-detection. Four variants — with/without rendering, with/without stealth.


The Best Endorsement: Cloudflare Kitesurf

From the README:

Cloudflare began by porting Obscura to Workers while developing its new agent-first browser — Kitesurf.

Cloudflare’s engineering team used Obscura as the starting point for Kitesurf, their agent-first browser service. Not “inspired by” — they ported it to Workers.


Best-Fit Scenarios

Great fit: batch web scraping, AI agent browser tools (MCP), screenshot services, local MCP tools, CI/CD browser testing

Not ideal: scenarios requiring full CSS rendering spec compliance, WebGL/Canvas-heavy pages, Chrome Extension support


💬 评论与讨论

使用 GitHub 账号登录后发表评论

关于本站 · 免责声明

🍄 Mushroom Research Blog 是非营利、免费公开的个人科技观察博客与公众号 XStack18,不接受商业合作、不代表任何企业或机构立场,也不谋求商业利益。我们以个人视角客观中立地记录和分析 AI、Web3 等领域的最新模型发布与技术动态——不止转述新闻标题或二手信息,而是给出有独立思考的深入分析,希望帮更多人获得有价值的一手科技认知。

⚠️ 文中介绍的开源代码与模型,仅供学习交流与技术借鉴。它们大多仍处于早期阶段,有待进一步研究和验证,请勿直接用于工作或生产环境;如需采用,请先自行充分测试,并核实其许可证与安全性。
Open-source code and models featured here are shared for learning and reference only. Most are early-stage and still need further study and verification — please don't use them directly in your work or in production. Test them thoroughly and check their licenses and security first.

  1. 本站文章均为作者基于公开信息的个人研究与观点整理,不代表文中提及的任何公司、产品、模型的官方立场,未与其构成商业关联或合作关系。
  2. 科技行业信息更新极快,我们尽力保证内容准确、及时,但不对完整性、实时性做绝对保证,具体请以相关企业/项目官方公告为准。
  3. 文中引用的第三方商标、产品名称、图片、数据等版权归原权利人所有,我们会尽量注明来源;如你认为存在版权疑问或侵权,请通过下方邮箱联系我们,收到通知后会尽快核实处理(更正、加注来源或删除)。
  4. 文章内容仅为技术科普与个人观点,不构成投资、法律或其他专业建议,据此进行任何决策的后果需自行判断和承担。

📮 侵权 / 勘误 / 合作咨询:hello@mushroom.cv