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

Reduce refcount of SharedMemory when sending them over IPC. #971

Merged
merged 0 commits into from May 25, 2022

Conversation

jyavenard
Copy link
Member

@jyavenard jyavenard commented May 24, 2022

6a4bb0e

Reduce refcount of SharedMemory when sending them over IPC.
https://bugs.webkit.org/show_bug.cgi?id=240855
rdar://problem/93806688

Reviewed by Jer Noble.

In the future, we want to be able to donate memory with exclusive access to another process, this require the VM to have a refcount of 1.
No change in obeservable behaviour. Covered by existing tests.

* Source/WebKit/Shared/WebCoreArgumentCoders.cpp:
(IPC::encodeSharedBuffer):
* Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::getPasteboardBufferForType):
(WebKit::WebPasteboardProxy::readBufferFromPasteboard):
* Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.cpp:
(WebKit::RemoteMediaResourceProxy::dataReceived):
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::append):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::writeItemsToPasteboard):
* Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::declareAndWriteDragImage):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::performActionOnElement):
(WebKit::WebPage::didFinishLoadForQuickLookDocumentInMainFrame):
* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::getDataSelectionForPasteboard):

Canonical link: https://commits.webkit.org/250943@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

@jyavenard jyavenard self-assigned this May 24, 2022
@jyavenard jyavenard added Other WebKit2 Bugs relating to the WebKit2 API layer labels May 24, 2022
Comment on lines 87 to 92
{
auto sharedData = SharedMemory::copyBuffer(data);
sharedData->createHandle(handle, SharedMemory::Protection::ReadOnly);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This could just be SharedMemory::copyBuffer(data)->createHandle(handle, SharedMemory::Protection::ReadOnly); without the braces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, this is wrong; copyBuffer can return nullptr; we should null check here.

Copy link
Contributor

@jernoble jernoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with a nit inline.

@jyavenard jyavenard added the merge-queue Applied to send a pull request to merge-queue label May 25, 2022
@webkit-early-warning-system webkit-early-warning-system merged commit 6a4bb0e into WebKit:main May 25, 2022
@webkit-early-warning-system
Copy link
Collaborator

Committed r294784 (250943@main): https://commits.webkit.org/250943@main

Reviewed commits have been landed. Closing PR #971 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system removed the merge-queue Applied to send a pull request to merge-queue label May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit2 Bugs relating to the WebKit2 API layer
Projects
None yet
3 participants