我尝试使用selenium和webdriver_manager.chrome爬取特定网站,我的代码完全爬取了该网站的元素。但在爬取后,控制台窗口中出现以下错误消息。
ERROR:gpu_init.cc(426) Passthrough is not supported, GL is disabled
当我第一次发现它时,我取消了Chrome的硬件加速,但这并没有解决问题。
我尝试使用selenium和webdriver_manager.chrome爬取特定网站,我的代码完全爬取了该网站的元素。但在爬取后,控制台窗口中出现以下错误消息。
ERROR:gpu_init.cc(426) Passthrough is not supported, GL is disabled
当我第一次发现它时,我取消了Chrome的硬件加速,但这并没有解决问题。
测试环境
Windows操作系统,Chromedriver版本89,无头模式。
解决方案
我不确定这是否可以是你问题的解决方案,因为错误消息略有不同。
据我记得,错误消息Passthrough is not supported, GL is swiftshader
在Chromedriver版本89之后作为一个bug(但不确定)出现 [1]。
对于Windows来说,使用--headless
和--disable-gpu
选项可以使chromedriver以无头模式工作[2]。由于该bug,Linux也需要使用--disable-gpu
[3]。
如果同时删除--headless
和--disable-gpu
选项,则错误消息将不会出现。然而,chromedriver将不再以无头模式工作。
在我的情况下,错误消息不会影响无头chrome的操作。正如我所发现的,“通常,Chrome会退回到没有GPU的工作状态。然而,为了获得一致的结果,Telemetry需要GPU的存在 [4]。”
我还额外应用了--disable-software-rasterizer
选项以禁用WebGL [5]。在无头操作下,错误消息不再显示。
参考文献
[1] https://reddit.com/r/chrome/comments/n6qywt/hardware_acceleration_fail_in_chrome_on_linux/
[2] https://developers.google.com/web/updates/2017/04/headless-chrome
[3] https://bugs.chromium.org/p/chromium/issues/detail?id=737678
[4] https://groups.google.com/a/chromium.org/g/telemetry/c/bEgV1EH63eA
[5] https://bugs.chromium.org/p/chromium/issues/detail?id=617551
--disable-software-rasterizer
对我有帮助,感谢详细的回答。 - Mache我在使用selenium和chromedriver时遇到了同样的问题。对我来说,解决方案是在Chrome浏览器中激活WebGL。我按照以下步骤进行操作:
chrome://settings
-> 在底部点击高级设置
-> 选中启用硬件加速
这里有更好的说明:https://superuser.com/questions/836832/how-can-i-enable-webgl-in-my-browser
在我使用Xvfb运行chromium的设置中,出现了这个警告。我通过在命令行中添加以下标志来解决此警告:
--disable-features=DefaultPassthroughCommandDecoder
我在启动 Eclipse 时遇到了这个错误,并通过以下两步骤进行修复:
添加 Eclipse 启动参数:
-vm C:\PROGRA~1\ECLIPS~1\jdk-11.0.12.7-hotspot\bin\javaw.exe
你的代码中可能有拼写错误,请检查一下,
[7608:1220/032708.152:ERROR:gpu_init.cc(523)] Passthrough is not supported, GL is disabled, ANGLE is
问题是类型错误
之前的代码:
错误的代码
// events funstions of electron
SM_app.on('redy', F_create_windows);
fixed code
// events funstions of electron
SM_app.on('ready', F_create_windows);
我的代码中缺少了a
。 redy
headless
选项是问题的原因[1, 2]。 - J. Choi