Skip to content

Commit

Permalink
REGRESSION(263118@main): [GTK] Web inspector does not paint reliably
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259449

Reviewed by Michael Catanzaro.

This happens with the inspector because the inspector view doesn't
follow the hardware accelerated settings, and always runs in
non-accelerated compositing mode. This is actually a bug in
non-accelerated compositing mode implementation, it happens with any web
view when disabling hardware acceleration. The problem is that when the
view is no longer in the active window (it loses the focus) we discard
the backing store after 2 seconds and we don't notify the web process
nor ask for an update when a new paint is requested (when the web view
is redraw), as we did before 263118@main. After the resize
simplification we can simplify this part too, and just add a message to
request an update when the web view is redrawn after the backing store
has been discarded. I'm also increasing the delay to discard the backing
store, because with 2 seconds we usually end up creating a new one after
losing the focus due to the repaint requested by the overlay scrollbars
fade out animation. Using 10 seconds we ensure we always discard the
backing store after the scrollbar animation finished and no more repaints
are expected.

* Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
(WebKit::DrawingAreaProxyCoordinatedGraphics::paint):
(WebKit::DrawingAreaProxyCoordinatedGraphics::discardBackingStoreSoon):
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
(WebKit::DrawingAreaCoordinatedGraphics::forceUpdate):
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
* Source/WebKit/WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::forceUpdate):
* Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in:

Canonical link: https://commits.webkit.org/266511@main
  • Loading branch information
carlosgcampos committed Aug 2, 2023
1 parent 476e8fb commit 184eb79
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ void DrawingAreaProxyCoordinatedGraphics::paint(BackingStore::PlatformGraphicsCo
if (isInAcceleratedCompositingMode())
return;

if (!m_backingStore)
if (!m_backingStore) {
if (!m_isWaitingForDidUpdateGeometry)
m_webPageProxy.send(Messages::DrawingArea::ForceUpdate(), m_identifier);
return;
}

m_backingStore->paint(context, rect);
unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size()));
Expand Down Expand Up @@ -260,7 +263,7 @@ void DrawingAreaProxyCoordinatedGraphics::discardBackingStoreSoon()

// We'll wait this many seconds after the last paint before throwing away our backing store to save memory.
// FIXME: It would be smarter to make this delay based on how expensive painting is. See <http://webkit.org/b/55733>.
static const Seconds discardBackingStoreDelay = 2_s;
static const Seconds discardBackingStoreDelay = 10_s;

m_discardBackingStoreTimer.startOneShot(discardBackingStoreDelay);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,4 +815,13 @@ void DrawingAreaCoordinatedGraphics::display(UpdateInfo& updateInfo)
m_displayTimer.stop();
}

void DrawingAreaCoordinatedGraphics::forceUpdate()
{
if (m_isWaitingForDidUpdate || m_layerTreeHost)
return;

m_dirtyRegion = m_webPage.bounds();
display();
}

} // namespace WebKit
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class DrawingAreaCoordinatedGraphics final : public DrawingArea {
void targetRefreshRateDidChange(unsigned rate) override;
void displayDidRefresh() override;
void setDeviceScaleFactor(float) override;
void forceUpdate();

#if PLATFORM(GTK)
void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/WebProcess/WebPage/DrawingArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class DrawingArea : public IPC::MessageReceiver, public WebCore::DisplayRefreshM
const WebCore::IntSize& /*scrollOffset*/) { }
virtual void targetRefreshRateDidChange(unsigned /*rate*/) { }
virtual void setDeviceScaleFactor(float) { }
virtual void forceUpdate() { }
#endif
virtual void displayDidRefresh() { }

Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ messages -> DrawingArea NotRefCounted {
UpdateGeometry(WebCore::IntSize size) -> ()
TargetRefreshRateDidChange(unsigned rate)
SetDeviceScaleFactor(float deviceScaleFactor)
ForceUpdate()
#endif

DisplayDidRefresh()
Expand Down

0 comments on commit 184eb79

Please sign in to comment.