ERROR:browser_process_sub_thread.cc(221)] Waited 57 ms for network service with Selenium ChromeDriver and Chrome on Windows

ERROR:browser_process_sub_thread.cc(221)] Waited 57 ms for network service with Selenium ChromeDriver and Chrome on Windows

所以我们在C#中使用Selenium来控制Chrome。在使用 v74 chromedriver 的 Chrome v74 和使用 v75 chromedriver 的 Chrome v75(测试版)中都发生了以下问题。

与网站进行大约 12 次交互后,我们收到错误消息,例如

[10084:5660:0601/111205.119:ERROR:browser_process_sub_thread.cc(221)] Waited 57 ms for network service

我们无法编辑 browser_process_sub_thread.cc 并重新编译。

我已就此问题寻求帮助,并且正在其他地方讨论。但是,由于 v75 beta 因同样的问题而中断,因此似乎没有发生什么。

我们如何解决这个问题?它只出现在这组测试中,而不出现在其他测试中。

稍后

现在我收到这种消息,即

ERROR:browser_process_sub_thread.cc(217)] Waited 285 ms for network service

立即而不是在一些交互之后!发生什么事了?

这个错误信息...

ERROR:browser_process_sub_thread.cc(217)] Waited 771 ms for network service

...来自 IOThreadCleanUp() method within the browser_process_sub_thread.cc 文件,实现为:

// Record time spent for the method call.
base::TimeDelta network_wait_time = base::TimeTicks::Now() - start_time;
UMA_HISTOGRAM_TIMES("NetworkService.ShutdownTime", network_wait_time);
LOG(ERROR) << "Waited " << network_wait_time.InMilliseconds()
           << " ms for network service";

根据 Chromium Servicification - Need better handling for when a core service process fails to start/initialize 中的讨论 new Network Process (NP) [--enable-features=NetworkService]如果生成子进程但服务启动失败,在这些情况下:

  • 浏览器 UI 保持可见并打开。
  • 由于该服务是可重启的,因此似乎在幕后发生了尝试重生子进程的无限循环,这会消耗更多的系统资源。
  • 由于严重故障,可见浏览器没有正确关闭,只是坐在那里,没有网络。

因此,Chrome 需要的所有 核心 服务都需要一个策略才能拥有 运行,可能是 [=42] 的失败路径=]网络进程 (NP).


根据上述要求,根据讨论 Sandbox the network service on Windows Chrome 引入了新的 沙盒(SANDBOX_NETWORK_TYPE ) 用于新的 网络进程 (NP).

Windows is the first platform to roll out of both the new features and you are one of the luckiest user to have the first hand user experience of:

  • 为网络服务启用的功能:NetworkService

    --enable-features=NetworkService
    
  • 网络服务启用的功能:NetworkServiceWindowsSandbox

    --enable-features=NetworkServiceWindowsSandbox
    

来自@WillHarris 的 revision and this commit with in sandbox_win.cc 着陆时将解决此问题。