fix: Fix compositor recycling when creating new BrowserView (6-1-x) (#21396)

Backport of #21372. This also backports a tiny bit of #19988.

Notes: Fix flicker when switching between BrowserViews after creating new BrowserView
This commit is contained in:
Birunthan Mohanathas
2019-12-06 13:35:26 -06:00
committed by Samuel Attard
parent 9743d70131
commit 5c0319e00e

View File

@@ -330,6 +330,12 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
// Whether to enable DevTools.
options.Get("devTools", &enable_devtools_);
// BrowserViews are not attached to a window initially so they should start
// off as hidden. This is also important for compositor recycling. See:
// https://github.com/electron/electron/pull/21372
bool initially_shown = type_ != Type::BROWSER_VIEW;
options.Get(options::kShow, &initially_shown);
// Obtain the session.
std::string partition;
mate::Handle<api::Session> session;
@@ -382,6 +388,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
#endif
} else {
content::WebContents::CreateParams params(session->browser_context());
params.initially_hidden = !initially_shown;
web_contents = content::WebContents::Create(params);
}