Changeset 285177 in webkit
- Timestamp:
- Nov 2, 2021, 12:42:06 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
Platform/IPC/Connection.cpp (modified) (3 diffs)
-
Scripts/webkit/model.py (modified) (1 diff)
-
Scripts/webkit/tests/MessageNames.cpp (modified) (3 diffs)
-
Scripts/webkit/tests/MessageNames.h (modified) (1 diff)
-
UIProcess/Network/NetworkProcessProxy.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r285170 r285177 1 2021-11-02 Sihui Liu <sihui_liu@apple.com> 2 3 Terminate unresponsive network process by crashing it 4 https://bugs.webkit.org/show_bug.cgi?id=232603 5 6 Reviewed by Chris Dumez. 7 8 UI process currently kills network process when it does not respond message in some time (network process being 9 unresponsive). We've found one common case where network process becomes unresponsive is that it is blocked by 10 some slow operation on the main thread (like file operation in rdar://84511633). To understand what the 11 operations are and make a fix, we now ask network process to crash itself on IPC thread. In this way, we can get 12 crash report that includes the call stack of the main thread. To avoid generating too many crash reports, we 13 only send the crash message to network process when it becomes unresponsive multiple times in a short time 14 period. 15 16 * Platform/IPC/Connection.cpp: 17 (IPC::terminateDueToIPCTerminateMessage): 18 (IPC::Connection::processIncomingMessage): 19 * Scripts/webkit/model.py: 20 * Scripts/webkit/tests/MessageNames.cpp: 21 (IPC::description): 22 (IPC::receiverName): 23 (IPC::isValidMessageName): 24 * Scripts/webkit/tests/MessageNames.h: 25 * UIProcess/Network/NetworkProcessProxy.cpp: 26 (WebKit::shouldTerminateNetworkProcessBySendingMessage): 27 (WebKit::NetworkProcessProxy::didBecomeUnresponsive): 28 1 29 2021-11-02 Kate Cheney <katherine_cheney@apple.com> 2 30 -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r285159 r285177 43 43 #if PLATFORM(COCOA) 44 44 #include "MachMessage.h" 45 #include "WKCrashReporter.h" 45 46 #endif 46 47 … … 752 753 } 753 754 755 static NEVER_INLINE NO_RETURN_DUE_TO_CRASH void terminateDueToIPCTerminateMessage() 756 { 757 #if PLATFORM(COCOA) 758 WebKit::logAndSetCrashLogMessage("Receives Terminate message"); 759 #else 760 WTFLogAlways("Receives Terminate message"); 761 #endif 762 CRASH(); 763 } 764 754 765 void Connection::processIncomingMessage(std::unique_ptr<Decoder> message) 755 766 { … … 760 771 return; 761 772 } 773 774 if (message->messageName() == MessageName::Terminate) 775 return terminateDueToIPCTerminateMessage(); 762 776 763 777 if (!MessageReceiveQueueMap::isValidMessage(*message)) { -
trunk/Source/WebKit/Scripts/webkit/model.py
r273204 r285177 78 78 Message('LegacySessionState', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 79 79 Message('SetStreamDestinationID', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 80 Message('ProcessOutOfStreamMessage', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None) 80 Message('ProcessOutOfStreamMessage', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 81 Message('Terminate', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 81 82 ], condition=None) 82 83 -
trunk/Source/WebKit/Scripts/webkit/tests/MessageNames.cpp
r283702 r285177 157 157 case MessageName::SyncMessageReply: 158 158 return "SyncMessageReply"; 159 case MessageName::Terminate: 160 return "Terminate"; 159 161 case MessageName::TestWithSuperclass_TestAsyncMessageReply: 160 162 return "TestWithSuperclass_TestAsyncMessageReply"; … … 259 261 case MessageName::SetStreamDestinationID: 260 262 case MessageName::SyncMessageReply: 263 case MessageName::Terminate: 261 264 return ReceiverName::IPC; 262 265 case MessageName::TestWithSuperclass_TestAsyncMessageReply: … … 467 470 if (messageName == IPC::MessageName::SyncMessageReply) 468 471 return true; 472 if (messageName == IPC::MessageName::Terminate) 473 return true; 469 474 #if ENABLE(TEST_FEATURE) 470 475 if (messageName == IPC::MessageName::TestWithSuperclass_TestAsyncMessageReply) -
trunk/Source/WebKit/Scripts/webkit/tests/MessageNames.h
r279221 r285177 108 108 , SetStreamDestinationID 109 109 , SyncMessageReply 110 , Terminate 110 111 , TestWithSuperclass_TestAsyncMessageReply 111 112 , TestWithSuperclass_TestAsyncMessageWithConnectionReply -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r285121 r285177 88 88 89 89 static constexpr Seconds networkProcessResponsivenessTimeout = 6_s; 90 static constexpr int unresponsivenessCountLimit = 3; 91 static constexpr Seconds unresponsivenessCheckPeriod = 15_s; 90 92 91 93 static HashSet<NetworkProcessProxy*>& networkProcessesSet() … … 94 96 static NeverDestroyed<HashSet<NetworkProcessProxy*>> set; 95 97 return set; 98 } 99 100 static bool shouldTerminateNetworkProcessBySendingMessage() 101 { 102 static WallTime unresponsivenessPeriodStartTime = WallTime::now(); 103 static int unresponsivenessCountDuringThisPeriod = 0; 104 auto now = WallTime::now(); 105 106 if (now - unresponsivenessPeriodStartTime > unresponsivenessCheckPeriod) { 107 unresponsivenessCountDuringThisPeriod = 1; 108 unresponsivenessPeriodStartTime = now; 109 return false; 110 } 111 112 ++unresponsivenessCountDuringThisPeriod; 113 if (unresponsivenessCountDuringThisPeriod >= unresponsivenessCountLimit) 114 return true; 115 116 return false; 96 117 } 97 118 … … 129 150 { 130 151 RELEASE_LOG_ERROR(Process, "NetworkProcessProxy::didBecomeUnresponsive: NetworkProcess with PID %d became unresponsive, terminating it", processIdentifier()); 152 153 // Let network process terminates itself and generate crash report for investigation of hangs. 154 // We currently only do this when network process becomes unresponsive multiple times in a short 155 // time period to avoid generating too many crash reports with same back trace on user's device. 156 if (shouldTerminateNetworkProcessBySendingMessage()) { 157 sendMessage(makeUniqueRef<IPC::Encoder>(IPC::MessageName::Terminate, 0), { }); 158 RunLoop::main().dispatchAfter(1_s, [weakThis = WeakPtr { *this }] () mutable { 159 if (weakThis) 160 weakThis->terminate(); 161 }); 162 return; 163 } 164 131 165 terminate(); 132 166 }
Note:
See TracChangeset
for help on using the changeset viewer.