Changeset 250329 in webkit


Ignore:
Timestamp:
Sep 24, 2019 6:56:50 PM (5 years ago)
Author:
Chris Dumez
Message:

[iOS] Regression(r249703) frequent 'kill() returned unexpected error' log messages
https://bugs.webkit.org/show_bug.cgi?id=202173

Reviewed by Geoffrey Garen.

The kill(pid, 0) command actually fails with an EPERM error when there is a process
running with the given pid, and this is causing us to log a lot of errors. The good
news is that we merely want to know that there is no process with the given PID and
we correctly get a ESRCH error in this case. I renamed the function from
isRunningProcessPID() to wasTerminated() and only check for ESRCH error now. I no
longer log any error otherwise since this is expected.

Also, for performance reason, I no longer call kill(pid, 0) from inside
AuxiliaryProcessProxy::state() as it gets called a lot. I instead only call it from
AuxiliaryProcessProxy::wasTerminated() and call it from
WebProcessPool::tryTakePrewarmedProcess().

  • UIProcess/AuxiliaryProcessProxy.cpp:

(WebKit::AuxiliaryProcessProxy::state const):
(WebKit::AuxiliaryProcessProxy::wasTerminated const):
(WebKit::AuxiliaryProcessProxy::isRunningProcessPID): Deleted.

  • UIProcess/AuxiliaryProcessProxy.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::tryTakePrewarmedProcess):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r250328 r250329  
     12019-09-24  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Regression(r249703) frequent 'kill() returned unexpected error' log messages
     4        https://bugs.webkit.org/show_bug.cgi?id=202173
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        The kill(pid, 0) command actually fails with an EPERM error when there is a process
     9        running with the given pid, and this is causing us to log a lot of errors. The good
     10        news is that we merely want to know that there is no process with the given PID and
     11        we correctly get a ESRCH error in this case. I renamed the function from
     12        isRunningProcessPID() to wasTerminated() and only check for ESRCH error now. I no
     13        longer log any error otherwise since this is expected.
     14
     15        Also, for performance reason, I no longer call kill(pid, 0) from inside
     16        AuxiliaryProcessProxy::state() as it gets called a lot. I instead only call it from
     17        AuxiliaryProcessProxy::wasTerminated() and call it from
     18        WebProcessPool::tryTakePrewarmedProcess().
     19
     20        * UIProcess/AuxiliaryProcessProxy.cpp:
     21        (WebKit::AuxiliaryProcessProxy::state const):
     22        (WebKit::AuxiliaryProcessProxy::wasTerminated const):
     23        (WebKit::AuxiliaryProcessProxy::isRunningProcessPID): Deleted.
     24        * UIProcess/AuxiliaryProcessProxy.h:
     25        * UIProcess/WebProcessPool.cpp:
     26        (WebKit::WebProcessPool::tryTakePrewarmedProcess):
     27
    1282019-09-24  Christopher Reid  <chris.reid@sony.com>
    229
  • trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp

    r250110 r250329  
    112112        return AuxiliaryProcessProxy::State::Launching;
    113113
    114     // There is sometimes a delay until we get the notification from mach about the connection getting closed.
    115     // To help detect terminated process earlier, we also check that the PID is for a valid running process.
    116     if (!m_connection || !isRunningProcessPID(processIdentifier()))
     114    if (!m_connection)
    117115        return AuxiliaryProcessProxy::State::Terminated;
    118116
     
    120118}
    121119
    122 bool AuxiliaryProcessProxy::isRunningProcessPID(ProcessID pid)
    123 {
     120bool AuxiliaryProcessProxy::wasTerminated() const
     121{
     122    switch (state()) {
     123    case AuxiliaryProcessProxy::State::Launching:
     124        return false;
     125    case AuxiliaryProcessProxy::State::Terminated:
     126        return true;
     127    case AuxiliaryProcessProxy::State::Running:
     128        break;
     129    }
     130
     131    auto pid = processIdentifier();
    124132    if (!pid)
    125         return false;
     133        return true;
    126134
    127135#if PLATFORM(COCOA)
    128     // Use kill() with a signal of 0 to check if there is actually still a process with the given PID.
    129     if (!kill(pid, 0))
    130         return true;
    131 
    132     if (errno == ESRCH) {
    133         // No process can be found corresponding to that specified by pid.
    134         return false;
    135     }
    136 
    137     RELEASE_LOG_ERROR(Process, "kill() returned unexpected error %d", errno);
    138     return true;
     136    // Use kill() with a signal of 0 to make sure there is indeed still a process with the given PID.
     137    // This is needed because it sometimes takes a little bit of time for us to get notified that a process
     138    // was terminated.
     139    return kill(pid, 0) && errno == ESRCH;
    139140#else
    140     UNUSED_PARAM(pid);
    141     return true;
     141    return false;
    142142#endif
    143143}
  • trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h

    r250110 r250329  
    100100    State state() const;
    101101    bool isLaunching() const { return state() == State::Launching; }
     102    bool wasTerminated() const;
    102103
    103104    ProcessID processIdentifier() const { return m_processLauncher ? m_processLauncher->processIdentifier() : 0; }
     
    125126    virtual void connectionWillOpen(IPC::Connection&);
    126127    virtual void processWillShutDown(IPC::Connection&) = 0;
    127     static bool isRunningProcessPID(ProcessID);
    128128
    129129    struct PendingMessage {
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r250321 r250329  
    808808    // There is sometimes a delay until we get notified that a prewarmed process has been terminated (e.g. after resuming
    809809    // from suspension) so make sure the process is still running here before deciding to use it.
    810     if (m_prewarmedProcess->state() == AuxiliaryProcessProxy::State::Terminated) {
     810    if (m_prewarmedProcess->wasTerminated()) {
    811811        RELEASE_LOG_ERROR(Process, "Not using prewarmed process %d because it has been terminated", m_prewarmedProcess->processIdentifier());
    812812        m_prewarmedProcess = nullptr;
Note: See TracChangeset for help on using the changeset viewer.