Browse Source

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
Birunthan Mohanathas 5 years ago
parent
commit
5c0319e00e
1 changed files with 7 additions and 0 deletions
  1. 7 0
      atom/browser/api/atom_api_web_contents.cc

+ 7 - 0
atom/browser/api/atom_api_web_contents.cc

@@ -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);
   }