From 69abcdc1037dad748f7a51e9287265095bdeb119 Mon Sep 17 00:00:00 2001 From: Jaroslaw Bojko Date: Wed, 26 Oct 2022 13:53:40 +0200 Subject: [PATCH] [ARRISEOS-41099] Repaint page after receiving wpe_compositor_refresh_event The entire page should be repainted after receiving wpe_compositor_refresh_event. This will make webbrowser repond to visibility change from awc_cli. Event flow: We receive an information about handle_configure method execution in wpe-backend-rdk. Thanks to this execution we know that the compositor change state and we need to repaint the app. As we get this info in network process thread we send it to the UI thread in wpe-backend-rdk via Wayland::EventDispatcher::singleton().sendEvent(). The wpe-browser is attached to EventDispatcher so by IPC we get this info in WPEView.cpp in wpe-webkit, wpe_view_backend_input_client callback. This event is received in UI thread while WebPage is working on network process thread. We send the event to the webpage by: page.repaintAfterCompositorReconfigure(); When we receive event on the proper thread, process and proper class we force the app to be repainted. To this we execute: m_drawingArea->forceRepaint(true); --- .../threadedcompositor/ThreadedCompositor.cpp | 10 +++++++++- .../threadedcompositor/ThreadedCompositor.h | 2 +- Source/WebKit/UIProcess/API/wpe/WPEView.cpp | 7 ++++++- Source/WebKit/UIProcess/WebPageProxy.cpp | 8 ++++++++ Source/WebKit/UIProcess/WebPageProxy.h | 2 ++ .../WebProcess/WebPage/AcceleratedDrawingArea.cpp | 4 ++-- .../WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h | 2 +- .../CoordinatedGraphics/CoordinatedLayerTreeHost.cpp | 2 +- .../CoordinatedGraphics/CoordinatedLayerTreeHost.h | 2 +- .../ThreadedCoordinatedLayerTreeHost.cpp | 4 ++-- .../ThreadedCoordinatedLayerTreeHost.h | 2 +- Source/WebKit/WebProcess/WebPage/DrawingArea.h | 2 +- Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp | 4 ++-- Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.h | 2 +- Source/WebKit/WebProcess/WebPage/LayerTreeHost.h | 2 +- Source/WebKit/WebProcess/WebPage/WebPage.cpp | 5 +++++ Source/WebKit/WebProcess/WebPage/WebPage.h | 1 + Source/WebKit/WebProcess/WebPage/WebPage.messages.in | 1 + 18 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp index 4b39bba48852a..04532694b766a 100644 --- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp +++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp @@ -220,8 +220,9 @@ void ThreadedCompositor::updateViewport() m_compositingRunLoop->scheduleUpdate(); } -void ThreadedCompositor::forceRepaint() +void ThreadedCompositor::forceRepaint(bool afterCompositorReconfigure) { + if(!afterCompositorReconfigure) { // FIXME: Enable this for WPE once it's possible to do these forced updates // in a way that doesn't starve out the underlying graphics buffers. #if PLATFORM(GTK) @@ -230,6 +231,13 @@ void ThreadedCompositor::forceRepaint() renderLayerTree(); }); #endif + } else { + m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] { + SetForScope change(m_inForceRepaint, true); + renderLayerTree(); + }); + m_compositingRunLoop->scheduleUpdate(); + } } void ThreadedCompositor::renderNonCompositedWebGL() diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h index 013e8230b40d5..ed614ad3e35e9 100644 --- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h +++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h @@ -76,7 +76,7 @@ class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadS void invalidate(); - void forceRepaint(); + void forceRepaint(bool afterCompositorReconfigure = false); #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) RefPtr displayRefreshMonitor(WebCore::PlatformDisplayID); diff --git a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp index 2bcce034b381b..e34c99aac8afc 100644 --- a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp +++ b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp @@ -136,10 +136,15 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC page.handleTouchEvent(WebKit::NativeWebTouchEvent(event, page.deviceScaleFactor())); #endif }, + // handle_wpe_compositor_refresh + [](void* data) + { + auto& page = reinterpret_cast(data)->page(); + page.repaintAfterCompositorReconfigure(); + }, // padding nullptr, nullptr, - nullptr, nullptr }; wpe_view_backend_set_input_client(m_backend, &s_inputClient, this); diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp index facfa24eb4d4e..6240c369a4151 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit/UIProcess/WebPageProxy.cpp @@ -4354,6 +4354,14 @@ void WebPageProxy::didExitFullscreen() m_uiClient->didExitFullscreen(this); } +void WebPageProxy::repaintAfterCompositorReconfigure() +{ + if (!isValid()) + return; + + m_process->send(Messages::WebPage::repaintAfterCompositorReconfigure(), m_pageID); +} + void WebPageProxy::closePage(bool stopResponsivenessTimer) { if (stopResponsivenessTimer) diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h index d35ca5b9a26f4..fb679b0a8165a 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.h +++ b/Source/WebKit/UIProcess/WebPageProxy.h @@ -381,6 +381,8 @@ class WebPageProxy : public API::ObjectImpl void didEnterFullscreen(); void didExitFullscreen(); + void repaintAfterCompositorReconfigure(); + WebInspectorProxy* inspector() const; void didChangeInspectorFrontendCount(unsigned count) { m_inspectorFrontendCount = count; } diff --git a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp index bacdca259415b..a212536e3ad69 100644 --- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp +++ b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp @@ -126,7 +126,7 @@ void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen) exitAcceleratedCompositingModeSoon(); } -void AcceleratedDrawingArea::forceRepaint() +void AcceleratedDrawingArea::forceRepaint(bool afterCompositorReconfigure) { setNeedsDisplay(); @@ -139,7 +139,7 @@ void AcceleratedDrawingArea::forceRepaint() // but clearly it doesn't make sense to call the function with that name. // Consider refactoring and renaming it. if (m_compositingAccordingToProxyMessages) - m_layerTreeHost->forceRepaint(); + m_layerTreeHost->forceRepaint(afterCompositorReconfigure); else { // Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to // prevent layerHostDidFlushLayers() from being called a second time. diff --git a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h index d8b0334154a8c..6cb3a577ac59d 100644 --- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h +++ b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h @@ -48,7 +48,7 @@ class AcceleratedDrawingArea : public DrawingArea { void setLayerTreeStateIsFrozen(bool) override; bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; } LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); } - void forceRepaint() override; + void forceRepaint(bool afterCompositorReconfigure = false) override; bool forceRepaintAsync(CallbackID) override; void setPaintingEnabled(bool) override; diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp index 8164794b48fa6..213164d716ca0 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp @@ -114,7 +114,7 @@ void CoordinatedLayerTreeHost::resumeRendering() LayerTreeHost::resumeRendering(); } -void CoordinatedLayerTreeHost::forceRepaint() +void CoordinatedLayerTreeHost::forceRepaint(bool afterCompositorReconfigure) { // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h index 816ff155b4555..ca951c8fb159a 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h @@ -53,7 +53,7 @@ class CoordinatedLayerTreeHost : public LayerTreeHost, public CompositingCoordin void pauseRendering() override; void resumeRendering() override; - void forceRepaint() override; + void forceRepaint(bool afterCompositorReconfigure = false) override; bool forceRepaintAsync(CallbackID) override; void sizeDidChange(const WebCore::IntSize& newSize) override; diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp index 297cec05822c5..cdf2f8b6b7611 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp @@ -94,10 +94,10 @@ void ThreadedCoordinatedLayerTreeHost::invalidate() m_surface = nullptr; } -void ThreadedCoordinatedLayerTreeHost::forceRepaint() +void ThreadedCoordinatedLayerTreeHost::forceRepaint(bool afterCompositorReconfigure) { CoordinatedLayerTreeHost::forceRepaint(); - m_compositor->forceRepaint(); + m_compositor->forceRepaint(afterCompositorReconfigure); } void ThreadedCoordinatedLayerTreeHost::pauseRendering() diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h index 66b09e22fffc8..ce3f40f0d110c 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h @@ -65,7 +65,7 @@ class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost, void invalidate() override; - void forceRepaint() override; + void forceRepaint(bool afterCompositorReconfigure = false) override; void pauseRendering() override; void resumeRendering() override; diff --git a/Source/WebKit/WebProcess/WebPage/DrawingArea.h b/Source/WebKit/WebProcess/WebPage/DrawingArea.h index b9c532ac5dc30..48ec50f7ba9b8 100644 --- a/Source/WebKit/WebProcess/WebPage/DrawingArea.h +++ b/Source/WebKit/WebProcess/WebPage/DrawingArea.h @@ -80,7 +80,7 @@ class DrawingArea : public IPC::MessageReceiver { // FIXME: These should be pure virtual. virtual void pageBackgroundTransparencyChanged() { } - virtual void forceRepaint() { } + virtual void forceRepaint(bool afterCompositorReconfigure = false) { } virtual bool forceRepaintAsync(CallbackID) { return false; } virtual void setLayerTreeStateIsFrozen(bool) { } virtual bool layerTreeStateIsFrozen() const { return false; } diff --git a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp index cbe1c58853bed..83460e7bdc81c 100644 --- a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -148,7 +148,7 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDel m_scrollOffset += scrollDelta; } -void DrawingAreaImpl::forceRepaint() +void DrawingAreaImpl::forceRepaint(bool afterCompositorReconfigure) { if (m_inUpdateBackingStoreState) { m_forceRepaintAfterBackingStoreStateUpdate = true; @@ -157,7 +157,7 @@ void DrawingAreaImpl::forceRepaint() m_forceRepaintAfterBackingStoreStateUpdate = false; if (m_layerTreeHost) { - AcceleratedDrawingArea::forceRepaint(); + AcceleratedDrawingArea::forceRepaint(afterCompositorReconfigure); return; } diff --git a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.h index 57c291494da27..ac44d45b052ab 100644 --- a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.h @@ -47,7 +47,7 @@ class DrawingAreaImpl final : public AcceleratedDrawingArea { void setNeedsDisplay() override; void setNeedsDisplayInRect(const WebCore::IntRect&) override; void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override; - void forceRepaint() override; + void forceRepaint(bool afterCompositorReconfigure = false) override; void updatePreferences(const WebPreferencesStore&) override; diff --git a/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h index 111b5b5b87581..fe075f8556c36 100644 --- a/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h +++ b/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h @@ -71,7 +71,7 @@ class LayerTreeHost : public RefCounted { virtual void setNonCompositedContentsNeedDisplay() { }; virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) { }; virtual void scrollNonCompositedContents(const WebCore::IntRect&) { }; - virtual void forceRepaint() = 0; + virtual void forceRepaint(bool afterCompositorReconfigure = false) = 0; virtual bool forceRepaintAsync(CallbackID) { return false; } virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0; virtual void pageBackgroundTransparencyChanged() = 0; diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp index 4f49b8165fdf4..667b0d55473e0 100644 --- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp @@ -3148,6 +3148,11 @@ void WebPage::forceRepaintWithoutCallback() m_drawingArea->forceRepaint(); } +void WebPage::repaintAfterCompositorReconfigure() +{ + m_drawingArea->forceRepaint(true); +} + void WebPage::forceRepaint(CallbackID callbackID) { if (m_drawingArea->forceRepaintAsync(callbackID)) diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h index bc79b70cd7028..f81d277408946 100644 --- a/Source/WebKit/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit/WebProcess/WebPage/WebPage.h @@ -865,6 +865,7 @@ class WebPage : public API::ObjectImpl, public IP float deviceScaleFactor() const; void forceRepaintWithoutCallback(); + void repaintAfterCompositorReconfigure(); void unmarkAllMisspellings(); void unmarkAllBadGrammar(); diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in index dd234f99c0f78..158de53667add 100644 --- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in @@ -23,6 +23,7 @@ messages -> WebPage LegacyReceiver { SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, WebKit::CallbackID callbackID) SetActivityState(OptionSet activityState, WebKit::ActivityStateChangeID activityStateChangeID, Vector callbackIDs) + repaintAfterCompositorReconfigure() SetLayerHostingMode(enum WebKit::LayerHostingMode layerHostingMode) SetDrawsBackground(bool drawsBackground)