Skip to content

Commit

Permalink
Introduce a <model> loading process - Part 2
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=243874
rdar://122051588 (Create new com.apple.WebKit.Model process)

Reviewed by Alex Christensen.

In order to allow parsing of complex 3D model formats with a custom (tight)
sandbox, introduce a separate process for loading/parsing <model>s.

This is part 2 of the effort, where we hook up the new Model* classes from
existing classes. ENABLE_MODEL_PROCESS is now turned on for visionOS.
The new process doesn't exist yet. The actual rendering flow is not changed yet.
Certain changes were to accommodate for the new plan of having a single ModelProcess
across the system instead of having one ModelProcess for each WebProcess.

* Source/WTF/wtf/PlatformEnableCocoa.h:
Enables MODEL_PROCESS for visionOS.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebCore/platform/RuntimeApplicationChecks.cpp:
(WebCore::processTypeDescription):
* Source/WebCore/platform/RuntimeApplicationChecks.h:
* Source/WebKit/ModelProcess/EntryPoint/Cocoa/XPCService/ModelServiceEntryPoint.mm: Copied from Source/WebKit/UIProcess/WebContextClient.h.
(WebKit::ModelServiceInitializerDelegate::ModelServiceInitializerDelegate):
(WebKit::initializeAuxiliaryProcess<ModelProcess>):
(MODEL_SERVICE_INITIALIZER):
* Source/WebKit/ModelProcess/cocoa/ModelProcessCocoa.mm: Copied from Source/WebKit/Platform/ExtraPrivateSymbolsForTAPI.h.
(WebKit::ModelProcess::notifyPreferencesChanged):
(WebKit::ModelProcess::dispatchSimulatedNotificationsForPreferenceChange):
* Source/WebKit/ModelProcess/ios/ModelProcessIOS.mm: Copied from Source/WebKit/Platform/ExtraPrivateSymbolsForTAPI.h.
(WebKit::ModelProcess::initializeProcess):
(WebKit::ModelProcess::initializeProcessName):
(WebKit::ModelProcess::initializeSandbox):
* Source/WebKit/Platform/ExtraPrivateSymbolsForTAPI.h:
* Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.mm:
(WebKit::isInWebKitChildProcess):
* Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
* Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
* Source/WebKit/Shared/RemoteLayerTree/DynamicContentScalingImageBufferBackend.mm:
(WebKit::DynamicContentScalingImageBufferBackend::createBackendHandle const):
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _modelProcessIdentifier]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp:
(WebKit::AuxiliaryProcessProxy::getLaunchOptions):
* Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h:
* Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm:
(WebKit::PageClientImplCocoa::modelProcessDidFinishLaunching):
(WebKit::PageClientImplCocoa::modelProcessDidExit):
* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::didCreateContextInModelProcessForVisibilityPropagation):
* Source/WebKit/UIProcess/Launcher/ProcessLauncher.h:
* Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm:
(WebKit::serviceName):
* Source/WebKit/UIProcess/Model/ModelProcessProxy.cpp:
(WebKit::singleton):
(WebKit::ModelProcessProxy::getOrCreate):
(WebKit::ModelProcessProxy::singletonIfCreated):
(WebKit::ModelProcessProxy::ModelProcessProxy):
(WebKit::ModelProcessProxy::modelProcessExited):
(WebKit::ModelProcessProxy::didFinishLaunching):
(WebKit::ModelProcessProxy::updateProcessAssertion):
(WebKit::ModelProcessProxy::create): Deleted.
* Source/WebKit/UIProcess/Model/ModelProcessProxy.h:
* Source/WebKit/UIProcess/PageClient.h:
(WebKit::PageClient::didCreateContextInModelProcessForVisibilityPropagation):
(WebKit::PageClient::modelProcessDidFinishLaunching):
(WebKit::PageClient::modelProcessDidExit):
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::didCreateContextInModelProcessForVisibilityPropagation):
* Source/WebKit/UIProcess/ProvisionalPageProxy.h:
(WebKit::ProvisionalPageProxy::contextIDForVisibilityPropagationInModelProcess const):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::modelProcessID const):
(WebKit::WebPageProxy::modelProcessDidFinishLaunching):
(WebKit::WebPageProxy::modelProcessExited):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::m_resetModelProcessCrashCountTimer):
(WebKit::WebProcessPool::ensureModelProcess):
(WebKit::WebProcessPool::ensureProtectedModelProcess):
(WebKit::WebProcessPool::modelProcessDidFinishLaunching):
(WebKit::WebProcessPool::modelProcessExited):
(WebKit::WebProcessPool::createModelProcessConnection):
(WebKit::WebProcessPool::updateProcessAssertions):
* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::createModelProcessConnection):
(WebKit::WebProcessProxy::modelProcessDidFinishLaunching):
(WebKit::WebProcessProxy::modelProcessExited):
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didCreateContextInModelProcessForVisibilityPropagation):
(WebKit::PageClientImpl::modelProcessDidExit):
* Source/WebKit/UIProcess/ios/WKContentView.h:
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _setupVisibilityPropagationViewForModelProcess]):
(-[WKContentView _removeVisibilityPropagationViewForModelProcess]):
(-[WKContentView _modelProcessDidExit]):
(-[WKContentView _didRelaunchProcess]):
(-[WKContentView _modelProcessDidCreateContextForVisibilityPropagation]):
(-[WKContentView _createVisibilityPropagationView]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Model/ModelProcessConnection.h:
* Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.h: Added.
(WebKit::ModelProcessModelPlayer::page):
(WebKit::ModelProcessModelPlayer::client):
* Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.mm: Added.
(WebKit::ModelProcessModelPlayer::create):
(WebKit::ModelProcessModelPlayer::ModelProcessModelPlayer):
(WebKit::ModelProcessModelPlayer::~ModelProcessModelPlayer):
(WebKit::ModelProcessModelPlayer::load):
(WebKit::ModelProcessModelPlayer::sizeDidChange):
(WebKit::ModelProcessModelPlayer::layer):
(WebKit::ModelProcessModelPlayer::handleMouseDown):
(WebKit::ModelProcessModelPlayer::handleMouseMove):
(WebKit::ModelProcessModelPlayer::handleMouseUp):
(WebKit::ModelProcessModelPlayer::enterFullscreen):
(WebKit::ModelProcessModelPlayer::getCamera):
(WebKit::ModelProcessModelPlayer::setCamera):
(WebKit::ModelProcessModelPlayer::isPlayingAnimation):
(WebKit::ModelProcessModelPlayer::setAnimationIsPlaying):
(WebKit::ModelProcessModelPlayer::isLoopingAnimation):
(WebKit::ModelProcessModelPlayer::setIsLoopingAnimation):
(WebKit::ModelProcessModelPlayer::animationDuration):
(WebKit::ModelProcessModelPlayer::animationCurrentTime):
(WebKit::ModelProcessModelPlayer::setAnimationCurrentTime):
(WebKit::ModelProcessModelPlayer::hasAudio):
(WebKit::ModelProcessModelPlayer::isMuted):
(WebKit::ModelProcessModelPlayer::setIsMuted):
(WebKit::ModelProcessModelPlayer::accessibilityChildren):
* Source/WebKit/WebProcess/Model/WebModelPlayerProvider.cpp:
(WebKit::WebModelPlayerProvider::createModelPlayer):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::modelProcessConnectionDidBecomeAvailable):
(WebKit::WebPage::~WebPage):
(WebKit::WebPage::updatePreferences):
(WebKit::WebPage::configureLoggingChannel):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureModelProcessConnection):
(WebKit::WebProcess::modelProcessConnectionClosed):
* Source/WebKit/WebProcess/WebProcess.h:
(WebKit::WebProcess::existingModelProcessConnection):

Canonical link: https://commits.webkit.org/274185@main
  • Loading branch information
eddydas authored and achristensen07 committed Feb 7, 2024
1 parent c0b07c4 commit 48ace7f
Show file tree
Hide file tree
Showing 44 changed files with 963 additions and 44 deletions.
14 changes: 14 additions & 0 deletions Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Expand Up @@ -4708,6 +4708,20 @@ ModelElementEnabled:
WebCore:
default: false

ModelProcessEnabled:
type: bool
status: unstable
condition: ENABLE(MODEL_PROCESS)
humanReadableName: "Enable Model Process"
humanReadableDescription: "Load <model> content in a separate process"
defaultValue:
WebKitLegacy:
default: false
WebKit:
default: false
WebCore:
default: false

MomentumScrollingAnimatorEnabled:
type: bool
status: internal
Expand Down
3 changes: 3 additions & 0 deletions Source/WTF/wtf/PlatformEnableCocoa.h
Expand Up @@ -1009,3 +1009,6 @@
#define ENABLE_WINDOW_PROXY_PROPERTY_ACCESS_NOTIFICATION 1
#endif

#if !defined(ENABLE_MODEL_PROCESS) && PLATFORM(VISION)
#define ENABLE_MODEL_PROCESS 1
#endif
4 changes: 4 additions & 0 deletions Source/WebCore/platform/RuntimeApplicationChecks.cpp
Expand Up @@ -108,6 +108,10 @@ const char* processTypeDescription(std::optional<AuxiliaryProcessType> type)
#if ENABLE(GPU_PROCESS)
case AuxiliaryProcessType::GPU:
return "GPU";
#endif
#if ENABLE(MODEL_PROCESS)
case AuxiliaryProcessType::Model:
return "Model";
#endif
}
return "Unknown";
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/platform/RuntimeApplicationChecks.h
Expand Up @@ -40,6 +40,9 @@ enum class AuxiliaryProcessType : uint8_t {
#if ENABLE(GPU_PROCESS)
GPU,
#endif
#if ENABLE(MODEL_PROCESS)
Model,
#endif
};

WEBCORE_EXPORT void setAuxiliaryProcessType(AuxiliaryProcessType);
Expand Down
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"

#import "EnvironmentUtilities.h"
#import "ModelProcess.h"
#import "WKBase.h"
#import "XPCServiceEntryPoint.h"

#if ENABLE(MODEL_PROCESS)

namespace WebKit {

class ModelServiceInitializerDelegate : public XPCServiceInitializerDelegate {
public:
ModelServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
: XPCServiceInitializerDelegate(WTFMove(connection), initializerMessage)
{
}
};

template<>
void initializeAuxiliaryProcess<ModelProcess>(AuxiliaryProcessInitializationParameters&& parameters)
{
static NeverDestroyed<ModelProcess> modelProcess(WTFMove(parameters));
}

} // namespace WebKit

#endif // ENABLE(MODEL_PROCESS)

extern "C" WK_EXPORT void MODEL_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage);

void MODEL_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage)
{
WTF::initializeMainThread();

#if ENABLE(MODEL_PROCESS)
WebKit::XPCServiceInitializer<WebKit::ModelProcess, WebKit::ModelServiceInitializerDelegate>(connection, initializerMessage);
#endif // ENABLE(MODEL_PROCESS)
}
52 changes: 52 additions & 0 deletions Source/WebKit/ModelProcess/cocoa/ModelProcessCocoa.mm
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#import "config.h"
#import "ModelProcess.h"

#if ENABLE(MODEL_PROCESS)

#import "ModelConnectionToWebProcess.h"
#import <wtf/RetainPtr.h>

namespace WebKit {
using namespace WebCore;

#if ENABLE(CFPREFS_DIRECT_MODE)
void ModelProcess::notifyPreferencesChanged(const String& domain, const String& key, const std::optional<String>& encodedValue)
{
preferenceDidUpdate(domain, key, encodedValue);
}

void ModelProcess::dispatchSimulatedNotificationsForPreferenceChange(const String& key)
{
}
#endif // ENABLE(CFPREFS_DIRECT_MODE)

} // namespace WebKit

#endif // ENABLE(MODEL_PROCESS)
56 changes: 56 additions & 0 deletions Source/WebKit/ModelProcess/ios/ModelProcessIOS.mm
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "ModelProcess.h"

#if ENABLE(MODEL_PROCESS)

#import "ModelProcessCreationParameters.h"
#import "ModelProcessProxyMessages.h"
#import "SandboxInitializationParameters.h"
#import <WebCore/NotImplemented.h>
#import <WebCore/WebCoreThreadSystemInterface.h>

namespace WebKit {
using namespace WebCore;

void ModelProcess::initializeProcess(const AuxiliaryProcessInitializationParameters&)
{
InitWebCoreThreadSystemInterface();
}

void ModelProcess::initializeProcessName(const AuxiliaryProcessInitializationParameters&)
{
notImplemented();
}

void ModelProcess::initializeSandbox(const AuxiliaryProcessInitializationParameters&, SandboxInitializationParameters&)
{
}

} // namespace WebKit

#endif // ENABLE(MODEL_PROCESS)
1 change: 1 addition & 0 deletions Source/WebKit/Platform/ExtraPrivateSymbolsForTAPI.h
Expand Up @@ -35,6 +35,7 @@ extern "C" {
void NetworkServiceInitializer();
void WebContentServiceInitializer();
void GPUServiceInitializer();
void ModelServiceInitializer();

void ExtensionEventHandler(xpc_connection_t);

Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.mm
Expand Up @@ -72,6 +72,9 @@ static bool isInWebKitChildProcess()
isInSubProcess = [bundleIdentifier hasPrefix:@"com.apple.WebKit.WebContent"]
|| [bundleIdentifier hasPrefix:@"com.apple.WebKit.Networking"]
|| [bundleIdentifier hasPrefix:@"com.apple.WebKit.GPU"];
#if ENABLE(MODEL_PROCESS)
isInSubProcess = isInSubProcess || [bundleIdentifier hasPrefix:@"com.apple.WebKit.Model"];
#endif
});

return isInSubProcess;
Expand Down
Expand Up @@ -46,6 +46,7 @@ extern "C" OS_NOTHROW void voucher_replace_default_voucher(void);
#define WEBCONTENT_SERVICE_INITIALIZER WebContentServiceInitializer
#define NETWORK_SERVICE_INITIALIZER NetworkServiceInitializer
#define GPU_SERVICE_INITIALIZER GPUServiceInitializer
#define MODEL_SERVICE_INITIALIZER ModelServiceInitializer

namespace WebKit {

Expand Down
Expand Up @@ -167,6 +167,8 @@ void XPCServiceEventHandler(xpc_connection_t peer)
entryPointFunctionName = CFSTR(STRINGIZE_VALUE_OF(NETWORK_SERVICE_INITIALIZER));
else if (!strcmp(serviceName, "com.apple.WebKit.GPU"))
entryPointFunctionName = CFSTR(STRINGIZE_VALUE_OF(GPU_SERVICE_INITIALIZER));
else if (!strcmp(serviceName, "com.apple.WebKit.Model"))
entryPointFunctionName = CFSTR(STRINGIZE_VALUE_OF(MODEL_SERVICE_INITIALIZER));
else {
RELEASE_LOG_ERROR(IPC, "XPCServiceEventHandler: Unexpected 'service-name': %{public}s", serviceName);
return;
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/SourcesCocoa.txt
Expand Up @@ -77,6 +77,10 @@ GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp
GPUProcess/webrtc/LibWebRTCCodecsProxy.mm @no-unify
GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererInternalUnitManager.cpp

ModelProcess/EntryPoint/Cocoa/XPCService/ModelServiceEntryPoint.mm
ModelProcess/cocoa/ModelProcessCocoa.mm
ModelProcess/ios/ModelProcessIOS.mm

Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
Platform/classifier/ResourceLoadStatisticsClassifier.cpp

Expand Down Expand Up @@ -674,6 +678,7 @@ WebProcess/Inspector/mac/WebInspectorUIMac.mm
WebProcess/MediaCache/WebMediaKeyStorageManager.cpp

WebProcess/Model/ARKitInlinePreviewModelPlayer.mm
WebProcess/Model/ModelProcessModelPlayer.mm
WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm
WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm

Expand Down
9 changes: 9 additions & 0 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Expand Up @@ -2924,6 +2924,15 @@ - (pid_t)_gpuProcessIdentifier
return _page->gpuProcessID();
}

- (pid_t)_modelProcessIdentifier
{
if (![self _isValid])
return 0;

return _page->modelProcessID();
}


- (BOOL)_webProcessIsResponsive
{
return _page->process().isResponsive();
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Expand Up @@ -184,6 +184,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) {
@property (nonatomic, readonly) pid_t _webProcessIdentifier;
@property (nonatomic, readonly) pid_t _provisionalWebProcessIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
@property (nonatomic, readonly) pid_t _gpuProcessIdentifier WK_API_AVAILABLE(macos(13.0), ios(16.0));
@property (nonatomic, readonly) pid_t _modelProcessIdentifier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

@property (nonatomic, getter=_isEditable, setter=_setEditable:) BOOL _editable WK_API_AVAILABLE(macos(10.11), ios(9.0));

Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
Expand Up @@ -141,6 +141,11 @@ void AuxiliaryProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& lau
varname = "GPU_PROCESS_CMD_PREFIX";
break;
#endif
#if ENABLE(MODEL_PROCESS)
case ProcessLauncher::ProcessType::Model:
varname = "MODEL_PROCESS_CMD_PREFIX";
break;
#endif
#if ENABLE(BUBBLEWRAP_SANDBOX)
case ProcessLauncher::ProcessType::DBusProxy:
ASSERT_NOT_REACHED();
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h
Expand Up @@ -60,6 +60,11 @@ class PageClientImplCocoa : public PageClient {
void gpuProcessDidExit() override;
#endif

#if ENABLE(MODEL_PROCESS)
void modelProcessDidFinishLaunching() override;
void modelProcessDidExit() override;
#endif

void themeColorWillChange() final;
void themeColorDidChange() final;
void underPageBackgroundColorWillChange() final;
Expand Down
14 changes: 14 additions & 0 deletions Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
Expand Up @@ -173,6 +173,20 @@
}
#endif

#if ENABLE(MODEL_PROCESS)
void PageClientImplCocoa::modelProcessDidFinishLaunching()
{
[m_webView willChangeValueForKey:@"_modelProcessIdentifier"];
[m_webView didChangeValueForKey:@"_modelProcessIdentifier"];
}

void PageClientImplCocoa::modelProcessDidExit()
{
[m_webView willChangeValueForKey:@"_modelProcessIdentifier"];
[m_webView didChangeValueForKey:@"_modelProcessIdentifier"];
}
#endif

WebCore::DictationContext PageClientImplCocoa::addDictationAlternatives(PlatformTextAlternatives *alternatives)
{
return m_alternativeTextUIController->addAlternatives(alternatives);
Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
Expand Up @@ -522,6 +522,14 @@ static bool exceedsRenderTreeSizeSizeThreshold(uint64_t thresholdSize, uint64_t
pageClient().didCreateContextInGPUProcessForVisibilityPropagation(contextID);
}
#endif // ENABLE(GPU_PROCESS)

#if ENABLE(MODEL_PROCESS)
void WebPageProxy::didCreateContextInModelProcessForVisibilityPropagation(LayerHostingContextID contextID)
{
m_contextIDForVisibilityPropagationInModelProcess = contextID;
pageClient().didCreateContextInModelProcessForVisibilityPropagation(contextID);
}
#endif // ENABLE(MODEL_PROCESS)
#endif // HAVE(VISIBILITY_PROPAGATION_VIEW)

#if ENABLE(MEDIA_USAGE)
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
Expand Up @@ -81,6 +81,9 @@ class ProcessLauncher : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<P
#endif
#if ENABLE(BUBBLEWRAP_SANDBOX)
DBusProxy,
#endif
#if ENABLE(MODEL_PROCESS)
Model,
#endif
};

Expand Down
Expand Up @@ -135,6 +135,10 @@ static void launchWithExtensionKit(ProcessLauncher& processLauncher, ProcessLaun
#if ENABLE(GPU_PROCESS)
case ProcessLauncher::ProcessType::GPU:
return "com.apple.WebKit.GPU";
#endif
#if ENABLE(MODEL_PROCESS)
case ProcessLauncher::ProcessType::Model:
return "com.apple.WebKit.Model";
#endif
}
}
Expand Down

0 comments on commit 48ace7f

Please sign in to comment.