[webkit-changes] [WebKit/WebKit] a44305: Add logging definition file for OS log entries tha...

Per Arne Vollan noreply at github.com
Wed Dec 11 05:57:35 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a443055848fd199a509bfb778e40094d32822c53
      https://github.com/WebKit/WebKit/commit/a443055848fd199a509bfb778e40094d32822c53
  Author: Per Arne Vollan <pvollan at apple.com>
  Date:   2024-12-11 (Wed, 11 Dec 2024)

  Changed paths:
    M Source/WTF/wtf/PlatformEnableCocoa.h
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/DerivedSources-input.xcfilelist
    M Source/WebCore/DerivedSources-output.xcfilelist
    M Source/WebCore/DerivedSources.make
    M Source/WebCore/Headers.cmake
    A Source/WebCore/Scripts/generate-log-declarations.py
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/html/HTMLMediaElement.cpp
    M Source/WebCore/html/HTMLVideoElement.cpp
    M Source/WebCore/loader/DocumentLoader.cpp
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/ProgressTracker.cpp
    M Source/WebCore/loader/ResourceLoader.cpp
    M Source/WebCore/loader/SubresourceLoader.cpp
    A Source/WebCore/platform/LogClient.h
    A Source/WebCore/platform/LogMessages.in
    M Source/WebCore/platform/Logging.cpp
    M Source/WebCore/platform/Logging.h
    M Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
    M Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm
    M Source/WebKit/CMakeLists.txt
    M Source/WebKit/DerivedSources-input.xcfilelist
    M Source/WebKit/DerivedSources-output.xcfilelist
    M Source/WebKit/DerivedSources.make
    A Source/WebKit/Platform/LogClient.cpp
    A Source/WebKit/Platform/LogClient.h
    A Source/WebKit/Platform/LogMessages.in
    M Source/WebKit/Platform/Logging.h
    M Source/WebKit/Platform/Sources.txt
    M Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in
    A Source/WebKit/Scripts/generate-derived-log-sources.py
    M Source/WebKit/Scripts/generate-message-receiver.py
    M Source/WebKit/Scripts/process-entitlements.sh
    M Source/WebKit/Shared/API/c/mac/WKWebArchiveResource.cpp
    M Source/WebKit/Shared/APIWebArchiveResource.h
    M Source/WebKit/Shared/APIWebArchiveResource.mm
    M Source/WebKit/Shared/LogStream.cpp
    M Source/WebKit/Shared/LogStream.h
    M Source/WebKit/Shared/WTFArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm
    M Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm
    M Source/WebKit/UIProcess/WebProcessProxy.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
    M Source/WebKit/WebProcess/Network/WebResourceLoader.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
    M Source/WebKit/WebProcess/WebProcess.h
    M Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm
    M Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
    M Source/WebKit/WebProcess/com.apple.WebProcess.sb.in

  Log Message:
  -----------
  Add logging definition file for OS log entries that should be forwarded from the WebContent process to the UI process
rdar://137601908
https://bugs.webkit.org/show_bug.cgi?id=282115

Reviewed by Chris Dumez.

Currently, we are forwarding preprocessed OS logs as strings from the WebContent process to the UI process in Lockdown Mode,
where they are sent to the logging daemon. Logging preprocessed strings is effectively disabling an important log size
optimization in the logging system. To preserve this optimization, all logging should use a literal format string, and
provide the data arguments when using the OS log API. This patch resolves this by adding logging definition files that are
used to generate code to send IPC messages from the WebContent process to the UI process, where the OS log API is called
with a literal format string, and the arguments provided over IPC. This patch adds one logging definition file for WebCore,
and one for WebKit, both with the name LogMessages.in.

This is the current format of the logging definition file:

<Identifier>, <Format string>, <Parameters>, <Log type (DEFAULT, INFO, ERROR, FAULT)>, <Category (Default, Process, Loading, etc)>

Here is an example:

DOCUMENTLOADER_STOPLOADING, "[pageID=%llu, frameID=%llu, isMainFrame=%d] DocumentLoader::stopLoading", (uint64_t, uint64_t, int), DEFAULT, Network

To add logging in the WebContent process that will be forwarded to the UI process in the efficient way, you will need
to add an entry to one of the logging definition files, and then pass the identifier to one of the new logging macros
- RELEASE_LOG_FORWARDABLE, RELEASE_LOG_ERROR_FORWARDABLE, etc.

Based on the logging definition files, the file LogStream.messages.in is generated. This file is used as input to the
standard script that generates code to send messages over IPC. The log forwarding is using streaming IPC, which is
based on shared memory, and is very efficient.

Additionally, two new log client classes are created, WebCore::LogClient and WebKit::LogClient. The scripts added in this
patch will generate virtual functions in these classes for every log message in the definitions file. Using one of the
new logging macros (RELEASE_LOG_FORWARDABLE, etc.), will result in calling one of these virtual functions, which will
send the IPC to the UI process. WebKit::LogClient is inheriting from WebCore::LogClient, and is implementing the sending
of IPC for both WebCore and WebKit logs.

This patch enables log forwarding for all Cocoa platforms, not just in Lockdown Mode.

Page load benchmarks results are neutral with this change for the configurations tested so far, and the sample count
is also neutral in PLT, which indicates that there should be no power regression from this change. Power benchmark
results are neutral on both iOS and macOS.

* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::m_remote):
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::insertedIntoAncestor):
(WebCore::HTMLMediaElement::didFinishInsertingNode):
(WebCore::HTMLMediaElement::removedFromAncestor):
(WebCore::HTMLMediaElement::currentMediaTime const):
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
(WebCore::HTMLMediaElement::mediaPlayerRateChanged):
(WebCore::HTMLMediaElement::mediaPlayerEngineUpdated):
(WebCore::HTMLMediaElement::updatePlayState):
(WebCore::HTMLMediaElement::visibilityStateChanged):
(WebCore::HTMLMediaElement::setShouldDelayLoadEvent):
(WebCore::HTMLMediaElement::setBufferingPolicy):
* Source/WebCore/html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::mediaPlayerRenderingModeChanged):
* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::stopLoading):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::startLoadingMainResource):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::changeLocation):
(WebCore::FrameLoader::loadURLIntoChildFrame):
(WebCore::FrameLoader::prepareForLoadStart):
(WebCore::FrameLoader::loadFrameRequest):
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithNavigationAction):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::stopAllLoaders):
(WebCore::FrameLoader::setDocumentLoader):
(WebCore::FrameLoader::setPolicyDocumentLoader):
(WebCore::FrameLoader::setProvisionalDocumentLoader):
(WebCore::FrameLoader::setState):
(WebCore::FrameLoader::transitionToCommitted):
(WebCore::FrameLoader::checkLoadCompleteForThisFrame):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
* Source/WebCore/loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::progressStarted):
(WebCore::ProgressTracker::progressCompleted):
(WebCore::ProgressTracker::finalProgressComplete):
* Source/WebCore/loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequestInternal):
* Source/WebCore/loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequestInternal):
(WebCore::SubresourceLoader::didReceiveResponse):
(WebCore::SubresourceLoader::didFinishLoading):
(WebCore::SubresourceLoader::didFail):
(WebCore::SubresourceLoader::willCancel):
* Source/WebCore/platform/Logging.cpp:
(WebCore::logClient):
* Source/WebCore/platform/Logging.h:
* Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::addSession):
(WebCore::PlatformMediaSessionManager::removeSession):
(WebCore::PlatformMediaSessionManager::sessionWillEndPlayback):
(WebCore::PlatformMediaSessionManager::sessionCanProduceAudioChanged):
(WebCore::PlatformMediaSessionManager::maybeActivateAudioSession):
* Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::updateSessionState):
(WebCore::MediaSessionManagerCocoa::clientCharacteristicsChanged):
(WebCore::MediaSessionManagerCocoa::sessionCanProduceAudioChanged):
* Source/WebKit/CMakeLists.txt:
* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Platform/IPC/StreamServerConnection.cpp:
(IPC::StreamServerConnection::didReceiveInvalidMessage):
* Source/WebKit/Platform/Logging.h:
* Source/WebKit/Platform/Sources.txt:
* Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in:
* Source/WebKit/Scripts/generate-message-receiver.py:
(main):
* Source/WebKit/Scripts/process-entitlements.sh:
* Source/WebKit/Shared/API/c/mac/WKWebArchiveResource.cpp:
(WKWebArchiveResourceCopyURL):
(WKWebArchiveResourceCopyMIMEType):
* Source/WebKit/Shared/APIWebArchiveResource.h:
* Source/WebKit/Shared/APIWebArchiveResource.mm:
(API::WebArchiveResource::create):
(API::WebArchiveResource::WebArchiveResource):
(API::WebArchiveResource::url):
(API::WebArchiveResource::mimeType):
(API::WebArchiveResource::textEncoding):
(API::WebArchiveResource::URL): Deleted.
(API::WebArchiveResource::MIMEType): Deleted.
* Source/WebKit/Shared/LogStream.cpp:
(WebKit::LogStream::~LogStream):
(WebKit::LogStream::setup):
* Source/WebKit/Shared/LogStream.h:
(WebKit::LogStream::create):
* Source/WebKit/Shared/WTFArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::setupLogStream):
* Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm:
(WebKit::ProcessLauncher::finishLaunchingProcess):
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
* Source/WebKit/WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::WebResourceLoader):
(WebKit::WebResourceLoader::willSendRequest):
(WebKit::WebResourceLoader::didReceiveResponse):
(WebKit::WebResourceLoader::didReceiveData):
(WebKit::WebResourceLoader::didFinishResourceLoad):
(WebKit::WebResourceLoader::serviceWorkerDidNotHandle):
(WebKit::WebResourceLoader::didFailResourceLoad):
(WebKit::WebResourceLoader::didBlockAuthenticationChallenge):
(WebKit::WebResourceLoader::stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied):
(WebKit::WebResourceLoader::didReceiveResource):
* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::navigationActionData const):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* Source/WebKit/WebProcess/WebProcess.h:
* Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm:
(WebKit::LaunchServicesDatabaseManager::handleEvent):
(WebKit::LaunchServicesDatabaseManager::waitForDatabaseUpdate):
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
(WebKit::WebProcess::setupLogStream):
(WebKit::WebProcess::sendLogOnStream):
* Source/WebKit/WebProcess/com.apple.WebProcess.sb.in:

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list