-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Minor refactoring of assertion code, v2 #19650
Minor refactoring of assertion code, v2 #19650
Conversation
EWS run on previous version of this PR (hash e20e1f2) |
e20e1f2
to
6bc0f8e
Compare
EWS run on previous version of this PR (hash 6bc0f8e) |
6bc0f8e
to
8963472
Compare
EWS run on previous version of this PR (hash 8963472) |
8963472
to
b19e985
Compare
EWS run on previous version of this PR (hash b19e985) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks fine, but I strongly recommend you restore the PID in the logging, as I've frequently needed this information to diagnose problem on users' devices from logs.
@@ -44,7 +44,7 @@ OBJC_CLASS WKRBSAssertionDelegate; | |||
|
|||
#if USE(EXTENSIONKIT_ASSERTIONS) | |||
OBJC_CLASS _SEExtensionProcess; | |||
OBJC_CLASS _SEGrant; | |||
OBJC_PROTOCOL(_SEGrant); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
#endif | ||
static Ref<ProcessAssertion> create(ProcessID, const String& reason, ProcessAssertionType, Mode = Mode::Async, const String& environmentIdentifier = emptyString(), CompletionHandler<void()>&& acquisisionHandler = nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Noticed an old typo here: acquisisionHandler
-> aquisitionHandler
{ | ||
m_watchdogTimer.startOneShot(interval); | ||
} | ||
|
||
void XPCConnectionTerminationWatchdog::watchdogTimerFired() | ||
{ | ||
terminateWithReason(m_xpcConnection.get(), ReasonCode::WatchdogTimerFired, "XPCConnectionTerminationWatchdog::watchdogTimerFired"); | ||
if (m_process && m_process->connection()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If m_process->connection()
exists, is the result of xpcConnection()
guaranteed to be a valid pointer? If so, why isn't it returning a reference?
It looks like methods such as Connection::getAuditToken()
check this value for nullptr. I think we should check connection's validity here before using it to terminate, unless the terminateWithReason
method expects the pointer might be nullptr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the implementation of xpc_connection_kill
uses the passed in argument without nullptr checking, so this would create crashes in some cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch! I added a null check before calling xpc_connection_kill
.
Thanks for reviewing!
|
||
void ProcessThrottler::didDisconnectFromProcess() | ||
{ | ||
PROCESSTHROTTLER_RELEASE_LOG_WITH_PID("didDisconnectFromProcess:", m_processID); | ||
PROCESSTHROTTLER_RELEASE_LOG("didDisconnectFromProcess:"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate the idea of losing this logging. Is there a way to determine the PID from the m_processProxy so we can keep this useful diagnostic information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
PROCESSTHROTTLER_RELEASE_LOG_WITH_PID("didDisconnectFromProcess:", m_processProxy ? m_processProxy->processID() : 0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro PROCESSTHROTTLER_RELEASE_LOG
actually logs the PID, so I believe we are good here.
b19e985
to
90fb10a
Compare
EWS run on previous version of this PR (hash 90fb10a) |
90fb10a
to
6f8231b
Compare
EWS run on current version of this PR (hash 6f8231b) |
https://bugs.webkit.org/show_bug.cgi?id=263797 rdar://117600174 Reviewed by Brent Fulgham. This patch contains some minor refactoring of assertions code: 1) Let ProcessAndUIAssertion create method take an AuxiliaryProcessProxy reference, instead of a PID. 2) Let XPCConnectionTerminationWatchdog hold on to a weak AuxiliaryProcessProxy pointer, instead of an XPC connection. 3) Let ProcessThrottler::didConnectToProcess take an AuxiliaryProcessProxy reference, instead of a PID. * Source/WebKit/Platform/cocoa/XPCUtilities.mm: (WebKit::terminateWithReason): * Source/WebKit/Platform/spi/Cocoa/ExtensionKitSPI.h: * Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp: (WebKit::AuxiliaryProcessProxy::didFinishLaunching): * Source/WebKit/UIProcess/Cocoa/AuxiliaryProcessProxyCocoa.mm: (WebKit::AuxiliaryProcessProxy::platformStartConnectionTerminationWatchdog): (WebKit::AuxiliaryProcessProxy::extensionProcess const): (WebKit::AuxiliaryProcessProxy::extensionProcess): Deleted. * Source/WebKit/UIProcess/Cocoa/ProcessAssertionCocoa.mm: (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion): * Source/WebKit/UIProcess/Cocoa/XPCConnectionTerminationWatchdog.h: * Source/WebKit/UIProcess/Cocoa/XPCConnectionTerminationWatchdog.mm: (WebKit::XPCConnectionTerminationWatchdog::startConnectionTerminationWatchdog): (WebKit::XPCConnectionTerminationWatchdog::XPCConnectionTerminationWatchdog): (WebKit::XPCConnectionTerminationWatchdog::watchdogTimerFired): * Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp: (WebKit::GPUProcessProxy::didFinishLaunching): * Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::didFinishLaunching): * Source/WebKit/UIProcess/ProcessAssertion.h: * Source/WebKit/UIProcess/ProcessThrottler.cpp: (WebKit::ProcessThrottler::setThrottleState): (WebKit::ProcessThrottler::updateThrottleStateIfNeeded): (WebKit::ProcessThrottler::didConnectToProcess): (WebKit::ProcessThrottler::didDisconnectFromProcess): (WebKit::ProcessThrottler::sendPrepareToSuspendIPC): (WebKit::ProcessThrottler::setShouldTakeNearSuspendedAssertion): (WebKit::ProcessThrottler::isSuspended const): (WebKit::ProcessThrottlerActivity::ProcessThrottlerActivity): (WebKit::ProcessThrottlerActivity::invalidate): * Source/WebKit/UIProcess/ProcessThrottler.h: (WebKit::ProcessThrottler::isSuspended const): Deleted. (WebKit::ProcessThrottlerActivity::ProcessThrottlerActivity): Deleted. (WebKit::ProcessThrottlerActivity::invalidate): Deleted. * Source/WebKit/UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::updateAudibleMediaAssertions): * Source/WebKit/UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::didFinishLaunching): (WebKit::WebProcessProxy::updateAudibleMediaAssertions): Canonical link: https://commits.webkit.org/270212@main
6f8231b
to
5d6df46
Compare
Committed 270212@main (5d6df46): https://commits.webkit.org/270212@main Reviewed commits have been landed. Closing PR #19650 and removing active labels. |
5d6df46
6f8231b
π§ͺ wpe-wk2π§ͺ gtk-wk2