RESOLVED FIXED 220663
[GPUProcess] Mark IOSurface backing for ImageBufferBackends as owned by the WebProcess
https://bugs.webkit.org/show_bug.cgi?id=220663
Summary [GPUProcess] Mark IOSurface backing for ImageBufferBackends as owned by the W...
Chris Dumez
Reported 2021-01-15 12:08:18 PST
Claim ownership of IOSurface backing for ImageBufferBackends in the WebProcess. If we don't do this, all IOSurface memory gets attributed to the GPUProcess, making it a prime candidate for jetsam. We need to attribute memory usage to the WebProcesses being served by the GPUProcess as much as possible and this is a step in this direction.
Attachments
Patch (5.92 KB, patch)
2021-01-15 12:11 PST, Chris Dumez
no flags
Patch (4.29 KB, patch)
2021-01-15 12:42 PST, Chris Dumez
ews-feeder: commit-queue-
Patch (4.33 KB, patch)
2021-01-15 12:53 PST, Chris Dumez
ews-feeder: commit-queue-
Patch (5.16 KB, patch)
2021-01-15 13:13 PST, Chris Dumez
no flags
WIP Patch (14.30 KB, patch)
2021-01-15 17:52 PST, Chris Dumez
no flags
WIP Patch (14.31 KB, patch)
2021-01-19 09:03 PST, Chris Dumez
ews-feeder: commit-queue-
Patch (22.01 KB, patch)
2021-01-19 09:58 PST, Chris Dumez
ews-feeder: commit-queue-
Patch (23.89 KB, patch)
2021-01-19 10:04 PST, Chris Dumez
ggaren: review+
Patch (5.16 KB, patch)
2021-01-19 14:06 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2021-01-15 12:11:47 PST
Tim Horton
Comment 2 2021-01-15 12:16:29 PST
Comment on attachment 417719 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417719&action=review > Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:52 > + if (result != kIOReturnSuccess) This should be in ImageBufferShareableMappedIOSurfaceBackend, and /only/ in ImageBufferShareableMappedIOSurfaceBackend. ImageBufferShareableIOSurfaceBackend (the unmapped variant) by definition must not IOSurfaceLookupFromMachPort.
jared
Comment 3 2021-01-15 12:18:21 PST Comment hidden (spam)
Chris Dumez
Comment 4 2021-01-15 12:19:30 PST
(In reply to Tim Horton from comment #2) > Comment on attachment 417719 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=417719&action=review > > > Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:52 > > + if (result != kIOReturnSuccess) > > This should be in ImageBufferShareableMappedIOSurfaceBackend, and /only/ in > ImageBufferShareableMappedIOSurfaceBackend. > ImageBufferShareableIOSurfaceBackend (the unmapped variant) by definition > must not IOSurfaceLookupFromMachPort. This means that with DOM rendering enabled, we will not have a short term fix for view tiles. I understand that in the long term, we want to stop using IOSurface in the WebProcess. However, in the short term, my proposal was to do this (which works for now).
Tim Horton
Comment 5 2021-01-15 12:28:17 PST
Comment on attachment 417719 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417719&action=review >>> Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:52 >>> + if (result != kIOReturnSuccess) >> >> This should be in ImageBufferShareableMappedIOSurfaceBackend, and /only/ in ImageBufferShareableMappedIOSurfaceBackend. ImageBufferShareableIOSurfaceBackend (the unmapped variant) by definition must not IOSurfaceLookupFromMachPort. > > This means that with DOM rendering enabled, we will not have a short term fix for view tiles. I understand that in the long term, we want to stop using IOSurface in the WebProcess. However, in the short term, my proposal was to do this (which works for now). Like I said on Slack (but will write here for wider audience), if you want to do this, you should just make DOM use the mapped backend (temporarily) instead of making the non-mapped case map the surfaces :)
Chris Dumez
Comment 6 2021-01-15 12:42:49 PST
Chris Dumez
Comment 7 2021-01-15 12:53:18 PST
Chris Dumez
Comment 8 2021-01-15 13:13:14 PST
Chris Dumez
Comment 9 2021-01-15 17:52:17 PST
Created attachment 417752 [details] WIP Patch Ok, I have it working from the GPUProcess this time (no need for IOSurface calls in the WebProcess at all). Much better solution for the long term. I still need to do some clean up: It may look nicer to transfer the ownership in RemoteRenderingBackend::createImageBuffer() or somewhere else that has access to both the PID and IOSurface, instead of doing it in RemoteRenderingBackend::didCreateImageBufferBackend(). Doing it in RemoteRenderingBackend::didCreateImageBufferBackend() is convenient but it needs I need to look up the IOSurface from the handle again.
Chris Dumez
Comment 10 2021-01-19 09:03:38 PST
Created attachment 417879 [details] WIP Patch
Chris Dumez
Comment 11 2021-01-19 09:58:01 PST
Chris Dumez
Comment 12 2021-01-19 10:04:29 PST
Geoffrey Garen
Comment 13 2021-01-19 11:29:10 PST
Comment on attachment 417884 [details] Patch r=me
Geoffrey Garen
Comment 14 2021-01-19 11:38:38 PST
Comment on attachment 417884 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417884&action=review > Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb:910 > +(allow mach-priv-task-port) We probably need to find a way to reduce the scope of sandbox change here. This is relatively high privilege thing.
Geoffrey Garen
Comment 15 2021-01-19 13:45:38 PST
Comment on attachment 417727 [details] Patch r=me
Chris Dumez
Comment 16 2021-01-19 13:49:05 PST
One API test failure on open source api bot: TestWebKitAPI.GPUProcess.CanvasBasicCrashHandling dyld: lazy symbol binding failed: Symbol not found: _IOSurfaceSetOwnership Referenced from: /Volumes/Data/worker/API-Tests-iOS-Simulator-EWS/build/WebKitBuild/Release-iphonesimulator/WebKit.framework/WebKit Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/IOSurface.framework/IOSurface dyld: Symbol not found: _IOSurfaceSetOwnership Referenced from: /Volumes/Data/worker/API-Tests-iOS-Simulator-EWS/build/WebKitBuild/Release-iphonesimulator/WebKit.framework/WebKit Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/IOSurface.framework/IOSurface
Chris Dumez
Comment 17 2021-01-19 14:06:51 PST
EWS
Comment 18 2021-01-19 16:07:44 PST
Committed r271627: <https://trac.webkit.org/changeset/271627> All reviewed patches have been landed. Closing bug and clearing flags on attachment 417912 [details].
Radar WebKit Bug Importer
Comment 19 2021-01-19 16:08:14 PST
Note You need to log in before you can comment on or make changes to this bug.