Chromium

来自 Arch Linux 中文维基

Chromium 是一款来自 "The Chromium Project" 的开源图形网络浏览器,基于 Blink 渲染引擎。它也是商业软件 Google Chrome 浏览器得以组成的基础。

这里你可以看到 Google Chrome 与 Chromium 浏览器的区别。此外,还有一点重要的不同:

  • 2021年3月2日发布的 Chromium 89 及其以后版本不再支持 Google 账户同步功能。

[1]

注意: 目前,可以通过 使用 Chrome 的OAuth2 凭证或者 申请一个属于自己的凭证来恢复同步功能, 但是请注意,这不一定是一个长期的解决方案。

长期来讲,最好考虑使用 xbrowsersync 来同步书签数据。

在这里 List of applications/Internet#Blink-based 你可以看到基于 Chromium 的其它浏览器。

安装[编辑 | 编辑源代码]

想要安装Chromium的话,有以下几种安装包可选:


Google Chrome 软件包:

注意: 根据 Chromium 隐私页面中所述: "在 Chromium 浏览器的代码中与 Google 有关的特性,编译之后的二进制程序是遵循 Google Privacy Policy的." 如果不希望 Chromium 浏览器代码中存在与 Google 集成的部分,请参阅 为隐私优化的Chromium发行版.


配置[编辑 | 编辑源代码]

设置成默认浏览器[编辑 | 编辑源代码]

要讲 Chromium 设置成默认浏览器或设置下载文件的打开方式,请参阅 Default applications


持久地应用 flags[编辑 | 编辑源代码]

注意: 文件chromium-flags.conf 和附带的自定义启动脚本是特定于 Arch Linux 软件仓库所打的chromium包的。对于 google-chromeAURgoogle-chrome-devAUR,请用 chrome-flags.confchrome-dev-flags.conf来代替。

你可以把你的 flag 写到$HOME/.config/(或$XDG_CONFIG_HOME,只是需要你配置环境变量)目录下的chromium-flags.conf

无需使用特殊语法,这些flag就能像终端参数一样被 Chromium 识别和使用。

  • 参数按空格分割,并遵循shell引用规则,但不会做进一步的解析。
  • 假如文件中有不正确的引用,则会引发Fatal Error。
  • 为了便于阅读,可以将flag置于单独的行中。
  • 以井号 (#) 开头的行不会被读取. (这条规则只被 chromium 启动脚本所支持 ,所以你在使用google-chromeAUR软件包时其实是没有这条规则的)

下面是 chromium-flags.conf 文件的一个例子,它定义了一个 --start-maximized --incognito的flag:

~/.config/chromium-flags.conf
# This line will be ignored.
--start-maximized
--incognito

强制使用 GPU 加速[编辑 | 编辑源代码]

警告: 禁用渲染黑名单可能会导致程序不稳定,在 chrome://gpu 可以看到对应的bug report的细节。

默认来说 Linux 平台上的 Chromium 不会启用任何 GPU 加速功能。为了强制使用 GPU 加速功能,把以下flag加入到持久配置中:

~/.config/chromium-flags.conf
--ignore-gpu-blocklist
--enable-gpu-rasterization
--enable-zero-copy

此外这个--disable-gpu-driver-bug-workarounds的flag也需要视情况开启或关闭。在 chrome://gpu 的flag应该显示为"Hardware accelerated"如果配置正确的话。 自从 mesa 20.1.1版本起,--enable-native-gpu-memory-buffers 不再生效。[2]

视频硬件解码[编辑 | 编辑源代码]

注意:
  • Arch 和Chromium 都不对这个特性作官方的支持, [3]. 但是,官方软件仓库中的 chromium 已经编译有 VA-API 支持,如果遇到问题你可以在 这个论坛帖子中寻求帮助.
  • 目前不支持 Wayland

如果要为 Chromium 启用 VA-API 支持:

  • 为你的显卡安装正确的 VA-API 驱动,并且确认 VA-API 已经被启用并且正常工作,详见 Hardware video acceleration.对于 NVIDIA 专有驱动的支持,请安装libva-vdpau-driver-chromiumAUR 或者libva-vdpau-driver-vp9-gitAUR
  • 设置这个参数 --enable-features=VaapiVideoDecoder. 如果你使用 X11,还需要设置参数 --disable-features=UseOzonePlatform.这个参数对于 ANGLE GL renderer + libva-intel-driver 是生效的.
  • 当使用 ANGLE 时, Chromium 会强制使用旧的 i965 驱动,不支持 intel-media-driver。一个解决方案是 手动配置VA-API. 详见[4]
  • 如果想在 Xorg 上使用系统提供的 GL 渲染器,使用 --use-gl=egl--use-gl=desktop两个参数之一
  • 如果想在 XWayland 上使用系统提供的 GL 渲染器,使用--use-gl=egl 参数 (在一些系统上可能存在 bug:FS#67035).
  • 运行在X11上的老旧显卡(笔者显卡是intel HD Graphics 4000),可以使用环境变量LIBVA_DRI3_DISABLE=1来启动硬件加速。或在命令行通过LIBVA_DRI3_DISABLE=1 chromium 启动浏览器(详见 https://www.phoronix.com/news/VA-API-lib)。

小提示[编辑 | 编辑源代码]

To check if it's working play a video which is using a codec supported by your VA-API driver (vainfo tells you which codecs are supported, but Chromium will only support VP9 and h264):

  • Open the DevTools by pressing Ctrl+Shift+I or on the Inspect button of the context (right-click) menu
  • Add the Media inspection tab: Hamburger menu > More tools > Media
  • In the newly opened Media tab, look at the hardware decoder state of the video decoder

Test on a large enough video. Starting with version 86, Chromium on desktop will only accelerate videos larger than 720p.

To reduce CPU usage while watching YouTube where VP8/VP9 hardware decoding is not available use the h264ify or enhanced-h264ify extension.

On some systems (especially on XWayland) you might need to #强制使用 GPU 加速. Only --ignore-gpu-blocklist is enough for our purposes.

You might need to disable the Skia renderer, as it is currently not compatible with video decode acceleration: --disable-features=UseSkiaRenderer

Flash播放器[编辑 | 编辑源代码]

自从 Chromium 88 起, Flash player支持被彻底移除。[5]


在Chromium中打开pdf文件[编辑 | 编辑源代码]

Chromium 和 Google Chrome 内置了Chromium PDF Viewer 插件。如果你不想用这个插件,在chrome://settings/content/pdfDocuments勾选使用不同的应用程序打开 PDF文件 .

证书管理[编辑 | 编辑源代码]

Chromium 使用 NSS 管理证书,可以通过chrome://settings/certificates.设置。

XWayland上运行[编辑 | 编辑源代码]

如果您使用的是 NVIDIA 的专有驱动程序,则在 XWayland 上运行 Chromium 可能会导致 GPU 进程偶尔崩溃。要防止 GPU 进程崩溃,请添加以下标志:

--use-angle=vulkan
--use-cmd-decoder=passthrough
注意: 这并不能防止所有与 XWayland 相关GPU进程的崩溃。

原生Wayland上运行[编辑 | 编辑源代码]

从版本 97 开始,可以使用以下标志启用chromium中的原生 Wayland 支持[6]:

--ozone-platform-hint=auto

请参阅#持久地应用 flags进行配置。完整的flags可查看Chromium#Tips and tricks 2

这将在 wayland 会话中选择 wayland Ozone 后端,因此,如果您经常在 X11 和 Wayland 之间反复切换,则可以使用单个桌面条目。

注意: 在浏览器标志菜单中更改“ozone-platform-hint”时,浏览器会提供一个“重新启动”按钮。不要使用这个,因为浏览器仍将在更改标志之前的平台中重新启动。您需要关闭浏览器,然后将其打开。

如果您使用的输入法fcitx5,可能会出现无法在浏览器中使用输入法的情况,若想解决这个问题还需要添加以下标志。详情请参考[7]

--gtk-version=4

在采用上述标志时,fcitx5可能也无法正常使用。尝试使用--enable-wayland-ime标识代替--gtk-version=4。

注意: 启用--enable-wayland-ime标识时,只有在实现了text_input_v1协议的情况下才有效。已知实现该协议的桌面环境:Weston,Kwin,Hyprland。


提示和技巧[编辑 | 编辑源代码]

见主要文章: Chromium/Tips and tricks

疑难解答[编辑 | 编辑源代码]

字体[编辑 | 编辑源代码]

注意: Chromium does not fully integrate with fontconfig/GTK/Pango/X/etc. due to its sandbox. For more information, see the Linux Technical FAQ.

PDF 插件中的字体问题[编辑 | 编辑源代码]

安装软件包 ttf-liberation 可以解决一些 PDF 的字体显示问题,不然的话替代字体会显示成其他的文字。reported on the chromium bug 报告.

在浏览器和Flash播放器插件强制使用3D加速功能[编辑 | 编辑源代码]

警告: 禁用渲染列表可能会导致包括主机崩溃在内的不稳定的行为。你可以在这里看到Bug报告chrome://gpu.

首先,确认你已经安装了所有已经在 VDPAU 中列出的包。然后,在 chrome://flags 中将 "Override software rendering list" 设置为 enable。你可以在 chrome://gpu 中检查设置是否起效。这也可能会减少 radeon 驱动的画面撕裂问题。

WebGL[编辑 | 编辑源代码]

有时 Chromium 会在某些显卡配置中禁用 WebGL,可以通过URL中输入about:flags,然后启用 WebGL. 通过命令行 --enable-webgl 选项也能启用它。

有可能 Chromium 把你的显卡列入了黑名单,如果是这样,可以通过--ignore-gpu-blacklist选项禁用黑名单。或者在about:flags 中启用 Override software rendering list.

界面混乱[编辑 | 编辑源代码]

Chromium 的图形界面可能在高分屏上显示异常,可以使用 --force-device-scale-factor=1 选项禁用按设备 DPI 缩放。

资源[编辑 | 编辑源代码]