Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REGRESSION(2.41.6): [GTK] Yelp help viewer and Epiphany browser do not show content on a virtual machine (llvmpipe?) with WebKitGTK 2.41.6 #15929

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/WebKit/Shared/WebProcessCreationParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#endif

#if PLATFORM(GTK)
#include "DMABufRendererBufferMode.h"
#include "GtkSettingsState.h"
#endif

Expand Down Expand Up @@ -219,7 +220,7 @@ struct WebProcessCreationParameters {
#endif

#if PLATFORM(GTK)
bool useDMABufSurfaceForCompositing { false };
OptionSet<DMABufRendererBufferMode> dmaBufRendererBufferMode;
bool useSystemAppearanceForScrollbars { false };
GtkSettingsState gtkSettings;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ struct WebKit::WebProcessCreationParameters {
#endif

#if PLATFORM(GTK)
bool useDMABufSurfaceForCompositing;
OptionSet<WebKit::DMABufRendererBufferMode> dmaBufRendererBufferMode;
bool useSystemAppearanceForScrollbars;
WebKit::GtkSettingsState gtkSettings;
#endif
Expand Down
49 changes: 49 additions & 0 deletions Source/WebKit/Shared/glib/DMABufRendererBufferMode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2023 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include <wtf/EnumTraits.h>

namespace WebKit {

enum class DMABufRendererBufferMode : uint8_t {
Hardware = 1 << 0,
SharedMemory = 1 << 1
};

} // namespace WebKit

namespace WTF {

template<> struct EnumTraits<WebKit::DMABufRendererBufferMode> {
using values = EnumValues<
WebKit::DMABufRendererBufferMode,
WebKit::DMABufRendererBufferMode::Hardware,
WebKit::DMABufRendererBufferMode::SharedMemory
>;
};

} // namespace WTF
23 changes: 21 additions & 2 deletions Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

#if PLATFORM(GTK)
#include "AcceleratedBackingStoreDMABuf.h"
#include "DMABufRendererBufferMode.h"
#include <WebCore/PlatformDisplaySurfaceless.h>
#include <gtk/gtk.h>

Expand Down Expand Up @@ -158,6 +159,24 @@ static const char* openGLAPI()
return "OpenGL ES 2 (libepoxy)";
}

#if PLATFORM(GTK)
static String dmabufRendererWithSupportedBuffers()
{
StringBuilder buffers;
buffers.append("DMABuf (Supported buffers: "_s);
auto mode = AcceleratedBackingStoreDMABuf::rendererBufferMode();
if (mode.contains(DMABufRendererBufferMode::Hardware))
buffers.append("Hardware"_s);
if (mode.contains(DMABufRendererBufferMode::SharedMemory)) {
if (mode.contains(DMABufRendererBufferMode::Hardware))
buffers.append(", ");
buffers.append("Shared Memory"_s);
}
buffers.append(')');
return buffers.toString();
}
#endif

void WebKitProtocolHandler::handleGPU(WebKitURISchemeRequest* request)
{
GString* html = g_string_new(
Expand Down Expand Up @@ -324,11 +343,11 @@ void WebKitProtocolHandler::handleGPU(WebKitURISchemeRequest* request)
addTableRow(jsonObject, "API"_s, String::fromUTF8(openGLAPI()));
#if PLATFORM(WAYLAND)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
addTableRow(hardwareAccelerationObject, "Renderer"_s, usingDMABufRenderer ? "DMABuf"_s : "WPE"_s);
addTableRow(hardwareAccelerationObject, "Renderer"_s, usingDMABufRenderer ? dmabufRendererWithSupportedBuffers() : "WPE"_s);
#endif
#if PLATFORM(X11)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11)
addTableRow(hardwareAccelerationObject, "Renderer"_s, usingDMABufRenderer ? "DMABuf"_s : "XWindow"_s);
addTableRow(hardwareAccelerationObject, "Renderer"_s, usingDMABufRenderer ? dmabufRendererWithSupportedBuffers() : "XWindow"_s);
#endif
addTableRow(hardwareAccelerationObject, "Native interface"_s, uiProcessContextIsEGL() ? "EGL"_s : "None"_s);

Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ void WebProcessPool::platformInitializeWebProcess(const WebProcessProxy& process
#endif

#if PLATFORM(GTK)
parameters.useDMABufSurfaceForCompositing = AcceleratedBackingStoreDMABuf::checkRequirements();
parameters.dmaBufRendererBufferMode = AcceleratedBackingStoreDMABuf::rendererBufferMode();
#endif

#if PLATFORM(WAYLAND)
if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::Wayland && !parameters.useDMABufSurfaceForCompositing) {
if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::Wayland && parameters.dmaBufRendererBufferMode.isEmpty()) {
wpe_loader_init("libWPEBackend-fdo-1.0.so.1");
if (AcceleratedBackingStoreWayland::checkRequirements()) {
parameters.hostClientFileDescriptor = UnixFileDescriptor { wpe_renderer_host_create_client(), UnixFileDescriptor::Adopt };
Expand Down
26 changes: 18 additions & 8 deletions Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "AcceleratedBackingStoreDMABufMessages.h"
#include "AcceleratedSurfaceDMABufMessages.h"
#include "DMABufRendererBufferMode.h"
#include "LayerTreeContext.h"
#include "ShareableBitmap.h"
#include "WebPageProxy.h"
Expand All @@ -49,23 +50,32 @@

namespace WebKit {

bool AcceleratedBackingStoreDMABuf::checkRequirements()
OptionSet<DMABufRendererBufferMode> AcceleratedBackingStoreDMABuf::rendererBufferMode()
{
static bool available;
static OptionSet<DMABufRendererBufferMode> mode;
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
const char* disableDMABuf = getenv("WEBKIT_DISABLE_DMABUF_RENDERER");
if (disableDMABuf && strcmp(disableDMABuf, "0")) {
available = false;
if (disableDMABuf && strcmp(disableDMABuf, "0"))
return;

const char* platformExtensions = eglQueryString(nullptr, EGL_EXTENSIONS);
if (!WebCore::GLContext::isExtensionSupported(platformExtensions, "EGL_KHR_platform_gbm")
&& !WebCore::GLContext::isExtensionSupported(platformExtensions, "EGL_MESA_platform_surfaceless")) {
return;
}

mode.add(DMABufRendererBufferMode::SharedMemory);

const auto& eglExtensions = WebCore::PlatformDisplay::sharedDisplay().eglExtensions();
available = eglExtensions.KHR_image_base
&& eglExtensions.KHR_surfaceless_context
&& WebCore::GLContext::isExtensionSupported(eglQueryString(nullptr, EGL_EXTENSIONS), "EGL_MESA_platform_surfaceless");
if (eglExtensions.KHR_image_base && eglExtensions.EXT_image_dma_buf_import)
mode.add(DMABufRendererBufferMode::Hardware);
});
return available;
return mode;
}
bool AcceleratedBackingStoreDMABuf::checkRequirements()
{
return !rendererBufferMode().isEmpty();
}

std::unique_ptr<AcceleratedBackingStoreDMABuf> AcceleratedBackingStoreDMABuf::create(WebPageProxy& webPage)
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <WebCore/RefPtrCairo.h>
#include <gtk/gtk.h>
#include <wtf/CompletionHandler.h>
#include <wtf/OptionSet.h>
#include <wtf/glib/GRefPtr.h>
#include <wtf/unix/UnixFileDescriptor.h>

Expand All @@ -54,10 +55,12 @@ namespace WebKit {
class ShareableBitmap;
class ShareableBitmapHandle;
class WebPageProxy;
enum class DMABufRendererBufferMode : uint8_t;

class AcceleratedBackingStoreDMABuf final : public AcceleratedBackingStore, public IPC::MessageReceiver {
WTF_MAKE_NONCOPYABLE(AcceleratedBackingStoreDMABuf); WTF_MAKE_FAST_ALLOCATED;
public:
static OptionSet<DMABufRendererBufferMode> rendererBufferMode();
static bool checkRequirements();
static std::unique_ptr<AcceleratedBackingStoreDMABuf> create(WebPageProxy&);
~AcceleratedBackingStoreDMABuf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void AcceleratedSurfaceDMABuf::clientResize(const WebCore::IntSize& size)
auto& display = WebCore::PlatformDisplay::sharedDisplayForCompositing();
switch (display.type()) {
case WebCore::PlatformDisplay::Type::Surfaceless:
if (display.eglExtensions().MESA_image_dma_buf_export)
if (display.eglExtensions().MESA_image_dma_buf_export && WebProcess::singleton().dmaBufRendererBufferMode().contains(DMABufRendererBufferMode::Hardware))
m_target = RenderTargetTexture::create(m_id, size);
else
m_target = RenderTargetSHMImage::create(m_id, size);
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit/WebProcess/WebProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ class WebProcess : public AuxiliaryProcess
void revokeLaunchServicesSandboxExtension();
#endif

#if PLATFORM(GTK)
const OptionSet<DMABufRendererBufferMode>& dmaBufRendererBufferMode() const { return m_dmaBufRendererBufferMode; }
#endif

private:
WebProcess();
~WebProcess();
Expand Down Expand Up @@ -739,8 +743,9 @@ class WebProcess : public AuxiliaryProcess

WeakHashMap<WebCore::UserGestureToken, uint64_t> m_userGestureTokens;

#if PLATFORM(GTK) && USE(EGL)
#if PLATFORM(GTK)
std::unique_ptr<WebCore::PlatformDisplay> m_displayForCompositing;
OptionSet<DMABufRendererBufferMode> m_dmaBufRendererBufferMode;
#endif

bool m_hasSuspendedPageProxy { false };
Expand Down
15 changes: 9 additions & 6 deletions Source/WebKit/WebProcess/glib/WebProcessGLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& para
#endif

#if PLATFORM(GTK)
if (parameters.useDMABufSurfaceForCompositing) {
m_dmaBufRendererBufferMode = parameters.dmaBufRendererBufferMode;
if (!m_dmaBufRendererBufferMode.isEmpty()) {
#if USE(GBM)
const char* disableGBM = getenv("WEBKIT_DMABUF_RENDERER_DISABLE_GBM");
if (!disableGBM || !strcmp(disableGBM, "0")) {
if (auto* device = WebCore::GBMDevice::singleton().device())
m_displayForCompositing = WebCore::PlatformDisplayGBM::create(device);
if (m_dmaBufRendererBufferMode.contains(DMABufRendererBufferMode::Hardware)) {
const char* disableGBM = getenv("WEBKIT_DMABUF_RENDERER_DISABLE_GBM");
if (!disableGBM || !strcmp(disableGBM, "0")) {
if (auto* device = WebCore::GBMDevice::singleton().device())
m_displayForCompositing = WebCore::PlatformDisplayGBM::create(device);
}
}
#endif
if (!m_displayForCompositing)
Expand All @@ -156,7 +159,7 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& para
#endif

#if PLATFORM(WAYLAND)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland && !parameters.isServiceWorkerProcess && !parameters.useDMABufSurfaceForCompositing) {
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland && !parameters.isServiceWorkerProcess && m_dmaBufRendererBufferMode.isEmpty()) {
auto hostClientFileDescriptor = parameters.hostClientFileDescriptor.release();
if (hostClientFileDescriptor != -1) {
wpe_loader_init(parameters.implementationLibraryName.data());
Expand Down