fix: disable background throttling also in the viz::DisplayScheduler
(#38924)
* fix: disable background throttling also in the `viz::DisplayScheduler` `viz::DisplayScheduler` is responsible for drawing and swapping frames in the `DisplayScheduler::DrawAndSwap` which is called from the `DisplayScheduler::AttemptDrawAndSwap` if the `DisplayScheduler::ShouldDraw` returns true. `ShouldDraw` depends on the `DisplayScheduler` visibility and when it is not visible then it returns false. In order to keep producing frames, disabling `backgroundThrottling` should also prevent changing `DisplayScheduler` visibility to false. `DisplayScheduler` lives in the `ui::Compositor` where every `electron::NativewWindow` has its own `Compositor`. `electron::NativewWindow` may be host of the multiple `electron::api::WebContents` instances which may have different `WebPreferences` settings. Therefore if at least one of the `WebContents` requires disabling throttling then all other `WebContents` using the same window will have it disabled in the `ui::Compositor`. BREAKING CHANGE: `backgroundThrottling` set to false will disable frames throttling in the `BrowserWindow` for all `WebContents` displayed by it. Close: [#31016](https://github.com/electron/electron/issues/31016) * fixup! fix: disable background throttling also in the `viz::DisplayScheduler` * fixup! fix: disable background throttling also in the `viz::DisplayScheduler` * fixup! fix: disable background throttling also in the `viz::DisplayScheduler` --------- Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
fa215f1009
commit
2190793fe6
10 changed files with 176 additions and 3 deletions
|
@ -47,6 +47,7 @@ class PersistentDictionary;
|
|||
namespace electron {
|
||||
|
||||
class ElectronMenuModel;
|
||||
class BackgroundThrottlingSource;
|
||||
class NativeBrowserView;
|
||||
|
||||
namespace api {
|
||||
|
@ -401,6 +402,17 @@ class NativeWindow : public base::SupportsUserData,
|
|||
|
||||
bool IsTranslucent() const;
|
||||
|
||||
// Adds |source| to |background_throttling_sources_|, triggers update of
|
||||
// background throttling state.
|
||||
void AddBackgroundThrottlingSource(BackgroundThrottlingSource* source);
|
||||
// Removes |source| to |background_throttling_sources_|, triggers update of
|
||||
// background throttling state.
|
||||
void RemoveBackgroundThrottlingSource(BackgroundThrottlingSource* source);
|
||||
// Updates `ui::Compositor` background throttling state based on
|
||||
// |background_throttling_sources_|. If at least one of the sources disables
|
||||
// throttling, then throttling in the `ui::Compositor` will be disabled.
|
||||
void UpdateBackgroundThrottlingState();
|
||||
|
||||
protected:
|
||||
friend class api::BrowserView;
|
||||
|
||||
|
@ -495,6 +507,8 @@ class NativeWindow : public base::SupportsUserData,
|
|||
// Observers of this window.
|
||||
base::ObserverList<NativeWindowObserver> observers_;
|
||||
|
||||
std::set<BackgroundThrottlingSource*> background_throttling_sources_;
|
||||
|
||||
// Accessible title.
|
||||
std::u16string accessible_title_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue