Diff
Modified: trunk/Source/WebCore/ChangeLog (283754 => 283755)
--- trunk/Source/WebCore/ChangeLog 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebCore/ChangeLog 2021-10-07 23:30:56 UTC (rev 283755)
@@ -24,6 +24,33 @@
2021-10-07 Myles C. Maxfield <[email protected]>
+ [GPU Process] Unique RenderingResourceIdentifiers Part 1: Uniquify at entry points
+ https://bugs.webkit.org/show_bug.cgi?id=231281
+ <rdar://problem/83920780>
+
+ Reviewed by Chris Dumez.
+
+ ProcessQualified is the generic form of QualifiedRenderingResourceIdentifier. It's
+ templated, so it can hold things other than RenderingResourceIdentifiers.
+
+ No new tests because there is no behavior change.
+
+ * Headers.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/ProcessQualified.h: Added.
+ (WebCore::ProcessQualified::ProcessQualified):
+ (WebCore::ProcessQualified::object const):
+ (WebCore::ProcessQualified::processIdentifier const):
+ (WebCore::ProcessQualified::isHashTableDeletedValue const):
+ (WebCore::ProcessQualified::operator== const):
+ (WebCore::ProcessQualified::operator!= const):
+ (WebCore::operator<<):
+ (WebCore::add):
+ (WTF::DefaultHash<WebCore::ProcessQualified<T>>::hash):
+ (WTF::DefaultHash<WebCore::ProcessQualified<T>>::equal):
+
+2021-10-07 Myles C. Maxfield <[email protected]>
+
Stop parsing font palette things that we can't implement
https://bugs.webkit.org/show_bug.cgi?id=230799
<rdar://problem/83537772>
Modified: trunk/Source/WebCore/Headers.cmake (283754 => 283755)
--- trunk/Source/WebCore/Headers.cmake 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebCore/Headers.cmake 2021-10-07 23:30:56 UTC (rev 283755)
@@ -1135,6 +1135,7 @@
platform/PopupMenuClient.h
platform/PopupMenuStyle.h
platform/ProcessIdentifier.h
+ platform/ProcessQualified.h
platform/PromisedAttachmentInfo.h
platform/PublicSuffix.h
platform/RectEdges.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (283754 => 283755)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-07 23:30:56 UTC (rev 283755)
@@ -650,6 +650,7 @@
1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */; };
1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
1CAF56DB25301AC80017B472 /* DrawGlyphsRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF56D8253014570017B472 /* DrawGlyphsRecorder.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 1CC54AFE270F96AE005BF8BE /* ProcessQualified.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CC54AFB270F92DA005BF8BE /* ProcessQualified.h */; settings = {ATTRIBUTES = (Private, ); }; };
1CCD81502231F83E0065FC2B /* WebCoreResourceHandleAsOperationQueueDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E152551416FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm */; };
1CCDF5BE1990332400BCEBAD /* SVGToOTFFontConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CCDF5BC1990332400BCEBAD /* SVGToOTFFontConversion.h */; };
1CE8864126105BF2000C816C /* InMemoryDisplayList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE8863F26105A5F000C816C /* InMemoryDisplayList.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7047,6 +7048,7 @@
1CAF56DE2530245A0017B472 /* DrawGlyphsRecorderCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DrawGlyphsRecorderCoreText.cpp; sourceTree = "<group>"; };
1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextDecorationThickness.h; sourceTree = "<group>"; };
1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextUnderlineOffset.h; sourceTree = "<group>"; };
+ 1CC54AFB270F92DA005BF8BE /* ProcessQualified.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProcessQualified.h; sourceTree = "<group>"; };
1CCDF5BB1990332400BCEBAD /* SVGToOTFFontConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGToOTFFontConversion.cpp; sourceTree = "<group>"; };
1CCDF5BC1990332400BCEBAD /* SVGToOTFFontConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGToOTFFontConversion.h; sourceTree = "<group>"; };
1CDD45E40BA9C84600F90147 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
@@ -28243,6 +28245,7 @@
A1ADAF7C2360FD3E009CB776 /* PreviewConverterProvider.h */,
51F645D21FECDBC800B54DED /* ProcessIdentifier.cpp */,
51F645D31FECDBC800B54DED /* ProcessIdentifier.h */,
+ 1CC54AFB270F92DA005BF8BE /* ProcessQualified.h */,
F47A633C1FF6FD500081B3CC /* PromisedAttachmentInfo.h */,
0081FEFD16B0A244008AAA7A /* PublicSuffix.h */,
5C97A3361F5F7A6500105207 /* RectEdges.h */,
@@ -34697,6 +34700,7 @@
6B0A07F221FA4B5C00D57391 /* PrivateClickMeasurement.h in Headers */,
51F645D51FECDBCE00B54DED /* ProcessIdentifier.h in Headers */,
A8EA7EBC0A1945D000A8EF5F /* ProcessingInstruction.h in Headers */,
+ 1CC54AFE270F96AE005BF8BE /* ProcessQualified.h in Headers */,
E42050172141901B0066EF3B /* ProcessWarming.h in Headers */,
E44613EC0CD681B500FADA75 /* ProgressEvent.h in Headers */,
A715E653134BBBEC00D8E713 /* ProgressShadowElement.h in Headers */,
Added: trunk/Source/WebCore/platform/ProcessQualified.h (0 => 283755)
--- trunk/Source/WebCore/platform/ProcessQualified.h (rev 0)
+++ trunk/Source/WebCore/platform/ProcessQualified.h 2021-10-07 23:30:56 UTC (rev 283755)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * 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 "ProcessIdentifier.h"
+#include <wtf/Hasher.h>
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+template <typename T>
+class ProcessQualified {
+public:
+ // This class is used when a single process retains objects representing things in multiple other processes.
+ // (E.g. resources in the GPU process.)
+ // Generally, objects are identified uniquely per process, but if multiple processes share them to a single
+ // process, the single process should distinguish between them by augmenting the objects with the
+ // ProcessIdentifier of the process which created them.
+
+ ProcessQualified() = default;
+
+ ProcessQualified(T&& object, ProcessIdentifier processIdentifier)
+ : m_object(WTFMove(object))
+ , m_processIdentifier(processIdentifier)
+ {
+ }
+
+ ProcessQualified(const T& object, ProcessIdentifier processIdentifier)
+ : m_object(object)
+ , m_processIdentifier(processIdentifier)
+ {
+ }
+
+ ProcessQualified(WTF::HashTableDeletedValueType)
+ : m_processIdentifier(WTF::HashTableDeletedValue)
+ {
+ }
+
+ const T& object() const
+ {
+ return m_object;
+ }
+
+ ProcessIdentifier processIdentifier() const
+ {
+ return m_processIdentifier;
+ }
+
+ bool isHashTableDeletedValue() const
+ {
+ return m_processIdentifier.isHashTableDeletedValue();
+ }
+
+ bool operator==(const ProcessQualified& other) const
+ {
+ return m_object == other.m_object
+ && m_processIdentifier == other.m_processIdentifier;
+ }
+
+ bool operator!=(const ProcessQualified& other) const
+ {
+ return !(*this == other);
+ }
+
+private:
+ T m_object;
+ ProcessIdentifier m_processIdentifier;
+};
+
+template <typename T>
+inline TextStream& operator<<(TextStream& ts, const ProcessQualified<T>& processQualified)
+{
+ ts << "ProcessQualified(" << processQualified.object() << ", " << processQualified.processIdentifier() << ')';
+ return ts;
+}
+
+template <typename T>
+inline void add(Hasher& hasher, const ProcessQualified<T>& processQualified)
+{
+ add(hasher, processQualified.object());
+ add(hasher, processQualified.processIdentifier());
+}
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<typename T> struct DefaultHash;
+template<typename T> struct DefaultHash<WebCore::ProcessQualified<T>> {
+ static unsigned hash(const WebCore::ProcessQualified<T>& processQualified)
+ {
+ return computeHash(processQualified);
+ }
+
+ static bool equal(const WebCore::ProcessQualified<T>& a, const WebCore::ProcessQualified<T>& b)
+ {
+ return a == b;
+ }
+
+ static const bool safeToCompareToEmptyOrDeleted = DefaultHash<T>::safeToCompareToEmptyOrDeleted;
+};
+
+template<typename T> struct HashTraits<WebCore::ProcessQualified<T>> : SimpleClassHashTraits<WebCore::ProcessQualified<T>> {
+ static constexpr bool emptyValueIsZero = HashTraits<T>::emptyValueIsZero;
+};
+
+} // namespace WTF
Property changes on: trunk/Source/WebCore/platform/ProcessQualified.h
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Source/WebKit/ChangeLog (283754 => 283755)
--- trunk/Source/WebKit/ChangeLog 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebKit/ChangeLog 2021-10-07 23:30:56 UTC (rev 283755)
@@ -1,3 +1,66 @@
+2021-10-07 Myles C. Maxfield <[email protected]>
+
+ [GPU Process] Unique RenderingResourceIdentifiers Part 1: Uniquify at entry points
+ https://bugs.webkit.org/show_bug.cgi?id=231281
+ <rdar://problem/83920780>
+
+ Reviewed by Chris Dumez.
+
+ Each web process creates its own RenderingResourceIdentifiers. Because the GPU process
+ can service multiple web processes, these identifiers can collide in the GPU process.
+ This is somewhat error prone, and might cause us to make a mistake in the future and
+ introduce a bug which lets one web process see another web process's resources (which
+ would be mega bad).
+
+ The goal of this project is to treat RenderingResourceIdentifiers in the GPU process
+ as a tuple of (the identifer we got from the web process, the process identifier of
+ the web process). This way, the tuples uniquely identify a resource across the entire
+ GPU process. Doing it this way makes it less likely that we'll make a mega bad mistake
+ in the future.
+
+ This patch is the first step: It introduces the QualifiedRenderingResourceIdentifier
+ type, which holds the tuple described above, and makes all the GPU process message
+ receivers immediately turn any RenderingResourceIdentifiers they received from the
+ web processes into QualifiedRenderingResourceIdentifiers. Not only do the identifiers
+ immediately get packed, but each message receiver now has an implementation function
+ which only accepts the QualifiedRenderingResourceIdentifier, so we can't make a
+ mistake and use the unpacked one accidentally.
+
+ Because this patch is just the first step, the QualifiedRenderingResourceIdentifiers
+ get unpacked eagerly, and the inner logic of the GPU process is unaffected. The
+ subsequent two patches will push the QualifiedRenderingResourceIdentifiers deeper
+ into the guts of the GPU process, eventually to the point where
+ RenderingResourceIdentifiers are never used there.
+
+ * GPUProcess/graphics/QualifiedRenderingResourceIdentifier.h: Added.
+ * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+ (WebKit::RemoteGraphicsContextGL::RemoteGraphicsContextGL):
+ (WebKit::RemoteGraphicsContextGL::paintRenderingResultsToCanvas):
+ (WebKit::RemoteGraphicsContextGL::paintRenderingResultsToCanvasWithQualifiedIdentifier):
+ (WebKit::RemoteGraphicsContextGL::paintCompositedResultsToCanvas):
+ (WebKit::RemoteGraphicsContextGL::paintCompositedResultsToCanvasWithQualifiedIdentifier):
+ (WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer):
+ * GPUProcess/graphics/RemoteGraphicsContextGL.h:
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::createImageBuffer):
+ (WebKit::RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::getDataURLForImageBuffer):
+ (WebKit::RemoteRenderingBackend::getDataURLForImageBufferWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::getDataForImageBuffer):
+ (WebKit::RemoteRenderingBackend::getDataForImageBufferWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBuffer):
+ (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBufferWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::cacheNativeImage):
+ (WebKit::RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::cacheFont):
+ (WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::releaseRemoteResource):
+ (WebKit::RemoteRenderingBackend::releaseRemoteResourceWithQualifiedIdentifier):
+ (WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandle):
+ (WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandleWithQualifiedIdentifier):
+ * GPUProcess/graphics/RemoteRenderingBackend.h:
+ * WebKit.xcodeproj/project.pbxproj:
+
2021-10-07 Arcady Goldmints-Orlov <[email protected]>
[GTK][WPE] Disable privateClickMeasurement when creating the network process
Added: trunk/Source/WebKit/GPUProcess/graphics/QualifiedRenderingResourceIdentifier.h (0 => 283755)
--- trunk/Source/WebKit/GPUProcess/graphics/QualifiedRenderingResourceIdentifier.h (rev 0)
+++ trunk/Source/WebKit/GPUProcess/graphics/QualifiedRenderingResourceIdentifier.h 2021-10-07 23:30:56 UTC (rev 283755)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * 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
+
+#if ENABLE(GPU_PROCESS)
+
+#include <WebCore/ProcessQualified.h>
+#include <WebCore/RenderingResourceIdentifier.h>
+
+namespace WebKit {
+
+using QualifiedRenderingResourceIdentifier = WebCore::ProcessQualified<WebCore::RenderingResourceIdentifier>;
+
+}
+
+#endif
Property changes on: trunk/Source/WebKit/GPUProcess/graphics/QualifiedRenderingResourceIdentifier.h
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (283754 => 283755)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2021-10-07 23:30:56 UTC (rev 283755)
@@ -29,6 +29,7 @@
#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
#include "GPUConnectionToWebProcess.h"
+#include "QualifiedRenderingResourceIdentifier.h"
#include "RemoteGraphicsContextGLMessages.h"
#include "RemoteGraphicsContextGLProxyMessages.h"
#include "StreamConnectionWorkQueue.h"
@@ -68,6 +69,7 @@
, m_graphicsContextGLIdentifier(graphicsContextGLIdentifier)
, m_renderingBackend(renderingBackend)
, m_renderingResourcesRequest(ScopedWebGLRenderingResourcesRequest::acquire())
+ , m_webProcessIdentifier(gpuConnectionToWebProcess.webProcessIdentifier())
{
assertIsMainRunLoop();
}
@@ -197,6 +199,13 @@
void RemoteGraphicsContextGL::paintRenderingResultsToCanvas(WebCore::RenderingResourceIdentifier imageBuffer, CompletionHandler<void()>&& completionHandler)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ paintRenderingResultsToCanvasWithQualifiedIdentifier({ imageBuffer, m_webProcessIdentifier }, WTFMove(completionHandler));
+}
+
+void RemoteGraphicsContextGL::paintRenderingResultsToCanvasWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageBuffer, CompletionHandler<void()>&& completionHandler)
+{
assertIsCurrent(m_streamThread);
paintPixelBufferToImageBuffer(m_context->readRenderingResultsForPainting(), imageBuffer, WTFMove(completionHandler));
}
@@ -203,11 +212,18 @@
void RemoteGraphicsContextGL::paintCompositedResultsToCanvas(WebCore::RenderingResourceIdentifier imageBuffer, CompletionHandler<void()>&& completionHandler)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ paintCompositedResultsToCanvasWithQualifiedIdentifier({ imageBuffer, m_webProcessIdentifier }, WTFMove(completionHandler));
+}
+
+void RemoteGraphicsContextGL::paintCompositedResultsToCanvasWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageBuffer, CompletionHandler<void()>&& completionHandler)
+{
assertIsCurrent(m_streamThread);
paintPixelBufferToImageBuffer(m_context->readCompositedResultsForPainting(), imageBuffer, WTFMove(completionHandler));
}
-void RemoteGraphicsContextGL::paintPixelBufferToImageBuffer(std::optional<WebCore::PixelBuffer>&& pixelBuffer, WebCore::RenderingResourceIdentifier target, CompletionHandler<void()>&& completionHandler)
+void RemoteGraphicsContextGL::paintPixelBufferToImageBuffer(std::optional<WebCore::PixelBuffer>&& pixelBuffer, QualifiedRenderingResourceIdentifier target, CompletionHandler<void()>&& completionHandler)
{
assertIsCurrent(m_streamThread);
// FIXME: We do not have functioning read/write fences in RemoteRenderingBackend. Thus this is synchronous,
@@ -216,7 +232,7 @@
Condition conditionVariable;
bool isFinished = false;
m_renderingBackend->dispatch([&, contextAttributes = m_context->contextAttributes()]() mutable {
- if (auto imageBuffer = m_renderingBackend->remoteResourceCache().cachedImageBuffer(target)) {
+ if (auto imageBuffer = m_renderingBackend->remoteResourceCache().cachedImageBuffer(target.object())) {
// Here we do not try to play back pending commands for imageBuffer. Currently this call is only made for empty
// image buffers and there's no good way to add display lists.
if (pixelBuffer)
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h (283754 => 283755)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h 2021-10-07 23:30:56 UTC (rev 283755)
@@ -30,6 +30,7 @@
#include "Connection.h"
#include "GPUConnectionToWebProcess.h"
#include "GraphicsContextGLIdentifier.h"
+#include "QualifiedRenderingResourceIdentifier.h"
#include "RemoteRenderingBackend.h"
#include "ScopedWebGLRenderingResourcesRequest.h"
#include "StreamMessageReceiver.h"
@@ -105,8 +106,12 @@
#include "RemoteGraphicsContextGLFunctionsGenerated.h" // NOLINT
- void paintPixelBufferToImageBuffer(std::optional<WebCore::PixelBuffer>&&, WebCore::RenderingResourceIdentifier, CompletionHandler<void()>&&);
+private:
+ void paintRenderingResultsToCanvasWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier, CompletionHandler<void()>&&);
+ void paintCompositedResultsToCanvasWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier, CompletionHandler<void()>&&);
+ void paintPixelBufferToImageBuffer(std::optional<WebCore::PixelBuffer>&&, QualifiedRenderingResourceIdentifier, CompletionHandler<void()>&&);
+protected:
WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess;
RefPtr<IPC::StreamServerConnection> m_streamConnection;
RefPtr<WebCore::GraphicsContextGLOpenGL> m_context WTF_GUARDED_BY_LOCK(m_streamThread);
@@ -114,6 +119,7 @@
Ref<RemoteRenderingBackend> m_renderingBackend;
ScopedWebGLRenderingResourcesRequest m_renderingResourcesRequest;
NO_UNIQUE_ADDRESS ThreadAssertion m_streamThread;
+ WebCore::ProcessIdentifier m_webProcessIdentifier;
};
IPC::StreamConnectionWorkQueue& remoteGraphicsContextGLStreamWorkQueue();
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (283754 => 283755)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2021-10-07 23:30:56 UTC (rev 283755)
@@ -32,6 +32,7 @@
#include "GPUConnectionToWebProcess.h"
#include "Logging.h"
#include "PlatformRemoteImageBuffer.h"
+#include "QualifiedRenderingResourceIdentifier.h"
#include "RemoteMediaPlayerManagerProxy.h"
#include "RemoteMediaPlayerProxy.h"
#include "RemoteRenderingBackendCreationParameters.h"
@@ -154,6 +155,13 @@
void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, RenderingResourceIdentifier imageBufferResourceIdentifier)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ createImageBufferWithQualifiedIdentifier(logicalSize, renderingMode, resolutionScale, colorSpace, pixelFormat, { imageBufferResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() });
+}
+
+void RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier(const FloatSize& logicalSize, RenderingMode renderingMode, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, QualifiedRenderingResourceIdentifier imageBufferResourceIdentifier)
+{
ASSERT(!RunLoop::isMain());
ASSERT(renderingMode == RenderingMode::Accelerated || renderingMode == RenderingMode::Unaccelerated);
@@ -160,7 +168,7 @@
RefPtr<ImageBuffer> imageBuffer;
if (renderingMode == RenderingMode::Accelerated) {
- if (auto acceleratedImageBuffer = AcceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier)) {
+ if (auto acceleratedImageBuffer = AcceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier.object())) {
#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
// Mark the IOSurface as being owned by the WebProcess even though it was constructed by the GPUProcess so that Jetsam knows which process to kill.
acceleratedImageBuffer->setProcessOwnership(m_gpuConnectionToWebProcess->webProcessIdentityToken());
@@ -170,7 +178,7 @@
}
if (!imageBuffer)
- imageBuffer = UnacceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier);
+ imageBuffer = UnacceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier.object());
if (!imageBuffer) {
ASSERT_NOT_REACHED();
@@ -180,7 +188,7 @@
m_remoteResourceCache.cacheImageBuffer(*imageBuffer);
updateRenderingResourceRequest();
- if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(imageBufferResourceIdentifier))
+ if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(imageBufferResourceIdentifier.object()))
wakeUpAndApplyDisplayList(std::exchange(m_pendingWakeupInfo, std::nullopt)->arguments);
}
@@ -434,10 +442,17 @@
void RemoteRenderingBackend::getDataURLForImageBuffer(const String& mimeType, std::optional<double> quality, WebCore::PreserveResolution preserveResolution, WebCore::RenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(String&&)>&& completionHandler)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ getDataURLForImageBufferWithQualifiedIdentifier(mimeType, quality, preserveResolution, { renderingResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() }, WTFMove(completionHandler));
+}
+
+void RemoteRenderingBackend::getDataURLForImageBufferWithQualifiedIdentifier(const String& mimeType, std::optional<double> quality, WebCore::PreserveResolution preserveResolution, QualifiedRenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(String&&)>&& completionHandler)
+{
ASSERT(!RunLoop::isMain());
String urlString;
- if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier))
+ if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier.object()))
urlString = imageBuffer->toDataURL(mimeType, quality, preserveResolution);
completionHandler(WTFMove(urlString));
}
@@ -444,10 +459,17 @@
void RemoteRenderingBackend::getDataForImageBuffer(const String& mimeType, std::optional<double> quality, WebCore::RenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(Vector<uint8_t>&&)>&& completionHandler)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ getDataForImageBufferWithQualifiedIdentifier(mimeType, quality, { renderingResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() }, WTFMove(completionHandler));
+}
+
+void RemoteRenderingBackend::getDataForImageBufferWithQualifiedIdentifier(const String& mimeType, std::optional<double> quality, QualifiedRenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(Vector<uint8_t>&&)>&& completionHandler)
+{
ASSERT(!RunLoop::isMain());
Vector<uint8_t> data;
- if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier))
+ if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier.object()))
data = "" quality);
completionHandler(WTFMove(data));
}
@@ -454,11 +476,18 @@
void RemoteRenderingBackend::getShareableBitmapForImageBuffer(WebCore::RenderingResourceIdentifier identifier, WebCore::PreserveResolution preserveResolution, CompletionHandler<void(ShareableBitmap::Handle&&)>&& completionHandler)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ getShareableBitmapForImageBufferWithQualifiedIdentifier({ identifier, m_gpuConnectionToWebProcess->webProcessIdentifier() }, preserveResolution, WTFMove(completionHandler));
+}
+
+void RemoteRenderingBackend::getShareableBitmapForImageBufferWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier identifier, WebCore::PreserveResolution preserveResolution, CompletionHandler<void(ShareableBitmap::Handle&&)>&& completionHandler)
+{
ASSERT(!RunLoop::isMain());
ShareableBitmap::Handle handle;
[&]() {
- auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(identifier);
+ auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(identifier.object());
if (!imageBuffer)
return;
auto image = imageBuffer->copyNativeImage(WebCore::BackingStoreCopy::DontCopyBackingStore);
@@ -480,6 +509,13 @@
void RemoteRenderingBackend::cacheNativeImage(const ShareableBitmap::Handle& handle, RenderingResourceIdentifier nativeImageResourceIdentifier)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ cacheNativeImageWithQualifiedIdentifier(handle, { nativeImageResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() });
+}
+
+void RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier(const ShareableBitmap::Handle& handle, QualifiedRenderingResourceIdentifier nativeImageResourceIdentifier)
+{
ASSERT(!RunLoop::isMain());
auto bitmap = ShareableBitmap::create(handle);
@@ -486,23 +522,30 @@
if (!bitmap)
return;
- auto image = NativeImage::create(bitmap->createPlatformImage(), nativeImageResourceIdentifier);
+ auto image = NativeImage::create(bitmap->createPlatformImage(), nativeImageResourceIdentifier.object());
if (!image)
return;
m_remoteResourceCache.cacheNativeImage(*image);
- if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(nativeImageResourceIdentifier))
+ if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(nativeImageResourceIdentifier.object()))
wakeUpAndApplyDisplayList(std::exchange(m_pendingWakeupInfo, std::nullopt)->arguments);
}
-void RemoteRenderingBackend::cacheFont(Ref<Font>&& font)
+void RemoteRenderingBackend::cacheFont(Ref<WebCore::Font>&& font)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ auto renderingResourceIdentifier = font->renderingResourceIdentifier();
+ cacheFontWithQualifiedIdentifier(WTFMove(font), { renderingResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() });
+}
+
+void RemoteRenderingBackend::cacheFontWithQualifiedIdentifier(Ref<Font>&& font, QualifiedRenderingResourceIdentifier fontResourceIdentifier)
+{
ASSERT(!RunLoop::isMain());
- auto fontResourceIdentifier = font->renderingResourceIdentifier();
m_remoteResourceCache.cacheFont(WTFMove(font));
- if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(fontResourceIdentifier))
+ if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(fontResourceIdentifier.object()))
wakeUpAndApplyDisplayList(std::exchange(m_pendingWakeupInfo, std::nullopt)->arguments);
}
@@ -514,8 +557,15 @@
void RemoteRenderingBackend::releaseRemoteResource(RenderingResourceIdentifier renderingResourceIdentifier, uint64_t useCount)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ releaseRemoteResourceWithQualifiedIdentifier({ renderingResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() }, useCount);
+}
+
+void RemoteRenderingBackend::releaseRemoteResourceWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier renderingResourceIdentifier, uint64_t useCount)
+{
ASSERT(!RunLoop::isMain());
- auto success = m_remoteResourceCache.releaseRemoteResource(renderingResourceIdentifier, useCount);
+ auto success = m_remoteResourceCache.releaseRemoteResource(renderingResourceIdentifier.object(), useCount);
MESSAGE_CHECK(success, "Resource is being released before being cached.");
updateRenderingResourceRequest();
}
@@ -534,6 +584,13 @@
void RemoteRenderingBackend::didCreateSharedDisplayListHandle(DisplayList::ItemBufferIdentifier itemBufferIdentifier, const SharedMemory::IPCHandle& handle, RenderingResourceIdentifier destinationBufferIdentifier)
{
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ didCreateSharedDisplayListHandleWithQualifiedIdentifier(itemBufferIdentifier, handle, { destinationBufferIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() });
+}
+
+void RemoteRenderingBackend::didCreateSharedDisplayListHandleWithQualifiedIdentifier(DisplayList::ItemBufferIdentifier itemBufferIdentifier, const SharedMemory::IPCHandle& handle, QualifiedRenderingResourceIdentifier)
+{
ASSERT(!RunLoop::isMain());
MESSAGE_CHECK(!m_sharedDisplayListHandles.contains(itemBufferIdentifier), "Duplicate shared display list handle");
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (283754 => 283755)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2021-10-07 23:30:56 UTC (rev 283755)
@@ -33,6 +33,7 @@
#include "ImageBufferBackendHandle.h"
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "QualifiedRenderingResourceIdentifier.h"
#include "RemoteRenderingBackendState.h"
#include "RemoteResourceCache.h"
#include "RenderingBackendIdentifier.h"
@@ -149,6 +150,16 @@
void finalizeRenderingUpdate(RenderingUpdateID);
void didCreateSharedDisplayListHandle(WebCore::DisplayList::ItemBufferIdentifier, const SharedMemory::IPCHandle&, WebCore::RenderingResourceIdentifier destinationBufferIdentifier);
+ // Received messages translated to use QualifiedRenderingResourceIdentifier.
+ void createImageBufferWithQualifiedIdentifier(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, float resolutionScale, const WebCore::DestinationColorSpace&, WebCore::PixelFormat, QualifiedRenderingResourceIdentifier);
+ void getDataURLForImageBufferWithQualifiedIdentifier(const String& mimeType, std::optional<double> quality, WebCore::PreserveResolution, QualifiedRenderingResourceIdentifier, CompletionHandler<void(String&&)>&&);
+ void getDataForImageBufferWithQualifiedIdentifier(const String& mimeType, std::optional<double> quality, QualifiedRenderingResourceIdentifier, CompletionHandler<void(Vector<uint8_t>&&)>&&);
+ void getShareableBitmapForImageBufferWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier, WebCore::PreserveResolution, CompletionHandler<void(ShareableBitmap::Handle&&)>&&);
+ void cacheNativeImageWithQualifiedIdentifier(const ShareableBitmap::Handle&, QualifiedRenderingResourceIdentifier);
+ void didCreateSharedDisplayListHandleWithQualifiedIdentifier(WebCore::DisplayList::ItemBufferIdentifier, const SharedMemory::IPCHandle&, QualifiedRenderingResourceIdentifier destinationBufferIdentifier);
+ void releaseRemoteResourceWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier, uint64_t useCount);
+ void cacheFontWithQualifiedIdentifier(Ref<WebCore::Font>&&, QualifiedRenderingResourceIdentifier);
+
class ReplayerDelegate : public WebCore::DisplayList::Replayer::Delegate {
public:
ReplayerDelegate(WebCore::ImageBuffer&, RemoteRenderingBackend&);
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (283754 => 283755)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-10-07 23:25:05 UTC (rev 283754)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-10-07 23:30:56 UTC (rev 283755)
@@ -3095,6 +3095,7 @@
1CA8B944127C882A00576C2B /* WebInspectorUIProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorUIProxyMessages.h; path = DerivedSources/WebKit2/WebInspectorUIProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebInspectorUIMessageReceiver.cpp; path = DerivedSources/WebKit2/WebInspectorUIMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorUIMessages.h; path = DerivedSources/WebKit2/WebInspectorUIMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1CC54AFD270F9654005BF8BE /* QualifiedRenderingResourceIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QualifiedRenderingResourceIdentifier.h; sourceTree = "<group>"; };
1CF18F3E26BB5D90004B1722 /* LogInitialization.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogInitialization.cpp; sourceTree = "<group>"; };
1D0530C9258EAB4400E436F7 /* combine-feature-flags-plist.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = "combine-feature-flags-plist.py"; sourceTree = "<group>"; };
1D0530D1259162C800E436F7 /* WebKit-ios.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "WebKit-ios.plist"; sourceTree = "<group>"; };
@@ -9092,6 +9093,7 @@
F4094CBC255304AF003D73E3 /* DisplayListReaderHandle.cpp */,
F4094CBB255304AF003D73E3 /* DisplayListReaderHandle.h */,
55AD09432408A0E600DE4D2F /* PlatformRemoteImageBuffer.h */,
+ 1CC54AFD270F9654005BF8BE /* QualifiedRenderingResourceIdentifier.h */,
7B904169254AFEA7006EEB8C /* RemoteGraphicsContextGL.cpp */,
7B90416A254AFEA7006EEB8C /* RemoteGraphicsContextGL.h */,
7B904168254AFEA7006EEB8C /* RemoteGraphicsContextGL.messages.in */,
@@ -12485,7 +12487,7 @@
5C298DA01C3DF02100470AFE /* PendingDownload.h in Headers */,
832ED18C1E2FE157006BA64A /* PerActivityStateCPUUsageSampler.h in Headers */,
7AFBD36F21E546F8005DBACB /* PersistencyUtils.h in Headers */,
- E5DEFA6826F8F42600AB68DB /* PhotosUISPI.h in Headers */,
+ E5DEFA6826F8F42600AB68DB /* PhotosUISPI.h in Headers */,
5CE85B201C88E64B0070BFCE /* PingLoad.h in Headers */,
0F5E200418E77051003EC3E5 /* PlatformCAAnimationRemote.h in Headers */,
2DA049B4180CCCD300AAFA9E /* PlatformCALayerRemote.h in Headers */,