Bug 1821256 [Linux] Don't throttle webrender transactions on unmapped windows r=emilio

Based on patch by Emilio Cobos Álvarez (D172786)

Differential Revision: https://phabricator.services.mozilla.com/D173846
This commit is contained in:
stransky 2023-04-05 08:26:30 +00:00
parent 169e55791f
commit b10d18f470
4 changed files with 21 additions and 5 deletions

View File

@ -257,8 +257,9 @@ bool WebRenderLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags) {
// Since we don't do repeat transactions right now, just set the time
mAnimationReadyTime = TimeStamp::Now();
mLatestTransactionId =
mTransactionIdAllocator->GetTransactionId(/*aThrottle*/ true);
// Don't block on hidden windows on Linux as it may block all rendering.
const bool throttle = mWidget->IsMapped();
mLatestTransactionId = mTransactionIdAllocator->GetTransactionId(throttle);
if (aFlags & EndTransactionFlags::END_NO_COMPOSITE &&
!mWebRenderCommandBuilder.NeedsEmptyTransaction()) {
@ -406,8 +407,9 @@ void WebRenderLayerManager::EndTransactionWithoutLayer(
nsLayoutUtils::NotifyPaintSkipTransaction(update);
}
mLatestTransactionId =
mTransactionIdAllocator->GetTransactionId(/*aThrottle*/ true);
// Don't block on hidden windows on Linux as it may block all rendering.
const bool throttle = mWidget->IsMapped();
mLatestTransactionId = mTransactionIdAllocator->GetTransactionId(throttle);
// Get the time of when the refresh driver start its tick (if available),
// otherwise use the time of when LayerManager::BeginTransaction was called.

View File

@ -809,6 +809,12 @@ void nsWindow::SetModal(bool aModal) {
// nsIWidget method, which means IsShown.
bool nsWindow::IsVisible() const { return mIsShown; }
bool nsWindow::IsMapped() const {
// TODO: Enable for X11 when Mozilla testsuite is moved to new
// testing environment from Ubuntu 18.04 which is broken.
return GdkIsWaylandDisplay() ? mIsMapped : true;
}
void nsWindow::RegisterTouchWindow() {
mHandleTouchEvent = true;
mTouches.Clear();

View File

@ -155,6 +155,7 @@ class nsWindow final : public nsBaseWidget {
void SetParent(nsIWidget* aNewParent) override;
void SetModal(bool aModal) override;
bool IsVisible() const override;
bool IsMapped() const override;
void ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) override;
void SetSizeConstraints(const SizeConstraints& aConstraints) override;
void LockAspectRatio(bool aShouldLock) override;
@ -281,7 +282,6 @@ class nsWindow final : public nsBaseWidget {
nsIFrame* GetFrame() const;
nsWindow* GetEffectiveParent();
bool IsDestroyed() const { return mIsDestroyed; }
bool IsMapped() const { return mIsMapped; }
bool IsPopup() const;
bool IsWaylandPopup() const;
bool IsPIPWindow() const { return mIsPIPWindow; };

View File

@ -687,6 +687,14 @@ class nsIWidget : public nsISupports {
*/
virtual bool IsVisible() const = 0;
/**
* Returns whether the window has allocated resources so
* we can paint into it.
* Recently it's used on Linux/Gtk where we should not paint
* to invisible window.
*/
virtual bool IsMapped() const { return true; }
/**
* Perform platform-dependent sanity check on a potential window position.
* This is guaranteed to work only for top-level windows.