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

Drop SharedBuffer::data() in favor of span() #28798

Merged

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented May 20, 2024

24db6e6

Drop SharedBuffer::data() in favor of span()
https://bugs.webkit.org/show_bug.cgi?id=274401

Reviewed by Darin Adler.

* Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::sanitizeKeyids):
* Source/WebCore/Modules/encryptedmedia/MediaKeyStatusMap.cpp:
(WebCore::keyIdsMatch):
(WebCore::MediaKeyStatusMap::Iterator::next):
* Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::consumeFormDataAsStream):
* Source/WebCore/bindings/js/WebAssemblyCachedScriptSourceProvider.h:
* Source/WebCore/bindings/js/WebAssemblyScriptBufferSourceProvider.h:
* Source/WebCore/fileapi/FileReaderLoader.cpp:
(WebCore::FileReaderLoader::didReceiveData):
* Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::didReceiveData):
* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::dataReceived):
* Source/WebCore/platform/SharedBuffer.cpp:
(WebCore::SharedBufferDataView::createSharedBuffer const):
* Source/WebCore/platform/SharedBuffer.h:
(WebCore::SharedBufferDataView::span const):
(WebCore::SharedBuffer::dataAsCharPtr const): Deleted.
(WebCore::SharedBufferDataView::data const): Deleted.
(WebCore::SharedBufferDataView::dataAsCharPtr const): Deleted.
* Source/WebCore/platform/SharedMemory.h:
(WebCore::SharedMemory::wrapMap):
* Source/WebCore/platform/cocoa/MediaUtilities.cpp:
(WebCore::createAudioFormatDescription):
* Source/WebCore/platform/cocoa/MediaUtilities.h:
(WebCore::createAudioFormatDescription):
* Source/WebCore/platform/cocoa/SharedBufferCocoa.mm:
(-[WebCoreSharedBufferData bytes]):
* Source/WebCore/platform/cocoa/SharedMemoryCocoa.cpp:
(WebCore::SharedMemory::wrapMap):
* Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::extractKeyidsLocationFromCencInitData):
(WebCore::extractKeyidsFromCencInitData):
(WebCore::extractKeyIdFromWebMInitData):
* Source/WebCore/platform/graphics/ImageBackingStore.h:
(WebCore::ImageBackingStore::setSize):
(WebCore::ImageBackingStore::ImageBackingStore):
* Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::decodeUTI):
* Source/WebCore/platform/graphics/cocoa/CMUtilities.mm:
(WebCore::createAudioFormatDescription):
(WebCore::PacketDurationParser::PacketDurationParser):
* Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::WebMParser::VideoTrackData::consumeFrameData):
* Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h:
(WebCore::OpenType::validateTable):
(WebCore::OpenType::TableBase::isValidEnd):
* Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp:
* Source/WebCore/platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::readDataSync):
* Source/WebCore/workers/ScriptBuffer.cpp:
(WebCore::tryConvertToShareableResourceHandle):
* Source/WebCore/xml/XSLTProcessorLibxslt.cpp:
(WebCore::docLoaderFunc):
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::mediaPlayerKeyNeeded):
* Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp:
(WebKit::RemoteMediaRecorder::fetchData):
* Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::readData):
* Source/WebKit/NetworkProcess/storage/BackgroundFetchStoreImpl.cpp:
(WebKit::BackgroundFetchStoreImpl::initializeFetches):
* Source/WebKit/NetworkProcess/storage/CacheStorageDiskStore.cpp:
(WebKit::CacheStorageDiskStore::readRecordFromFileData):
* Source/WebKit/Platform/IPC/SharedBufferReference.cpp:
(IPC::SharedBufferReference::data const):
* Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp:
(API::getData):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadAlternateHTML):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::streamDidReceiveData):
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::finishedLoading):

Canonical link: https://commits.webkit.org/279097@main

9079799

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2   πŸ§ͺ wincairo-tests
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  wpe-cairo
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ gtk-wk2
loading πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ§ͺ api-gtk
βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim

@cdumez cdumez self-assigned this May 20, 2024
@cdumez cdumez added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label May 20, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 9ce861b to 34a8c16 Compare May 20, 2024 19:09
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 34a8c16 to 5a3cbf7 Compare May 20, 2024 19:15
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 5a3cbf7 to aefcd8d Compare May 20, 2024 19:35
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from aefcd8d to ce4ad6f Compare May 20, 2024 19:47
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from ce4ad6f to 0a5a21a Compare May 20, 2024 20:13
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 0a5a21a to 4192bfd Compare May 20, 2024 20:28
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 4192bfd to 9a81e8d Compare May 20, 2024 20:35
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 9a81e8d to cd56adf Compare May 20, 2024 20:49
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 20, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 47a14e8 to 2bea767 Compare May 21, 2024 04:10
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 2bea767 to 3f48b51 Compare May 21, 2024 05:03
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 21, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 21, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 3f48b51 to f21d320 Compare May 21, 2024 14:54
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 21, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 21, 2024
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from f21d320 to 51f341f Compare May 21, 2024 16:17
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 21, 2024
@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label May 21, 2024
@cdumez cdumez requested a review from darinadler May 21, 2024 21:54
@cdumez cdumez force-pushed the 274401_drop_SharedBuffer_data branch from 51f341f to 9079799 Compare May 21, 2024 21:57
@cdumez cdumez marked this pull request as ready for review May 21, 2024 21:57
@cdumez cdumez requested review from a team, philn, dcrousso and patrickangle as code owners May 21, 2024 21:57
@@ -194,7 +194,7 @@ std::optional<Vector<Ref<SharedBuffer>>> InitDataRegistry::extractKeyIDsCenc(con
#if USE(GSTREAMER)
bool isPlayReadySanitizedInitializationData(const SharedBuffer& buffer)
{
const char* protectionData = buffer.dataAsCharPtr();
auto* protectionData = reinterpret_cast<const char*>(buffer.span().data());
Copy link
Member

Choose a reason for hiding this comment

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

Damn, I really have to get my byteCast in.


auto sendRight = makeMemoryEntry(size, toVMAddress(data), protection, MACH_PORT_NULL);
auto sendRight = makeMemoryEntry(data.size(), toVMAddress(static_cast<void*>(const_cast<uint8_t*>(data.data()))), protection, MACH_PORT_NULL);
Copy link
Member

Choose a reason for hiding this comment

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

Is that static_cast really needed?

@@ -4428,7 +4428,7 @@ void MediaPlayerPrivateGStreamer::initializationDataEncountered(InitData&& initD

GST_DEBUG("scheduling initializationDataEncountered %s event of size %zu", initData.payloadContainerType().utf8().data(),
initData.payload()->size());
GST_MEMDUMP("init datas", reinterpret_cast<const uint8_t*>(initData.payload()->makeContiguous()->data()), initData.payload()->size());
GST_MEMDUMP("init datas", reinterpret_cast<const uint8_t*>(initData.payload()->makeContiguous()->span().data()), initData.payload()->size());
Copy link
Member

Choose a reason for hiding this comment

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

Why reinterpret_cast here? What type are we casting from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't look needed indeed.

@@ -98,7 +98,7 @@ Ref<MediaPromise> SourceBufferPrivateGStreamer::appendInternal(Ref<SharedBuffer>

ASSERT(!m_appendPromise);
m_appendPromise.emplace();
gpointer bufferData = const_cast<void*>(static_cast<const void*>(data->data()));
gpointer bufferData = const_cast<void*>(static_cast<const void*>(data->span().data()));
Copy link
Member

Choose a reason for hiding this comment

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

Should only need const_cast, not two casts, here.

@cdumez cdumez added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 22, 2024
https://bugs.webkit.org/show_bug.cgi?id=274401

Reviewed by Darin Adler.

* Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::sanitizeKeyids):
* Source/WebCore/Modules/encryptedmedia/MediaKeyStatusMap.cpp:
(WebCore::keyIdsMatch):
(WebCore::MediaKeyStatusMap::Iterator::next):
* Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::consumeFormDataAsStream):
* Source/WebCore/bindings/js/WebAssemblyCachedScriptSourceProvider.h:
* Source/WebCore/bindings/js/WebAssemblyScriptBufferSourceProvider.h:
* Source/WebCore/fileapi/FileReaderLoader.cpp:
(WebCore::FileReaderLoader::didReceiveData):
* Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::didReceiveData):
* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::dataReceived):
* Source/WebCore/platform/SharedBuffer.cpp:
(WebCore::SharedBufferDataView::createSharedBuffer const):
* Source/WebCore/platform/SharedBuffer.h:
(WebCore::SharedBufferDataView::span const):
(WebCore::SharedBuffer::dataAsCharPtr const): Deleted.
(WebCore::SharedBufferDataView::data const): Deleted.
(WebCore::SharedBufferDataView::dataAsCharPtr const): Deleted.
* Source/WebCore/platform/SharedMemory.h:
(WebCore::SharedMemory::wrapMap):
* Source/WebCore/platform/cocoa/MediaUtilities.cpp:
(WebCore::createAudioFormatDescription):
* Source/WebCore/platform/cocoa/MediaUtilities.h:
(WebCore::createAudioFormatDescription):
* Source/WebCore/platform/cocoa/SharedBufferCocoa.mm:
(-[WebCoreSharedBufferData bytes]):
* Source/WebCore/platform/cocoa/SharedMemoryCocoa.cpp:
(WebCore::SharedMemory::wrapMap):
* Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::extractKeyidsLocationFromCencInitData):
(WebCore::extractKeyidsFromCencInitData):
(WebCore::extractKeyIdFromWebMInitData):
* Source/WebCore/platform/graphics/ImageBackingStore.h:
(WebCore::ImageBackingStore::setSize):
(WebCore::ImageBackingStore::ImageBackingStore):
* Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::decodeUTI):
* Source/WebCore/platform/graphics/cocoa/CMUtilities.mm:
(WebCore::createAudioFormatDescription):
(WebCore::PacketDurationParser::PacketDurationParser):
* Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::WebMParser::VideoTrackData::consumeFrameData):
* Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h:
(WebCore::OpenType::validateTable):
(WebCore::OpenType::TableBase::isValidEnd):
* Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp:
* Source/WebCore/platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::readDataSync):
* Source/WebCore/workers/ScriptBuffer.cpp:
(WebCore::tryConvertToShareableResourceHandle):
* Source/WebCore/xml/XSLTProcessorLibxslt.cpp:
(WebCore::docLoaderFunc):
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::mediaPlayerKeyNeeded):
* Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp:
(WebKit::RemoteMediaRecorder::fetchData):
* Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::readData):
* Source/WebKit/NetworkProcess/storage/BackgroundFetchStoreImpl.cpp:
(WebKit::BackgroundFetchStoreImpl::initializeFetches):
* Source/WebKit/NetworkProcess/storage/CacheStorageDiskStore.cpp:
(WebKit::CacheStorageDiskStore::readRecordFromFileData):
* Source/WebKit/Platform/IPC/SharedBufferReference.cpp:
(IPC::SharedBufferReference::data const):
* Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp:
(API::getData):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadAlternateHTML):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::streamDidReceiveData):
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::finishedLoading):

Canonical link: https://commits.webkit.org/279097@main
@webkit-commit-queue
Copy link
Collaborator

Committed 279097@main (24db6e6): https://commits.webkit.org/279097@main

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

@webkit-commit-queue webkit-commit-queue merged commit 24db6e6 into WebKit:main May 22, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 22, 2024
@cdumez
Copy link
Contributor Author

cdumez commented May 22, 2024

Looks like I failed to upload my local follow-up changes (to address review comments) before merging the PR. I'm following up in #28895.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
5 participants