Skip to content

Commit f6f4d72

Browse files
GPU process is terminated during debugging
https://bugs.webkit.org/show_bug.cgi?id=277731 rdar://133372529 Reviewed by Mike Wyrzykowski. GPU process would not be debuggable due to WCP timing out a send or wait to GPUP. This would cause following distinct problems - WCP would ask UI to terminate GPUP - Even if GPUP was not terminated, the WCP would already be in undefined state due to timing out a send or a wait. Add a setting ChildProcessDebuggabilityEnabled which should be set when the developer is intending to stop the GPU process in debugger. The added implementation will set stream IPC connection timeout to infinity. Later commits will modify other, less frequent normal IPC sendSync and wait timeouts. Run with: lldb -w -n GPU.Development -o c run-webkit-tests --internal-feature=ChildProcessDebuggabilityEnabled --no-timeout test.html run-minibrowser Set "Internal -> Child Process Debuggability" and restart * Source/WTF/Scripts/GeneratePreferences.rb: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: (WebKit::RemoteGraphicsContextGLProxy::create): * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: (WebKit::RemoteRenderingBackendProxy::ensureGPUProcessConnection): * Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp: (WebKit::RemoteGPUProxy::create): * Source/WebKit/WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): * Source/WebKit/WebProcess/WebProcess.cpp: (WebKit::WebProcess::gpuProcessTimeoutDuration const): (WebKit::WebProcess::setGPUProcessDebuggabilityEnabled): * Source/WebKit/WebProcess/WebProcess.h: Canonical link: https://commits.webkit.org/282280@main
1 parent 0e9bbd9 commit f6f4d72

File tree

8 files changed

+44
-7
lines changed

8 files changed

+44
-7
lines changed

Introduction.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ When debugging a debug build in LLDB, there are also a few functions that can be
202202
* showTreeForThis()
203203
* showNodePathForThis()
204204

205+
Debugging child processes such as GPU process, "Child Process Debuggability" internal feature must be in use. For the test runner, you can
206+
specify `run-webkit-tests --internal-feature=ChildProcessDebuggabilityEnabled`. For MiniBrowser, set the Debug > Internal > Child Process Debuggability
207+
menu item and restart.
208+
205209
## Correctness Testing in WebKit
206210

207211
WebKit is really big on test driven development, we have many types of tests.
@@ -1759,7 +1763,8 @@ You may want to specify OS_ACTIVITY_MODE environmental variable to “disable”
17591763
in order to suppress all the system logging that happens during the debugging session.
17601764

17611765
You may also want to specify `--no-timeout` option to prevent WebKitTestRunner or DumpRenderTree
1762-
to stop the test after 30 seconds if you’re stepping through code.
1766+
to stop the test after 30 seconds if you’re stepping through code. Specify additional
1767+
`--internal-feature=ChildProcessDebuggabilityEnabled` when stepping through child process such as GPU process.
17631768

17641769
Once this is done, you can run WebKitTestRunner or DumpRenderTree by going to Product > Perform Action > Run without Building.
17651770

Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,21 @@ CaretBrowsingEnabled:
17071707
WebCore:
17081708
default: false
17091709

1710+
ChildProcessDebuggabilityEnabled:
1711+
comment: Disables GPU process IPC timeouts
1712+
type: bool
1713+
status: internal
1714+
humanReadableName: "Child Process Debuggability"
1715+
humanReadableDescription: "Enable stopping child processes with a debugger"
1716+
exposed: [ WebKit ]
1717+
defaultValue:
1718+
WebKitLegacy:
1719+
default: false
1720+
WebKit:
1721+
default: false
1722+
WebCore:
1723+
default: false
1724+
17101725
ClearSiteDataHTTPHeaderEnabled:
17111726
type: bool
17121727
status: stable

Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ RefPtr<RemoteGraphicsContextGLProxy> RemoteGraphicsContextGLProxy::create(const
8181
{
8282
constexpr unsigned defaultConnectionBufferSizeLog2 = 21;
8383
unsigned connectionBufferSizeLog2 = defaultConnectionBufferSizeLog2;
84-
constexpr Seconds defaultTimeoutDuration = 30_s;
8584
if (attributes.failContextCreationForTesting == WebCore::GraphicsContextGLAttributes::SimulatedCreationFailure::IPCBufferOOM)
8685
connectionBufferSizeLog2 = 50; // Expect this to fail.
87-
auto connectionPair = IPC::StreamClientConnection::create(connectionBufferSizeLog2, defaultTimeoutDuration);
86+
auto connectionPair = IPC::StreamClientConnection::create(connectionBufferSizeLog2, WebProcess::singleton().gpuProcessTimeoutDuration());
8887
if (!connectionPair)
8988
return nullptr;
9089
auto [clientConnection, serverConnectionHandle] = WTFMove(*connectionPair);

Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ void RemoteRenderingBackendProxy::ensureGPUProcessConnection()
102102
{
103103
if (m_connection)
104104
return;
105-
static constexpr auto connectionBufferSizeLog2 = 21;
106-
auto connectionPair = IPC::StreamClientConnection::create(connectionBufferSizeLog2, defaultTimeout);
105+
constexpr unsigned connectionBufferSizeLog2 = 21u;
106+
auto connectionPair = IPC::StreamClientConnection::create(connectionBufferSizeLog2, WebProcess::singleton().gpuProcessTimeoutDuration());
107107
if (!connectionPair)
108108
CRASH();
109109
auto [streamConnection, serverHandle] = WTFMove(*connectionPair);

Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ RefPtr<RemoteGPUProxy> RemoteGPUProxy::create(WebGPU::ConvertToBackingContext& c
5757
RefPtr<RemoteGPUProxy> RemoteGPUProxy::create(WebGPU::ConvertToBackingContext& convertToBackingContext, RemoteRenderingBackendProxy& renderingBackend, SerialFunctionDispatcher& dispatcher)
5858
{
5959
constexpr size_t connectionBufferSizeLog2 = 21;
60-
constexpr Seconds defaultTimeoutDuration = 30_s;
61-
auto connectionPair = IPC::StreamClientConnection::create(connectionBufferSizeLog2, defaultTimeoutDuration);
60+
auto connectionPair = IPC::StreamClientConnection::create(connectionBufferSizeLog2, WebProcess::singleton().gpuProcessTimeoutDuration());
6261
if (!connectionPair)
6362
return nullptr;
6463
auto [clientConnection, serverConnectionHandle] = WTFMove(*connectionPair);

Source/WebKit/WebProcess/WebPage/WebPage.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4701,6 +4701,8 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
47014701
if (m_drawingArea)
47024702
m_drawingArea->updatePreferences(store);
47034703

4704+
WebProcess::singleton().setChildProcessDebuggabilityEnabled(store.getBoolValueForKey(WebPreferencesKey::childProcessDebuggabilityEnabledKey()));
4705+
47044706
#if ENABLE(GPU_PROCESS)
47054707
static_cast<WebMediaStrategy&>(platformStrategies()->mediaStrategy()).setUseGPUProcess(m_shouldPlayMediaInGPUProcess);
47064708
#if ENABLE(VIDEO)

Source/WebKit/WebProcess/WebProcess.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,12 @@ GPUProcessConnection& WebProcess::ensureGPUProcessConnection()
13771377
return *m_gpuProcessConnection;
13781378
}
13791379

1380+
Seconds WebProcess::gpuProcessTimeoutDuration() const
1381+
{
1382+
constexpr Seconds defaultTimeoutDuration = 15_s;
1383+
return m_childProcessDebuggabilityEnabled ? Seconds::infinity() : defaultTimeoutDuration;
1384+
}
1385+
13801386
void WebProcess::gpuProcessConnectionClosed()
13811387
{
13821388
ASSERT(m_gpuProcessConnection);
@@ -2212,6 +2218,11 @@ void WebProcess::updateDomainsWithStorageAccessQuirks(HashSet<WebCore::Registrab
22122218
m_domainsWithStorageAccessQuirks.add(domain);
22132219
}
22142220

2221+
void WebProcess::setChildProcessDebuggabilityEnabled(bool childProcessDebuggabilityEnabled)
2222+
{
2223+
m_childProcessDebuggabilityEnabled = childProcessDebuggabilityEnabled;
2224+
}
2225+
22152226
#if ENABLE(GPU_PROCESS)
22162227
void WebProcess::setUseGPUProcessForCanvasRendering(bool useGPUProcessForCanvasRendering)
22172228
{

Source/WebKit/WebProcess/WebProcess.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ class WebProcess : public AuxiliaryProcess
248248
#if ENABLE(GPU_PROCESS)
249249
GPUProcessConnection& ensureGPUProcessConnection();
250250
GPUProcessConnection* existingGPUProcessConnection() { return m_gpuProcessConnection.get(); }
251+
// Returns timeout duration for GPU process connections. Thread-safe.
252+
Seconds gpuProcessTimeoutDuration() const;
251253
void gpuProcessConnectionClosed();
252254
void gpuProcessConnectionDidBecomeUnresponsive();
253255

@@ -383,6 +385,8 @@ class WebProcess : public AuxiliaryProcess
383385
void updatePageScreenProperties();
384386
#endif
385387

388+
void setChildProcessDebuggabilityEnabled(bool);
389+
386390
#if ENABLE(GPU_PROCESS)
387391
void setUseGPUProcessForCanvasRendering(bool);
388392
void setUseGPUProcessForDOMRendering(bool);
@@ -805,6 +809,8 @@ class WebProcess : public AuxiliaryProcess
805809
RetainPtr<NSMutableDictionary> m_accessibilityRemoteFrameTokenCache;
806810
#endif
807811

812+
bool m_childProcessDebuggabilityEnabled { false };
813+
808814
#if ENABLE(GPU_PROCESS)
809815
bool m_useGPUProcessForCanvasRendering { false };
810816
bool m_useGPUProcessForDOMRendering { false };

0 commit comments

Comments
 (0)