Ladybird Browser Launch Options

ladybird 的全部启动参数。权威来源是它自己:

Meta/ladybird.py run ladybird -- --help
ARGSPARSER_EMIT_MARKDOWN=1 Meta/ladybird.py run ladybird -- --help

标注 隐藏 的参数不进 --help,但照常能用(parse() 不看 hide_mode)。

命令行参数

位置参数

参数 取值 / 示例 说明
url 取值 [url ...],如 ladybird example.com a.html 启动时打开的 URL,可省略、可多个
URLs to open at startup

源码:Libraries/LibWebView/Application.cpp:389

通用

参数 取值 / 示例 说明
--help 无,如 ladybird --help 显示帮助后退出
Display help message and exit
--version 无 打印版本号
Print version
--complete 无,隐藏 为后续 argv 输出补全 JSON
Emit shell-completion JSON
-C, --certificate 取值 <certificate>,如 -C ca.pem 证书文件,可重复
Certificate file, repeatable
-n, --new-window 无 强制开新窗口
Force a new window
--test-mode 无 测试模式
Enable test mode
--default-time-zone 取值 <id>,如 --default-time-zone Asia/Shanghai 默认时区
Default time zone
--resource-map 取值 <path>,如 --resource-map map.json JSON,把 URL 映射到本地文件
JSON mapping URLs to local files
--user-agent-preset 取值 <name> 用指定 UA 预设顶掉默认 UA
Use a named User-Agent preset

源码:--help/--version/--complete 在 Libraries/LibCore/ArgsParser.cpp:34-36,其余在 Libraries/LibWebView/Application.cpp:389-539

Headless 与窗口

参数 取值 / 示例 说明
--headless 取值 [=mode],如 --headless、--headless=text 不开窗口跑。mode ∈ screenshot(默认,省略值即取它)、layout-tree、text、manual、terminal(非 Windows)
Run without a window; screenshot is the default
--screenshot-delay 取值 <seconds>,如 --screenshot-delay 3 截图前等几秒(仅 screenshot 模式)
Seconds to wait before the screenshot
--screenshot-path 取值 <path>,如 --screenshot-path out.png 截图存哪(仅 screenshot 模式)
Where to save the screenshot
--window-width 取值 <pixels>,如 --window-width 1280 视口宽,默认 800,目前仅 headless 生效
Viewport width, default 800
--window-height 取值 <pixels>,如 --window-height 720 视口高,默认 600,目前仅 headless 生效
Viewport height, default 600
--device-pixel-ratio 取值 <ratio>,如 --device-pixel-ratio 2 DPR,默认 1,仅 headless terminal 模式
Device pixel ratio, default 1

源码:Libraries/LibWebView/Application.cpp:391-421

Profile 与进程统计

参数 取值 / 示例 说明
--profile 取值 <name>,如 --profile scratch 选用或创建命名 profile
Select or create a named profile
--profile-path 取值 <path> 在该绝对路径下用一份自包含 profile
Self-contained profile at an absolute path
--temporary-profile 无 临时 profile,正常退出即删
Temporary profile, removed on clean shutdown
--replace-unresponsive-browser-from-before 取值 <unix-ms> 结束该时刻前启动、且已无响应的同 profile 浏览器并接管(非 Windows,UI 自动注入)
Replace an unresponsive earlier browser
--stats-log-dir 取值 <path> 进程统计(JSON lines)写到哪;Android 不注册
Directory for process statistics

源码:Libraries/LibWebView/Application.cpp:437-445

网络、DNS 与缓存

参数 取值 / 示例 说明
--proxy-autoconfig-url 取值 <url>,隐藏 PAC 地址,源码注明暂不支持、请求会失败
PAC URL, not supported yet
--dns-server 取值 <host>,如 --dns-server 1.1.1.1 DNS 服务器地址
DNS server address
--dns-port 取值 <port> DNS 端口;不给时 53,带 --dot 时 853
DNS port, 53 by default, 853 with --dot
--dot 无 走 DNS over TLS
Use DNS over TLS
--dnssec 无 本地验证 DNSSEC
Validate DNSSEC locally
--disable-http-memory-cache 无 关掉 HTTP 内存缓存
Disable the HTTP memory cache
--disable-http-disk-cache 无 关掉 HTTP 磁盘缓存
Disable the HTTP disk cache
--max-site-request-servers 取值 <count>,如 --max-site-request-servers 0 每个站点可用的 RequestServer 数,0 = 共用一个
RequestServers per site; 0 shares one
--disable-content-blocker 无 关掉内容拦截
Disable content blocking
--content-blocker-list 取值 <path>,可重复 拦截列表路径
Content blocker list, repeatable
--force-video-decoder-server 无 没硬解的视频也丢给 VideoDecoderServer
Force software video through VideoDecoderServer

源码:Libraries/LibWebView/Application.cpp:423-435(PAC)、:473-521(其余)

页面行为

参数 取值 / 示例 说明
--allow-popups 无 默认不拦弹窗
Do not block popups by default
--disable-scripting 无 默认禁用脚本
Disable scripting by default
--disable-sql-database 无 禁用 SQL 数据库
Disable the SQL database
--tuple-file-origins 无 把 file:// 当 tuple origin
Treat file:// URLs as tuple origins
--log-all-js-exceptions 无 记录所有 JS 异常
Log all JavaScript exceptions
--enable-autoplay 无 允许自动播放
Enable multimedia autoplay
--expose-experimental-interfaces 无 暴露实验性 IDL 接口
Expose experimental IDL interfaces
--expose-internals-object 无 暴露 internals 对象
Expose the internals object
--disable-scrollbar-painting 无 主视口不画滚动条
Do not paint scrollbars on the main viewport
--force-fontconfig 无 字体加载强制走 fontconfig
Force fontconfig for font loading

源码:Libraries/LibWebView/Application.cpp:447-517

性能与调试

参数 取值 / 示例 说明
--debug-process 取值 <name>,如 --debug-process=WebContent,可重复 让指定进程等调试器 attach
Wait for a debugger on the given process
--profile-process 取值 <name> 对指定进程做性能分析
Profile the given process
--profile-tool 取值 <tool>,callgrind(默认)或 cpu 选分析器
Select the profiler
--profile-output 取值 <path> CPU profiler 输出路径,要配 --profile-tool=cpu
Where to write CPU profiler output
-g, --collect-garbage-on-every-allocation 无 每次 JS 堆分配后都 GC
GC after every JS heap allocation
--force-cpu-painting 无 强制 CPU 绘制,等价 --disable-features=gpu_painting
Same as --disable-features=gpu_painting
--disable-features 取值 <feature,...>,可重复 关闭平台特性及其依赖者
Turn off platform features
--force-enable-features 取值 <feature,...>,可重复 越过黑名单强开平台特性
Force-enable features despite the blocklist
--devtools 取值 [=port],如 --devtools、--devtools=9229 开 Firefox DevTools server,端口可省(默认 6000)
Enable the DevTools server, port optional
--disable-sandbox 无 关掉辅助进程沙箱
Disable helper process sandboxing
--web-content-memory-limit 取值 <MiB>,0 = 不限 WebContent 内存上限
Memory limit for WebContent

源码:Libraries/LibWebView/Application.cpp:451-537,DevTools 默认端口 Libraries/LibWebView/Options.h:69

隐藏与内部参数

参数 取值 / 示例 说明
--webdriver-browser-mach-server-name 取值 <name>,隐藏,仅 macOS 浏览器 WebDriver IPC 的 Mach server 名
Mach server for WebDriver IPC
--webdriver-browser-path 取值 <path>,隐藏,非 macOS 浏览器 WebDriver IPC 路径
Path to the WebDriver IPC
--ui-info 取值 <hex>,隐藏 UI 交给 Hub 的启动信息
What the UI tells the Hub to start with
--ui-mach-server 取值 <name>,隐藏,仅 macOS Hub 回连 UI 的 Mach server
Mach server for the Hub to reach the UI
--ui-pid 取值 <pid>,隐藏 Hub 结束时一并结束的 UI 进程 PID
PID of the UI process the Hub ends with

前两条被 #if defined(AK_OS_MACOS) 夹着,单个构建里只有一条;后三条由 UI 自动注入,别手敲。

源码:Libraries/LibWebView/Application.cpp:466-469、Services/Hub/Application.cpp:28-31


OptionHideMode 定义在 Libraries/LibCore/ArgsParser.h:43-47:Markdown 只在 Markdown 渲染里藏(终端 --help 照样显示),CommandLineAndMarkdown 则连 --help 和补全都不出现(跳过点 Libraries/LibCore/ArgsParser.cpp:219/251/296/744)。

Comments