Changeset 286838 in webkit
- Timestamp:
- Dec 10, 2021, 12:24:30 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 30 edited
- 1 copied
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Headers.cmake (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Source/WebCore/platform/Logging.h (modified) (1 diff)
-
Source/WebCore/platform/ProcessIdentity.cpp (copied) (copied from trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h ) (2 diffs)
-
Source/WebCore/platform/ProcessIdentity.h (added)
-
Source/WebCore/platform/graphics/RemoteVideoSample.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (modified) (4 diffs)
-
Source/WebCore/platform/graphics/cocoa/IOSurface.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cocoa/IOSurface.mm (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (modified) (2 diffs)
-
Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (modified) (3 diffs)
-
Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp (modified) (5 diffs)
-
Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (modified) (1 diff)
-
Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (modified) (2 diffs)
-
Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (modified) (2 diffs)
-
Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (modified) (1 diff)
-
Source/WebKit/Shared/GPUProcessConnectionParameters.h (modified) (5 diffs)
-
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (modified) (7 diffs)
-
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286837 r286838 1 2021-12-10 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 IOSurface memory attribution is hard to use in constructors 4 https://bugs.webkit.org/show_bug.cgi?id=232988 5 <rdar://problem/85541918> 6 7 Reviewed by Chris Dumez. 8 9 Add WebCore::ProcessIdentity type that can be used to communicate memory attribution. 10 For non-Cocoa ports, this is nullptr. 11 This is used in WebCore to set the memory attribution of IOSurface and objects 12 that hold IOSurfaces. 13 This is instantiated in WebKit. 14 Currently the only useful way to instantiate ProcessIdentity is by receiving 15 the ProcessIdentity as a message and create it this way for the 16 sender process. 17 18 No new tests, refactor. 19 20 * Headers.cmake: 21 * Sources.txt: 22 * WebCore.xcodeproj/project.pbxproj: 23 * platform/Logging.h: 24 Add WebCore Process log tag since the code moved from WebKit to ProcessIdentity 25 used that tag to log. 26 * platform/ProcessIdentity.cpp: Added. 27 (WebCore::ProcessIdentity::ProcessIdentity): 28 (WebCore::ProcessIdentity::taskIdToken const): 29 (WebCore::ProcessIdentity::sendRight const): 30 (WebCore::ProcessIdentity::operator bool const): 31 * platform/ProcessIdentity.h: Added. 32 Add the ProcessIdentity type that can be used to communicate memory attribution. 33 * platform/graphics/RemoteVideoSample.h: 34 (WebCore::RemoteVideoSample::setOwnershipIdentity): 35 * platform/graphics/angle/GraphicsContextGLANGLE.h: 36 * platform/graphics/cocoa/GraphicsContextGLCocoa.h: 37 * platform/graphics/cocoa/GraphicsContextGLCocoa.mm: 38 (WebCore::GraphicsContextGLCocoa::create): 39 (WebCore::GraphicsContextGLCocoa::GraphicsContextGLCocoa): 40 (WebCore::GraphicsContextGLANGLE::allocateAndBindDisplayBufferBacking): 41 Add an example use where the constructor takes the memory attribution token. 42 This may be needed in the future when the token is used as a parameter in 43 the ANGLE context creation. 44 Use the token in creating the IOSurface. This fixes a bug where WebGL 45 back buffers would not be attributed until they were sent to WP. 46 * platform/graphics/cocoa/IOSurface.h: 47 * platform/graphics/cocoa/IOSurface.mm: 48 (WebCore::IOSurface::setOwnershipIdentity): 49 * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm: 50 1 51 2021-12-10 Adrian Perez de Castro <aperez@igalia.com> 2 52 -
trunk/Source/WebCore/Headers.cmake
r286824 r286838 1292 1292 platform/PopupMenuStyle.h 1293 1293 platform/ProcessIdentifier.h 1294 platform/ProcessIdentity.h 1294 1295 platform/ProcessQualified.h 1295 1296 platform/PromisedAttachmentInfo.h -
trunk/Source/WebCore/Sources.txt
r286821 r286838 1887 1887 platform/PreviewConverter.cpp 1888 1888 platform/ProcessIdentifier.cpp 1889 platform/ProcessIdentity.cpp 1889 1890 platform/ReferrerPolicy.cpp 1890 1891 platform/RemoteCommandListener.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r286824 r286838 2392 2392 7BB680BA25BA1BE4002B8738 /* GraphicsChecksMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2393 2393 7BDDA31F274FA0210038659E /* GraphicsContextGLCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2394 7BDDA34C275A01310038659E /* ProcessIdentity.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA349275A01300038659E /* ProcessIdentity.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2394 2395 7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; }; 2395 2396 7BFF59F42757726700773D39 /* DisplayConfigurationMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BFF59EF275771E800773D39 /* DisplayConfigurationMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 11419 11420 7BDDA31C274F9DA40038659E /* GraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GraphicsContextGLCocoa.mm; sourceTree = "<group>"; }; 11420 11421 7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCocoa.h; sourceTree = "<group>"; }; 11422 7BDDA349275A01300038659E /* ProcessIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessIdentity.h; sourceTree = "<group>"; }; 11423 7BDDA34B275A01300038659E /* ProcessIdentity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessIdentity.cpp; sourceTree = "<group>"; }; 11421 11424 7BE7265B25763B8D00E85D98 /* RemoteGraphicsContextGLProxyBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyBase.cpp; sourceTree = "<group>"; }; 11422 11425 7BFF59EF275771E800773D39 /* DisplayConfigurationMonitor.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = DisplayConfigurationMonitor.h; sourceTree = "<group>"; }; … … 29779 29782 51F645D21FECDBC800B54DED /* ProcessIdentifier.cpp */, 29780 29783 51F645D31FECDBC800B54DED /* ProcessIdentifier.h */, 29784 7BDDA34B275A01300038659E /* ProcessIdentity.cpp */, 29785 7BDDA349275A01300038659E /* ProcessIdentity.h */, 29781 29786 1CC54AFB270F92DA005BF8BE /* ProcessQualified.h */, 29782 29787 F47A633C1FF6FD500081B3CC /* PromisedAttachmentInfo.h */, … … 36321 36326 6B0A07F221FA4B5C00D57391 /* PrivateClickMeasurement.h in Headers */, 36322 36327 51F645D51FECDBCE00B54DED /* ProcessIdentifier.h in Headers */, 36328 7BDDA34C275A01310038659E /* ProcessIdentity.h in Headers */, 36323 36329 A8EA7EBC0A1945D000A8EF5F /* ProcessingInstruction.h in Headers */, 36324 36330 1CC54AFE270F96AE005BF8BE /* ProcessQualified.h in Headers */, -
trunk/Source/WebCore/platform/Logging.h
r285528 r286838 95 95 M(PopupBlocking) \ 96 96 M(PrivateClickMeasurement) \ 97 M(Process) \ 97 98 M(Progress) \ 98 99 M(RemoteInspector) \ -
trunk/Source/WebCore/platform/ProcessIdentity.cpp
r286837 r286838 1 1 /* 2 * Copyright (C) 202 0 Apple Inc.All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "ProcessIdentity.h" 27 28 28 #i f ENABLE(GPU_PROCESS) && HAVE(IOSURFACE)29 #include "Logging.h" 29 30 30 #i nclude "ImageBufferBackendHandle.h"31 #include < WebCore/ImageBufferIOSurfaceBackend.h>32 # include <wtf/IsoMalloc.h>31 #if HAVE(TASK_IDENTITY_TOKEN) 32 #include <mach/mach.h> 33 #endif 33 34 34 namespace Web Kit{35 namespace WebCore { 35 36 36 class ShareableBitmap; 37 ProcessIdentity::ProcessIdentity(CurrentProcessTag) 38 { 39 #if HAVE(TASK_IDENTITY_TOKEN) 40 task_id_token_t identityToken; 41 kern_return_t kr = task_create_identity_token(mach_task_self(), &identityToken); 42 if (kr == KERN_SUCCESS) 43 m_taskIdToken = MachSendRight::adopt(identityToken); 44 else 45 RELEASE_LOG_ERROR(Process, "task_create_identity_token() failed: %{private}s (%x)", mach_error_string(kr), kr); 46 #endif 47 } 37 48 38 class ImageBufferShareableMappedIOSurfaceBackend final : public WebCore::ImageBufferIOSurfaceBackend { 39 WTF_MAKE_ISO_ALLOCATED(ImageBufferShareableMappedIOSurfaceBackend); 40 WTF_MAKE_NONCOPYABLE(ImageBufferShareableMappedIOSurfaceBackend); 41 public: 42 static std::unique_ptr<ImageBufferShareableMappedIOSurfaceBackend> create(const Parameters&, const WebCore::HostWindow*); 43 static std::unique_ptr<ImageBufferShareableMappedIOSurfaceBackend> create(const Parameters&, ImageBufferBackendHandle); 49 ProcessIdentity::operator bool() const 50 { 51 #if HAVE(TASK_IDENTITY_TOKEN) 52 return static_cast<bool>(m_taskIdToken); 53 #else 54 return false; 55 #endif 56 } 44 57 45 using WebCore::ImageBufferIOSurfaceBackend::ImageBufferIOSurfaceBackend; 58 #if HAVE(TASK_IDENTITY_TOKEN) 59 ProcessIdentity::ProcessIdentity(MachSendRight&& taskIdToken) 60 : m_taskIdToken(WTFMove(taskIdToken)) 61 { 62 } 63 #endif 46 64 47 ImageBufferBackendHandle createImageBufferBackendHandle() const; 48 49 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 50 void setProcessOwnership(task_id_token_t); 51 #endif 52 }; 53 54 } // namespace WebKit 55 56 #endif // ENABLE(GPU_PROCESS) && HAVE(IOSURFACE) 65 } -
trunk/Source/WebCore/platform/graphics/RemoteVideoSample.h
r284857 r286838 38 38 namespace WebCore { 39 39 40 class ProcessIdentity; 41 40 42 class RemoteVideoSample { 41 43 public: … … 49 51 WEBCORE_EXPORT IOSurfaceRef surface() const; 50 52 51 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 52 void setOwnershipIdentity(task_id_token_t newOwner); 53 #endif 53 void setOwnershipIdentity(const ProcessIdentity&); 54 54 55 55 const MediaTime& time() const { return m_time; } … … 120 120 }; 121 121 122 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 123 inline void RemoteVideoSample::setOwnershipIdentity(task_id_token_t newOwner) 122 inline void RemoteVideoSample::setOwnershipIdentity(const ProcessIdentity& resourceOwner) 124 123 { 125 124 if (m_ioSurface) 126 m_ioSurface->setOwnershipIdentity( newOwner);125 m_ioSurface->setOwnershipIdentity(resourceOwner); 127 126 } 128 #endif129 127 130 128 } -
trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h
r286423 r286838 37 37 #include "GraphicsContextGLIOSurfaceSwapChain.h" 38 38 #include "IOSurface.h" 39 #include "ProcessIdentity.h" 39 40 #endif 40 41 … … 428 429 429 430 #if PLATFORM(COCOA) 431 // FIXME: Move these to GraphicsContextGLCocoa. 430 432 GraphicsContextGLIOSurfaceSwapChain m_swapChain; 431 433 EGLDisplay m_displayObj { nullptr }; … … 437 439 std::unique_ptr<IOSurface> m_displayBufferBacking; 438 440 void* m_displayBufferPbuffer { nullptr }; 441 ProcessIdentity m_resourceOwner; 439 442 #endif 440 443 #if USE(COORDINATED_GRAPHICS) -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h
r286709 r286838 43 43 namespace WebCore { 44 44 45 class ProcessIdentity; 46 45 47 class WEBCORE_EXPORT GraphicsContextGLCocoa : public GraphicsContextGLANGLE { 46 48 public: 47 static RefPtr<GraphicsContextGLCocoa> create(WebCore::GraphicsContextGLAttributes&& );49 static RefPtr<GraphicsContextGLCocoa> create(WebCore::GraphicsContextGLAttributes&&, ProcessIdentity&& resourceOwner); 48 50 ~GraphicsContextGLCocoa(); 49 51 IOSurface* displayBuffer(); … … 77 79 #endif 78 80 protected: 79 GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&& );81 GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&&, ProcessIdentity&& resourceOwner); 80 82 bool isValid() const; 81 82 83 #if ENABLE(VIDEO) 83 84 std::unique_ptr<GraphicsContextGLCVCocoa> m_cv; -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm
r286709 r286838 36 36 #import "GraphicsContextGLOpenGLManager.h" 37 37 #import "Logging.h" 38 #import "ProcessIdentity.h" 38 39 #import "RuntimeApplicationChecks.h" 39 40 #import <CoreGraphics/CGBitmapContext.h> … … 193 194 #endif 194 195 195 RefPtr<GraphicsContextGLCocoa> GraphicsContextGLCocoa::create(GraphicsContextGLAttributes&& attributes )196 { 197 auto context = adoptRef(*new GraphicsContextGLCocoa(WTFMove(attributes) ));196 RefPtr<GraphicsContextGLCocoa> GraphicsContextGLCocoa::create(GraphicsContextGLAttributes&& attributes, ProcessIdentity&& resourceOwner) 197 { 198 auto context = adoptRef(*new GraphicsContextGLCocoa(WTFMove(attributes), WTFMove(resourceOwner))); 198 199 if (!context->isValid()) 199 200 return nullptr; … … 201 202 } 202 203 203 GraphicsContextGLCocoa::GraphicsContextGLCocoa(GraphicsContextGLAttributes&& creationAttributes )204 GraphicsContextGLCocoa::GraphicsContextGLCocoa(GraphicsContextGLAttributes&& creationAttributes, ProcessIdentity&& resourceOwner) 204 205 : GraphicsContextGLANGLE(WTFMove(creationAttributes)) 205 206 { 206 207 if (!isValid()) 207 208 return; 209 // FIXME: Move this to initializer list once m_resourceOwner moves to GraphicsContextGLCocoa. 210 m_resourceOwner = WTFMove(resourceOwner); 211 208 212 #if PLATFORM(MAC) 209 213 auto attributes = contextAttributes(); … … 558 562 if (!backing) 559 563 return false; 560 564 if (m_resourceOwner) 565 backing->setOwnershipIdentity(m_resourceOwner); 561 566 backing->migrateColorSpaceToProperties(); 562 567 -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h
r284857 r286838 47 47 class HostWindow; 48 48 class ImageBuffer; 49 class ProcessIdentity; 49 50 50 51 enum class PixelFormat : uint8_t; … … 160 161 #endif // HAVE(IOSURFACE_ACCELERATOR) 161 162 162 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 163 WEBCORE_EXPORT void setOwnershipIdentity(task_id_token_t newOwner); 164 #endif 163 WEBCORE_EXPORT void setOwnershipIdentity(const ProcessIdentity&); 165 164 166 165 void migrateColorSpaceToProperties(); -
trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm
r286816 r286838 35 35 #import "Logging.h" 36 36 #import "PlatformScreen.h" 37 #import "ProcessIdentity.h" 37 38 #import <pal/spi/cg/CoreGraphicsSPI.h> 38 39 #import <wtf/Assertions.h> … … 485 486 #endif // HAVE(IOSURFACE_ACCELERATOR) 486 487 487 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 488 void IOSurface::setOwnershipIdentity(task_id_token_t newOwner) 489 { 490 auto result = IOSurfaceSetOwnershipIdentity(m_surface.get(), newOwner, kIOSurfaceMemoryLedgerTagGraphics, 0); 488 void IOSurface::setOwnershipIdentity(const ProcessIdentity& resourceOwner) 489 { 490 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) && HAVE(TASK_IDENTITY_TOKEN) 491 ASSERT(resourceOwner); 492 task_id_token_t ownerTaskIdToken = resourceOwner.taskIdToken(); 493 auto result = IOSurfaceSetOwnershipIdentity(m_surface.get(), ownerTaskIdToken, kIOSurfaceMemoryLedgerTagGraphics, 0); 491 494 if (result != kIOReturnSuccess) 492 RELEASE_LOG_ERROR(IOSurface, "IOSurface::setOwnershipIdentity: Failed to claim ownership of IOSurface %p, newOwner: %d, error: %d", m_surface.get(), (int)newOwner, result); 493 } 494 #endif 495 RELEASE_LOG_ERROR(IOSurface, "IOSurface::setOwnershipIdentity: Failed to claim ownership of IOSurface %p, task id token: %d, error: %d", m_surface.get(), (int)ownerTaskIdToken, result); 496 #else 497 UNUSED_PARAM(resourceOwner); 498 #endif 499 } 495 500 496 501 void IOSurface::migrateColorSpaceToProperties() -
trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm
r286709 r286838 30 30 #import "GraphicsContextGLCocoa.h" // NOLINT 31 31 #import "GraphicsContextGLOpenGLManager.h" 32 #import "ProcessIdentity.h" 32 33 #import "WebGLLayer.h" 33 34 #import <wtf/BlockObjCExceptions.h> … … 78 79 79 80 WebProcessGraphicsContextGLCocoa::WebProcessGraphicsContextGLCocoa(GraphicsContextGLAttributes&& attributes) 80 : GraphicsContextGLCocoa(WTFMove(attributes) )81 : GraphicsContextGLCocoa(WTFMove(attributes), { }) 81 82 , m_webGLLayer(createWebGLLayer(contextAttributes())) 82 83 { -
trunk/Source/WebKit/ChangeLog
r286837 r286838 1 2021-12-10 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 IOSurface memory attribution is hard to use in constructors 4 https://bugs.webkit.org/show_bug.cgi?id=232988 5 <rdar://problem/85541918> 6 7 Reviewed by Chris Dumez. 8 9 Remove ifdefs and direct use of task_id_token_t. 10 Instead, use WebCore::ProcessIdentifier. This way the 11 cross-platform code is easier to author. 12 13 * GPUProcess/GPUConnectionToWebProcess.cpp: 14 (WebKit::GPUConnectionToWebProcess::GPUConnectionToWebProcess): 15 * GPUProcess/GPUConnectionToWebProcess.h: 16 (WebKit::GPUConnectionToWebProcess::webProcessIdentity const): 17 (WebKit::GPUConnectionToWebProcess::webProcessIdentityToken const): Deleted. 18 * GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp: 19 (WebKit::RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa): 20 (WebKit::RemoteGraphicsContextGLCocoa::platformWorkQueueInitialize): 21 (WebKit::RemoteGraphicsContextGLCocoa::prepareForDisplay): 22 * GPUProcess/graphics/RemoteImageBuffer.h: 23 (WebKit::RemoteImageBuffer::setOwnershipIdentity): 24 (WebKit::RemoteImageBuffer::setProcessOwnership): Deleted. 25 * GPUProcess/graphics/RemoteRenderingBackend.cpp: 26 (WebKit::RemoteRenderingBackend::RemoteRenderingBackend): 27 (WebKit::RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier): 28 * GPUProcess/graphics/RemoteRenderingBackend.h: 29 * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm: 30 (WebKit::Function<void): 31 * Shared/GPUProcessConnectionParameters.h: 32 (WebKit::GPUProcessConnectionParameters::encode const): 33 (WebKit::GPUProcessConnectionParameters::decode): 34 * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: 35 (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy): 36 (WebKit::UserMediaCaptureManagerProxy::SourceProxy::setShouldApplyRotation): 37 (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): 38 (WebKit::UserMediaCaptureManagerProxy::clone): 39 (WebKit::UserMediaCaptureManagerProxy::SourceProxy::setWebProcessIdentityToken): Deleted. 40 * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: 41 (WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::webProcessIdentityToken const): Deleted. 42 * UIProcess/WebProcessProxy.cpp: 43 * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h: 44 (WebKit::ImageBufferShareableBitmapBackend::setOwnershipIdentity): 45 * WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp: 46 (WebKit::ImageBufferShareableMappedIOSurfaceBackend::setOwnershipIdentity): 47 (WebKit::ImageBufferShareableMappedIOSurfaceBackend::setProcessOwnership): Deleted. 48 * WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h: 49 * WebProcess/cocoa/WebProcessCocoa.mm: 50 (WebKit::WebProcess::platformInitializeGPUProcessConnectionParameters): 51 1 52 2021-12-10 Adrian Perez de Castro <aperez@igalia.com> 2 53 -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
r286650 r286838 208 208 } 209 209 #endif 210 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 211 std::optional<task_id_token_t> webProcessIdentityToken() const final210 211 const ProcessIdentity& resourceOwner() const final 212 212 { 213 return m_process.webProcessIdentityToken(); 214 } 215 #endif 213 return m_process.webProcessIdentity(); 214 } 216 215 217 216 GPUConnectionToWebProcess& m_process; … … 229 228 , m_gpuProcess(gpuProcess) 230 229 , m_webProcessIdentifier(webProcessIdentifier) 231 #if HAVE(TASK_IDENTITY_TOKEN) 232 , m_webProcessIdentityToken(WTFMove(parameters.webProcessIdentityToken)) 233 #endif 230 , m_webProcessIdentity(WTFMove(parameters.webProcessIdentity)) 234 231 , m_remoteMediaPlayerManagerProxy(makeUniqueRef<RemoteMediaPlayerManagerProxy>(*this)) 235 232 , m_sessionID(sessionID) -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h
r286650 r286838 42 42 #include <WebCore/PageIdentifier.h> 43 43 #include <WebCore/ProcessIdentifier.h> 44 #include <WebCore/ProcessIdentity.h> 44 45 #include <pal/SessionID.h> 45 46 #include <wtf/Logger.h> … … 156 157 #endif 157 158 158 #if HAVE(TASK_IDENTITY_TOKEN) 159 task_id_token_t webProcessIdentityToken() const { return static_cast<task_id_token_t>(m_webProcessIdentityToken.sendRight()); } 160 #endif 161 159 const WebCore::ProcessIdentity& webProcessIdentity() const { return m_webProcessIdentity; } 162 160 #if ENABLE(ENCRYPTED_MEDIA) 163 161 RemoteCDMFactoryProxy& cdmFactoryProxy(); … … 284 282 Ref<GPUProcess> m_gpuProcess; 285 283 const WebCore::ProcessIdentifier m_webProcessIdentifier; 286 #if HAVE(TASK_IDENTITY_TOKEN) 287 MachSendRight m_webProcessIdentityToken; 288 #endif 284 const WebCore::ProcessIdentity m_webProcessIdentity; 289 285 #if ENABLE(WEB_AUDIO) 290 286 std::unique_ptr<RemoteAudioDestinationManager> m_remoteAudioDestinationManager; -
trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp
r286709 r286838 30 30 31 31 #include "GPUConnectionToWebProcess.h" 32 #include <WebCore/ProcessIdentity.h> 32 33 #include <wtf/MachSendRight.h> 33 34 … … 46 47 void prepareForDisplay(CompletionHandler<void(WTF::MachSendRight&&)>&&) final; 47 48 private: 48 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 49 task_id_token_t m_webProcessIdentityToken; 50 #endif 49 const ProcessIdentity m_resourceOwner; 51 50 }; 52 51 … … 62 61 RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream) 63 62 : RemoteGraphicsContextGL(gpuConnectionToWebProcess, graphicsContextGLIdentifier, renderingBackend, WTFMove(stream)) 64 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 65 , m_webProcessIdentityToken(gpuConnectionToWebProcess.webProcessIdentityToken()) 66 #endif 63 , m_resourceOwner(gpuConnectionToWebProcess.webProcessIdentity()) 67 64 { 68 65 … … 72 69 { 73 70 assertIsCurrent(m_streamThread); 74 m_context = GraphicsContextGLCocoa::create(WTFMove(attributes) );71 m_context = GraphicsContextGLCocoa::create(WTFMove(attributes), ProcessIdentity { m_resourceOwner }); 75 72 } 76 73 … … 83 80 if (displayBuffer) { 84 81 m_context->markDisplayBufferInUse(); 85 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)86 // 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.87 displayBuffer->setOwnershipIdentity(m_webProcessIdentityToken);88 #endif89 82 sendRight = displayBuffer->createSendRight(); 90 83 } -
trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h
r284079 r286838 70 70 } 71 71 72 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 73 void setProcessOwnership(task_id_token_t newOwner) 72 void setOwnershipIdentity(const WebCore::ProcessIdentity& resourceOwner) 74 73 { 75 74 if (m_backend) 76 m_backend->set ProcessOwnership(newOwner);75 m_backend->setOwnershipIdentity(resourceOwner); 77 76 } 78 #endif79 77 80 78 private: -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
r286538 r286838 86 86 , m_remoteResourceCache(gpuConnectionToWebProcess.webProcessIdentifier()) 87 87 , m_gpuConnectionToWebProcess(gpuConnectionToWebProcess) 88 , m_resourceOwner(gpuConnectionToWebProcess.webProcessIdentity()) 88 89 , m_renderingBackendIdentifier(creationParameters.identifier) 89 90 { … … 175 176 if (renderingMode == RenderingMode::Accelerated) { 176 177 if (auto acceleratedImageBuffer = AcceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier)) { 177 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)178 178 // 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. 179 acceleratedImageBuffer->setProcessOwnership(m_gpuConnectionToWebProcess->webProcessIdentityToken());180 #endif 179 if (m_resourceOwner) 180 acceleratedImageBuffer->setOwnershipIdentity(m_resourceOwner); 181 181 imageBuffer = WTFMove(acceleratedImageBuffer); 182 182 } -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h
r286538 r286838 47 47 #include <WebCore/DisplayListReplayer.h> 48 48 #include <WebCore/ProcessIdentifier.h> 49 #include <WebCore/ProcessIdentity.h> 49 50 #include <wtf/WeakPtr.h> 50 51 … … 134 135 RemoteResourceCache m_remoteResourceCache; 135 136 Ref<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess; 137 WebCore::ProcessIdentity m_resourceOwner; 136 138 RenderingBackendIdentifier m_renderingBackendIdentifier; 137 139 IPC::Semaphore m_getPixelBufferSemaphore; -
trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
r283369 r286838 77 77 static Function<void(CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp)> createDecoderCallback(RTCDecoderIdentifier identifier, GPUConnectionToWebProcess& gpuConnectionToWebProcess) 78 78 { 79 return [connection = Ref { gpuConnectionToWebProcess.connection() }, 80 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 81 token = gpuConnectionToWebProcess.webProcessIdentityToken(), 82 #endif 83 identifier](CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) { 79 return [connection = Ref { gpuConnectionToWebProcess.connection() }, resourceOwner = gpuConnectionToWebProcess.webProcessIdentity(), identifier] (CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) { 84 80 if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1))) { 85 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 86 sample->setOwnershipIdentity(token); 87 #endif 81 if (resourceOwner) 82 sample->setOwnershipIdentity(resourceOwner); 88 83 connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0); 89 84 } -
trunk/Source/WebKit/Shared/GPUProcessConnectionParameters.h
r285979 r286838 29 29 30 30 #include "WebCoreArgumentCoders.h" 31 #include <WebCore/ProcessIdentity.h> 31 32 #include <wtf/MachSendRight.h> 32 33 … … 34 35 35 36 struct GPUProcessConnectionParameters { 36 #if HAVE(TASK_IDENTITY_TOKEN) 37 MachSendRight webProcessIdentityToken; 38 #endif 37 WebCore::ProcessIdentity webProcessIdentity; 39 38 Vector<String> overrideLanguages; 40 39 #if ENABLE(IPC_TESTING_API) … … 47 46 void encode(IPC::Encoder& encoder) const 48 47 { 49 #if HAVE(TASK_IDENTITY_TOKEN) 50 encoder << webProcessIdentityToken; 51 #endif 48 encoder << webProcessIdentity; 52 49 encoder << overrideLanguages; 53 50 #if ENABLE(IPC_TESTING_API) … … 61 58 static std::optional<GPUProcessConnectionParameters> decode(IPC::Decoder& decoder) 62 59 { 63 #if HAVE(TASK_IDENTITY_TOKEN) 64 std::optional<MachSendRight> webProcessIdentityToken; 65 decoder >> webProcessIdentityToken; 66 if (!webProcessIdentityToken) 60 std::optional<WebCore::ProcessIdentity> webProcessIdentity; 61 decoder >> webProcessIdentity; 62 if (!webProcessIdentity) 67 63 return std::nullopt; 68 #endif69 64 70 65 std::optional<Vector<String>> overrideLanguages; … … 87 82 88 83 return GPUProcessConnectionParameters { 89 #if HAVE(TASK_IDENTITY_TOKEN) 90 WTFMove(*webProcessIdentityToken), 91 #endif 84 WTFMove(*webProcessIdentity), 92 85 WTFMove(*overrideLanguages), 93 86 #if ENABLE(IPC_TESTING_API) -
trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
r286650 r286838 58 58 WTF_MAKE_FAST_ALLOCATED; 59 59 public: 60 SourceProxy(RealtimeMediaSourceIdentifier id, Ref<IPC::Connection>&& connection, Ref<RealtimeMediaSource>&& source)60 SourceProxy(RealtimeMediaSourceIdentifier id, Ref<IPC::Connection>&& connection, ProcessIdentity&& resourceOwner, Ref<RealtimeMediaSource>&& source) 61 61 : m_id(id) 62 62 , m_connection(WTFMove(connection)) 63 , m_resourceOwner(WTFMove(resourceOwner)) 63 64 , m_source(WTFMove(source)) 64 65 { … … 126 127 127 128 void setShouldApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = true; } 128 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)129 void setWebProcessIdentityToken(std::optional<task_id_token_t> token) { m_webProcessIdentityToken = token;}130 #endif131 129 132 130 private: … … 189 187 remoteSample = RemoteVideoSample::create(sample); 190 188 if (remoteSample) { 191 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 192 if (m_webProcessIdentityToken) 193 remoteSample->setOwnershipIdentity(*m_webProcessIdentityToken); 194 #endif 189 if (m_resourceOwner) 190 remoteSample->setOwnershipIdentity(m_resourceOwner); 195 191 m_connection->send(Messages::RemoteCaptureSampleManager::VideoSampleAvailable(m_id, WTFMove(*remoteSample), metadata), 0); 196 192 } … … 245 241 WeakPtr<PlatformMediaSessionManager> m_sessionManager; 246 242 Ref<IPC::Connection> m_connection; 243 ProcessIdentity m_resourceOwner; 247 244 Ref<RealtimeMediaSource> m_source; 248 245 std::unique_ptr<CARingBuffer> m_ringBuffer; … … 258 255 MediaTime m_startTime; 259 256 bool m_shouldReset { false }; 260 #if HAVE(TASK_IDENTITY_TOKEN)261 std::optional<task_id_token_t> m_webProcessIdentityToken;262 #endif263 257 }; 264 258 … … 324 318 325 319 ASSERT(!m_proxies.contains(id)); 326 auto proxy = makeUnique<SourceProxy>(id, m_connectionProxy->connection(), WTFMove(source)); 327 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 328 if (device.type() != WebCore::CaptureDevice::DeviceType::Microphone) 329 proxy->setWebProcessIdentityToken(m_connectionProxy->webProcessIdentityToken()); 330 #endif 331 320 auto proxy = makeUnique<SourceProxy>(id, m_connectionProxy->connection(), ProcessIdentity { m_connectionProxy->resourceOwner() }, WTFMove(source)); 332 321 m_proxies.add(id, WTFMove(proxy)); 333 322 } else … … 395 384 MESSAGE_CHECK(!m_proxies.contains(newSourceID)); 396 385 if (auto* proxy = m_proxies.get(clonedID)) 397 m_proxies.add(newSourceID, makeUnique<SourceProxy>(newSourceID, m_connectionProxy->connection(), proxy->source().clone()));386 m_proxies.add(newSourceID, makeUnique<SourceProxy>(newSourceID, m_connectionProxy->connection(), ProcessIdentity { m_connectionProxy->resourceOwner() }, proxy->source().clone())); 398 387 } 399 388 -
trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h
r286650 r286838 33 33 #include <WebCore/CaptureDevice.h> 34 34 #include <WebCore/OrientationNotifier.h> 35 #include <WebCore/ProcessIdentity.h> 35 36 #include <WebCore/RealtimeMediaSource.h> 36 37 #include <WebCore/RealtimeMediaSourceIdentifier.h> … … 60 61 virtual Logger& logger() = 0; 61 62 virtual bool setCaptureAttributionString() { return true; } 62 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 63 virtual std::optional<task_id_token_t> webProcessIdentityToken() const { return { }; }; 64 #endif 63 virtual const WebCore::ProcessIdentity& resourceOwner() const = 0; 65 64 #if ENABLE(APP_PRIVACY_REPORT) 66 65 virtual void setTCCIdentity() { } -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r286800 r286838 217 217 } 218 218 219 const WebCore::ProcessIdentity& resourceOwner() const final 220 { 221 // FIXME: should obtain WebContent process identity from WebContent. 222 static NeverDestroyed<WebCore::ProcessIdentity> dummy; 223 return dummy.get(); 224 } 225 219 226 RefPtr<Logger> m_logger; 220 227 WebProcessProxy& m_process; -
trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h
r278253 r286838 32 32 #include <wtf/IsoMalloc.h> 33 33 34 namespace WebCore { 35 class ProcessIdentity; 36 } 37 34 38 namespace WebKit { 35 39 … … 62 66 void putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override; 63 67 68 void setOwnershipIdentity(const WebCore::ProcessIdentity&) { } 64 69 private: 65 70 unsigned bytesPerRow() const override; -
trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp
r284095 r286838 78 78 } 79 79 80 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 81 void ImageBufferShareableMappedIOSurfaceBackend::setProcessOwnership(task_id_token_t processIdentityToken) 80 void ImageBufferShareableMappedIOSurfaceBackend::setOwnershipIdentity(const WebCore::ProcessIdentity& resourceOwner) 82 81 { 83 82 ASSERT(surface()); 84 surface()->setOwnershipIdentity( processIdentityToken);83 surface()->setOwnershipIdentity(resourceOwner); 85 84 } 86 #endif87 85 88 86 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h
r273903 r286838 32 32 #include <wtf/IsoMalloc.h> 33 33 34 namespace WebCore { 35 class ProcessIdentity; 36 } 37 34 38 namespace WebKit { 35 39 … … 47 51 ImageBufferBackendHandle createImageBufferBackendHandle() const; 48 52 49 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY) 50 void setProcessOwnership(task_id_token_t); 51 #endif 53 void setOwnershipIdentity(const WebCore::ProcessIdentity&); 52 54 }; 53 55 -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r286590 r286838 1227 1227 void WebProcess::platformInitializeGPUProcessConnectionParameters(GPUProcessConnectionParameters& parameters) 1228 1228 { 1229 #if HAVE(TASK_IDENTITY_TOKEN) 1230 task_id_token_t identityToken; 1231 kern_return_t kr = task_create_identity_token(mach_task_self(), &identityToken); 1232 if (kr == KERN_SUCCESS) 1233 parameters.webProcessIdentityToken = MachSendRight::adopt(identityToken); 1234 else 1235 RELEASE_LOG_ERROR(Process, "Call to task_create_identity_token() failed: %{private}s (%x)", mach_error_string(kr), kr); 1236 #endif 1229 parameters.webProcessIdentity = ProcessIdentity { ProcessIdentity::CurrentProcess }; 1237 1230 1238 1231 parameters.overrideLanguages = userPreferredLanguagesOverride(); -
trunk/Tools/ChangeLog
r286836 r286838 1 2021-12-10 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 IOSurface memory attribution is hard to use in constructors 4 https://bugs.webkit.org/show_bug.cgi?id=232988 5 <rdar://problem/85541918> 6 7 Reviewed by Chris Dumez. 8 9 Update constructor calling base class constructor, add empty 10 ProcesseIdentity. 11 12 * TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm: 13 1 14 2021-12-09 Antoine Quint <graouts@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm
r286709 r286838 33 33 #import <WebCore/Color.h> 34 34 #import <WebCore/GraphicsContextGLCocoa.h> 35 #import <WebCore/ProcessIdentity.h> 35 36 #import <optional> 36 37 #import <wtf/HashSet.h> … … 68 69 attributes.alpha = true; 69 70 attributes.preserveDrawingBuffer = false; 70 auto context = WebCore::GraphicsContextGLCocoa::create(WTFMove(attributes) );71 auto context = WebCore::GraphicsContextGLCocoa::create(WTFMove(attributes), { }); 71 72 if (!context) 72 73 return nullptr; … … 120 121 attributes.useMetal = true; 121 122 EXPECT_EQ(attributes.powerPreference, WebCore::GraphicsContextGLPowerPreference::Default); 122 auto defaultContext = WebCore::GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes { attributes } );123 auto defaultContext = WebCore::GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes { attributes }, { }); 123 124 ASSERT_NE(defaultContext, nullptr); 124 125 125 126 attributes.powerPreference = WebCore::GraphicsContextGLPowerPreference::LowPower; 126 auto lowPowerContext = WebCore::GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes { attributes } );127 auto lowPowerContext = WebCore::GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes { attributes }, { }); 127 128 ASSERT_NE(lowPowerContext, nullptr); 128 129 129 130 attributes.powerPreference = WebCore::GraphicsContextGLPowerPreference::HighPerformance; 130 auto highPerformanceContext = WebCore::GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes { attributes } );131 auto highPerformanceContext = WebCore::GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes { attributes }, { }); 131 132 ASSERT_NE(highPerformanceContext, nullptr); 132 133
Note:
See TracChangeset
for help on using the changeset viewer.