Source/WebKit2/ChangeLog

 12012-12-18 Kiran Muppala <cmuppala@apple.com>
 2
 3 Adopt new assertion SPI for process suppression on Mac
 4 https://bugs.webkit.org/show_bug.cgi?id=105378
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Process suppression for WebKit2 child processes is currently enabled or disabled using AutomaticTermination.
 9 This should be replaced with a new assertion SPI specific to process suppression.
 10
 11 * Shared/ChildProcess.cpp:
 12 (WebKit::ChildProcess::ChildProcess): Remove unused member variable m_applicationIsOccluded.
 13 The occlusion state is now captured by m_processAssertionVisible.
 14 * Shared/ChildProcess.h:
 15 * Shared/mac/ChildProcessMac.mm:
 16 (WebKit::ChildProcess::setApplicationIsOccluded): Use m_processAssertionVisible to check if the occlusion
 17 state has changed and call enable/disableProcessSuppression() accordingly.
 18 (WebKit::ChildProcess::disableProcessSuppression): Take assertion using the new WKSI SPI wrapper function
 19 WKGetNSProcessInfoProcessAssertionVisible().
 20 (WebKit::ChildProcess::enableProcessSuppression): Release assertion retained by m_processAssertionVisible.
 21 (WebKit::ChildProcess::platformInitialize): Remove call to initializeTimerCoalescingPolicy(), since taking
 22 a process visible assertion also sets the timer coalescing policy appropriately.
 23
1242012-12-17 Sam Weinig <sam@webkit.org>
225
326 Try to fix the Mac build.

Source/WebKit2/Shared/ChildProcess.cpp

@@ChildProcess::ChildProcess()
6060 : m_terminationTimeout(0)
6161 , m_terminationCounter(0)
6262 , m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired)
63 #if PLATFORM(MAC)
64  , m_applicationIsOccluded(false)
65 #endif
6663{
6764 // FIXME: The termination timer should not be scheduled on the main run loop.
6865 // It won't work with the threaded mode, but it's not really useful anyway as is.

Source/WebKit2/Shared/ChildProcess.h

2828
2929#include "Connection.h"
3030#include <WebCore/RunLoop.h>
 31#include <wtf/RetainPtr.h>
3132
3233#if PLATFORM(MAC)
3334OBJC_CLASS NSString;

@@public:
6263 };
6364
6465#if PLATFORM(MAC)
65  bool applicationIsOccluded() const { return m_applicationIsOccluded; }
6666 void setApplicationIsOccluded(bool);
6767#endif
6868

@@private:
8181 virtual void terminate();
8282
8383#if PLATFORM(MAC)
84  void disableProcessSuppression(NSString *reason);
85  void enableProcessSuppression(NSString *reason);
86 
87  static NSString * const processSuppressionVisibleApplicationReason;
 84 void disableProcessSuppression();
 85 void enableProcessSuppression();
8886#endif
8987
9088 void platformInitialize();

@@private:
10098 WebCore::RunLoop::Timer<ChildProcess> m_terminationTimer;
10199
102100#if PLATFORM(MAC)
103  bool m_applicationIsOccluded;
 101 RetainPtr<id> m_processAssertionVisible;
104102#endif
105103};
106104

Source/WebKit2/Shared/mac/ChildProcessMac.mm

2626#import "config.h"
2727#import "ChildProcess.h"
2828
 29#import "WebKitSystemInterface.h"
2930#import <mach/task.h>
3031
3132namespace WebKit {
3233
33 NSString * const ChildProcess::processSuppressionVisibleApplicationReason = @"Application is Visible";
34 
3534void ChildProcess::setApplicationIsOccluded(bool applicationIsOccluded)
3635{
37  if (m_applicationIsOccluded == applicationIsOccluded)
 36 if (static_cast<bool>(m_processAssertionVisible) == !applicationIsOccluded)
3837 return;
3938
4039#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
41  m_applicationIsOccluded = applicationIsOccluded;
42  if (m_applicationIsOccluded)
43  enableProcessSuppression(processSuppressionVisibleApplicationReason);
 40 if (applicationIsOccluded)
 41 enableProcessSuppression();
4442 else
45  disableProcessSuppression(processSuppressionVisibleApplicationReason);
 43 disableProcessSuppression();
4644#endif
4745}
4846
49 void ChildProcess::disableProcessSuppression(NSString *reason)
 47void ChildProcess::disableProcessSuppression()
5048{
5149#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
52  // The following assumes that a process enabling AutomaticTerminationSupport also
53  // takes a AutomaticTermination assertion for the lifetime of the process.
54  [[NSProcessInfo processInfo] disableAutomaticTermination:reason];
 50 if (!m_processAssertionVisible)
 51 m_processAssertionVisible = WKGetNSProcessInfoProcessAssertionVisible();
5552#endif
5653}
5754
58 void ChildProcess::enableProcessSuppression(NSString *reason)
 55void ChildProcess::enableProcessSuppression()
5956{
6057#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
61  // The following assumes that a process enabling AutomaticTerminationSupport also
62  // takes a AutomaticTermination assertion for the lifetime of the process.
63  [[NSProcessInfo processInfo] enableAutomaticTermination:reason];
 58 m_processAssertionVisible.clear();
6459#endif
6560}
6661
67 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
68 static void initializeTimerCoalescingPolicy()
69 {
70  // Set task_latency and task_throughput QOS tiers as appropriate for a visible application.
71  struct task_qos_policy qosinfo = { LATENCY_QOS_TIER_0, THROUGHPUT_QOS_TIER_0 };
72  kern_return_t kr = task_policy_set(mach_task_self(), TASK_BASE_QOS_POLICY, (task_policy_t)&qosinfo, TASK_QOS_POLICY_COUNT);
73  ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
74 }
75 #endif
76 
7762void ChildProcess::platformInitialize()
7863{
7964#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
8065 setpriority(PRIO_DARWIN_PROCESS, 0, 0);
81  initializeTimerCoalescingPolicy();
8266#endif
83  disableProcessSuppression(processSuppressionVisibleApplicationReason);
 67 disableProcessSuppression();
8468}
8569
8670}

WebKitLibraries/ChangeLog

 12012-12-18 Kiran Muppala <cmuppala@apple.com>
 2
 3 Adopt new assertion SPI for process suppression on Mac
 4 https://bugs.webkit.org/show_bug.cgi?id=105378
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add WKGetNSProcessInfoProcessAssertionVisible().
 9
 10 * WebKitSystemInterface.h:
 11
1122012-12-12 Roger Fong <roger_fong@apple.com>
213
314 Enable VIDEO_TRACK on Windows.

WebKitLibraries/WebKitSystemInterface.h

@@typedef void (*WKOcclusionNotificationHandler)(uint32_t, void*, uint32_t, void*,
530530
531531bool WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
532532bool WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
 533
 534id WKGetNSProcessInfoProcessAssertionVisible(void);
533535#endif
534536
535537bool WKIsJavaPlugInActive(void);