是否有可能使 chromium 在选项卡崩溃时立即重新加载?

发布于 2025-01-15 17:27:44 字数 1092 浏览 4 评论 0原文

我们在嵌入式系统上运行 chromium 83,并遇到了一些随机选项卡崩溃的情况。

如果崩溃的话,是否可以直接重新加载 chromium 中的选项卡(不显示“噢,快照!”页面)?

我们目前正在尝试修补源代码以使其正常工作,这些是迄今为止我们的方法。

(均在 Sad_tab_helper.cc -> SadTabHelper::RenderProcessGone() 中 方法一:

if (SadTab::ShouldShow(status)) {
  web_contents()->GetController().Reload(content::ReloadType::NORMAL, true);      
}

方法二:

if (SadTab::ShouldShow(status)) {
  content::RunOrPostTaskOnThread(
    FROM_HERE, 
    content::BrowserThread::ID::UI,
    base::BindOnce(
        [](content::WebContents* contents) {
          contents->GetController().Reload(content::ReloadType::NORMAL, true);
        },
        std::move(web_contents())));
}

这两种改变最终都会导致整个浏览器崩溃。

铬似乎尝试重新加载页面,但正如所说,然后它崩溃了。我们得到的日志是:

[1663:1671:0321/090914.211931:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://127.0.0.1/login

[1663:1671:0321/090919.082378:ERROR:broker_posix.cc(40)] Recvmsg error: Connection reset by peer (104)

之后整个浏览器崩溃了。有没有办法做我们想做的事,或者我们陷入了死胡同?

We are running chromium 83 on an embedded system and experience some random tab crashes.

Is it possible to directly reload a tab in chromium, if it crashes (without showing the "Aw snap!" page)?

We're currently trying to patch the source code to get it working and those were our approaches so far.

(both in sad_tab_helper.cc -> SadTabHelper::RenderProcessGone()
Approach 1:

if (SadTab::ShouldShow(status)) {
  web_contents()->GetController().Reload(content::ReloadType::NORMAL, true);      
}

Approach 2:

if (SadTab::ShouldShow(status)) {
  content::RunOrPostTaskOnThread(
    FROM_HERE, 
    content::BrowserThread::ID::UI,
    base::BindOnce(
        [](content::WebContents* contents) {
          contents->GetController().Reload(content::ReloadType::NORMAL, true);
        },
        std::move(web_contents())));
}

Both changes finally lead to crash of the entire browser.

It seems that chromium tries to reload the page but as said, it then crashes. The log we get are:

[1663:1671:0321/090914.211931:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://127.0.0.1/login

[1663:1671:0321/090919.082378:ERROR:broker_posix.cc(40)] Recvmsg error: Connection reset by peer (104)

After that the entire browser crashes. Is there a way to do what we want or are we on a dead end here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

闻呓 2025-01-22 17:27:44

第二种方法不是最理想的,SadTabHelper::RenderProcessGone 仅在 UI 上运行。

必须避免在处理来自任何 WebContentsObserverSadTabHelperWebContentsObserver)的通知时启动导航。它会导致问题。这两种方法都试图做到这一点。我想使用 base::PostTask 而不是 content::RunOrPostTaskOnThread 应该有所帮助。

if (SadTab::ShouldShow(status)) {
  base::PostTask(
    FROM_HERE, 
    {content::BrowserThread::UI},
    base::BindOnce(
        [](content::WebContents* contents) {
          contents->GetController().Reload(content::ReloadType::NORMAL, true);
        },
        web_contents()));
}

The second approach is suboptimal, SadTabHelper::RenderProcessGone only runs on UI.

Initiating navigation while handling notifications from any WebContentsObserver (SadTabHelper is a WebContentsObserver) must be avoided. It leads to problems. The both approaches attempt to do this. I suppose using base::PostTask instead of content::RunOrPostTaskOnThread should help.

if (SadTab::ShouldShow(status)) {
  base::PostTask(
    FROM_HERE, 
    {content::BrowserThread::UI},
    base::BindOnce(
        [](content::WebContents* contents) {
          contents->GetController().Reload(content::ReloadType::NORMAL, true);
        },
        web_contents()));
}
情魔剑神 2025-01-22 17:27:44

我的声誉不足以发表评论,因此我无法将此评论保留在应有的位置。

如果您遇到此特定解决方案,则所需的内容包括:

#include "base/task_scheduler/post_task.h"
#include "content/public/browser/browser_thread.h"
#include "base/bind.h"

My reputation is not good enough to comment so I can't leave this comment where it should be.

If you come across this particular solution, the required includes are:

#include "base/task_scheduler/post_task.h"
#include "content/public/browser/browser_thread.h"
#include "base/bind.h"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文