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 支持:

如果你已經通過檢查輸出 vainfo 確認了有效的 VA-API 支持,則可以先單獨嘗試以下標誌:

~/.config/chromium-flags.conf
--enable-features=VaapiVideoDecodeLinuxGL

否則請繼續嘗試以下步驟:

  • 為你的顯卡安裝正確的 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 縮放。

資源[編輯 | 編輯原始碼]