Skip to content

fix: Fix compositor recycling when creating new BrowserView - #21372

Merged
MarshallOfSound merged 1 commit into
electron:masterfrom
poiru:fix-recycling
Dec 5, 2019
Merged

MarshallOfSound merged 1 commit into
electron:masterfrom
poiru:fix-recycling

Conversation

@poiru

@poiru poiru commented Dec 3, 2019 •

Copy link
Copy Markdown
Contributor

In #20829, we fixed compositor recycling when switching between
BrowserViews, but it turns out that there is one additional case that we
need to handle. When we create a completely new BrowserView instance, it
starts of as visible (even when it hasn't been added to the window),
which means that it will need its own compositor instead of using the
recycled compositor.

To fix this, lets make BrowserViews hidden by default until they're
added to the window. See also #19988. This is a potentially breaking
change given that the initial value of document.visibilityState will
now be hidden, but given the experimental status of BrowserViews, I
think this is a fine change to make. The old behavior can be restored
with webPreferences: { show: true }.

Notes: Fix flicker when switching between BrowserViews after creating new BrowserView

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Dec 3, 2019
@poiru

poiru commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

cc @MarshallOfSound @loc

@poiru

poiru commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

Note that this PR is strictly not necessary given that we can use the undocumented webPreferences: { show: false } option to achieve the same effect. We need that option in 6.x though. If you prefer to leave the default unchanged, we could also just backport the option itself to 6.x:

bool initially_shown = true;
options.Get(options::kShow, &initially_shown);

// ...

params.initially_hidden = !initially_shown;
web_contents = content::WebContents::Create(params);

In electron#20829, we fixed compositor recycling when switching between
BrowserViews, but it turns out that there is one additional case that we
need to handle. When we create a completely new BrowserView instance, it
starts of as visible (even when it hasn't been added to the window),
which means that it will need its own compositor instead of using the
recycled compositor.

To fix this, lets make BrowserViews hidden by default until they're
added to the window. See also electron#19988. This is a potentially breaking
change given that the initial value of `document.visibilityState` will
now be `hidden`, but given the experimental status of BrowserViews, I
think this is a fine change to make. The old behavior can be restored
with `webPreferences: { show: true }`.

Notes: Fix compositor recycling when creating new BrowserView
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Dec 4, 2019

@felixrieseberg felixrieseberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

poiru added a commit to poiru/electron that referenced this pull request Dec 5, 2019
Backport of electron#21372. This also backports a tiny bit of electron#19988.

Notes: Fix flicker when switching between BrowserViews after creating new BrowserView
@MarshallOfSound
MarshallOfSound merged commit 5223d1d into electron:master Dec 5, 2019
@release-clerk

release-clerk Bot commented Dec 5, 2019

Copy link
Copy Markdown

Release Notes Persisted

Fix flicker when switching between BrowserViews after creating new BrowserView

@trop

trop Bot commented Dec 5, 2019

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "6-1-x" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Dec 5, 2019

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "8-x-y", please check out #21399

@trop

trop Bot commented Dec 5, 2019

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "7-1-x", please check out #21400

@poiru
poiru deleted the fix-recycling branch December 5, 2019 19:12
@trop trop Bot removed the in-flight/7-1-x label Dec 5, 2019
@trop trop Bot added the merged/7-1-x label Dec 5, 2019
MarshallOfSound pushed a commit that referenced this pull request Dec 6, 2019
…21396)

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

Notes: Fix flicker when switching between BrowserViews after creating new BrowserView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants