Chromium
Chromium 是一款來自 "The Chromium Project" 的開源圖形網絡瀏覽器,基於 Blink 渲染引擎。它也是商業軟體 Google Chrome 瀏覽器得以組成的基礎。
在這裡你可以看到 Google Chrome 與 Chromium 瀏覽器的區別。此外,還有一點重要的不同:
- 2021年3月2日發布的 Chromium 89 及其以後版本不再支持 Google 帳戶同步功能。
長期來講,最好考慮使用 xbrowsersync 來同步書籤數據。
在這裡 List of applications/Internet#Blink-based 你可以看到基於 Chromium 的其它瀏覽器。
安裝[編輯 | 編輯原始碼]
想要安裝Chromium的話,有以下幾種安裝包可選:
- chromium包 — 穩定版本;
- chromium-devAUR — Dev 開發版本;
- chromium-snapshot-binAUR — Nightly 每日構建版本.
Google Chrome 軟體包:
- google-chromeAUR — 穩定版本;
- google-chrome-betaAUR — Beta 測試版本;
- google-chrome-devAUR — Dev 開發版本.
配置[編輯 | 編輯原始碼]
設置成默認瀏覽器[編輯 | 編輯原始碼]
要講 Chromium 設置成默認瀏覽器或設置下載文件的打開方式,請參閱 Default applications。
持久地應用 flags[編輯 | 編輯原始碼]
chromium-flags.conf
和附帶的自定義啟動腳本是特定於 Arch Linux 軟體倉庫所打的chromium包包的。對於 google-chromeAUR和google-chrome-devAUR,請用 chrome-flags.conf
和chrome-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]
視頻硬體解碼[編輯 | 編輯原始碼]
如果要為 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
原生Wayland上運行[編輯 | 編輯原始碼]
從版本 97 開始,可以使用以下標誌啟用chromium中的原生 Wayland 支持[6]:
--ozone-platform-hint=auto
請參閱#持久地應用 flags進行配置。完整的flags可查看Chromium#Tips and tricks 2。
這將在 wayland 會話中選擇 wayland Ozone 後端,因此,如果您經常在 X11 和 Wayland 之間反覆切換,則可以使用單個桌面條目。
如果您使用的輸入法fcitx5包,可能會出現無法在瀏覽器中使用輸入法的情況,若想解決這個問題還需要添加以下標誌。詳情請參考[7]。
--gtk-version=4
在採用上述標誌時,fcitx5可能也無法正常使用。嘗試使用--enable-wayland-ime標識代替--gtk-version=4。
提示和技巧[編輯 | 編輯原始碼]
見主要文章: Chromium/Tips and tricks。
疑難解答[編輯 | 編輯原始碼]
字體[編輯 | 編輯原始碼]
PDF 插件中的字體問題[編輯 | 編輯原始碼]
安裝軟體包 ttf-liberation包 可以解決一些 PDF 的字體顯示問題,不然的話替代字體會顯示成其他的文字。reported on the chromium bug 報告.
在瀏覽器和Flash播放器插件強制使用3D加速功能[編輯 | 編輯原始碼]
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 縮放。