Changeset 202696 in webkit
- Timestamp:
- Jun 30, 2016 1:17:30 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r202695 r202696 1 2016-06-30 Chris Dumez <cdumez@apple.com> 2 3 [iOS] Process suspension is prevented for 30 seconds after closing a tab 4 https://bugs.webkit.org/show_bug.cgi?id=159280 5 <rdar://problem/27014867> 6 7 Reviewed by Gavin Barraclough. 8 9 When closing a tab, ConnectionTerminationWatchdog takes a background 10 assertion on behalf of the WebContent process and only releases it 11 after 30 seconds, allowing for the WebContent process to exit cleanly 12 without worrying about getting suspended too early. 13 14 However, the child process normally exits much sooner than this and 15 we end up holding a process assertion for no reason for a full 30 16 seconds anyway. This patch addresses the issue by registering an 17 invalidation handler with the BKSProcessAssertion and releasing our 18 our assertion in such case. The invalidation handler gets called 19 as soon as the child process exits. 20 21 * Platform/spi/ios/AssertionServicesSPI.h: 22 * UIProcess/ProcessAssertion.cpp: 23 (WebKit::ProcessAssertion::ProcessAssertion): 24 * UIProcess/ProcessAssertion.h: 25 (WebKit::ProcessAssertion::ProcessAssertion): 26 (WebKit::ProcessAssertion::validity): 27 * UIProcess/ios/ProcessAssertionIOS.mm: 28 (WebKit::ProcessAssertion::ProcessAssertion): 29 (WebKit::ProcessAssertion::~ProcessAssertion): 30 (WebKit::ProcessAndUIAssertion::updateRunInBackgroundCount): 31 (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion): 32 (WebKit::ProcessAssertion::setState): Deleted. 33 1 34 2016-06-30 Tim Horton <timothy_horton@apple.com> 2 35 -
trunk/Source/WebKit2/Platform/spi/ios/AssertionServicesSPI.h
r187609 r202696 73 73 typedef uint32_t BKSProcessAssertionReason; 74 74 75 typedef void (^BKSProcessAssertionInvalidationHandler)(void); 75 76 typedef void (^BKSProcessAssertionAcquisitionHandler)(BOOL acquired); 76 77 … … 81 82 @property (nonatomic, assign) BKSProcessAssertionFlags flags; 82 83 - (id)initWithPID:(pid_t)pid flags:(BKSProcessAssertionFlags)flags reason:(BKSProcessAssertionReason)reason name:(NSString *)name withHandler:(BKSProcessAssertionAcquisitionHandler)handler; 84 85 @property (nonatomic, copy) BKSProcessAssertionInvalidationHandler invalidationHandler; 83 86 - (void)invalidate; 84 87 @end -
trunk/Source/WebKit2/UIProcess/ProcessAssertion.cpp
r184105 r202696 31 31 namespace WebKit { 32 32 33 ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState )33 ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState, std::function<void()>) 34 34 : m_assertionState(assertionState) 35 35 { -
trunk/Source/WebKit2/UIProcess/ProcessAssertion.h
r202690 r202696 27 27 #define ProcessAssertion_h 28 28 29 #include <functional> 30 29 31 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) 30 32 #include <wtf/RetainPtr.h> … … 48 50 class ProcessAssertion { 49 51 public: 50 ProcessAssertion(pid_t, AssertionState );52 ProcessAssertion(pid_t, AssertionState, std::function<void()> invalidationCallback = { }); 51 53 ~ProcessAssertion(); 52 54 … … 57 59 void setState(AssertionState); 58 60 61 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) 62 protected: 63 enum class Validity { No, Yes, Unset }; 64 Validity validity() const { return m_validity; } 65 #endif 66 59 67 private: 60 68 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) 61 69 RetainPtr<BKSProcessAssertion> m_assertion; 70 Validity m_validity { Validity::Unset }; 62 71 #endif 63 72 AssertionState m_assertionState; -
trunk/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm
r202690 r202696 144 144 } 145 145 146 ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState) 147 { 148 m_assertionState = assertionState; 149 146 ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState, std::function<void()> invalidationCallback) 147 : m_assertionState(assertionState) 148 { 150 149 BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) { 151 150 if (!acquired) { 152 LOG_ ERROR("Unable to acquire assertion for process %d", pid);151 LOG_ALWAYS_ERROR(true, "Unable to acquire assertion for process %d", pid); 153 152 ASSERT_NOT_REACHED(); 153 m_validity = Validity::No; 154 invalidationCallback(); 154 155 } 155 156 }; 156 157 m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:BKSProcessAssertionReasonExtension name:@"Web content visible" withHandler:handler]); 158 m_assertion.get().invalidationHandler = ^() { 159 m_validity = Validity::No; 160 invalidationCallback(); 161 }; 157 162 } 158 163 159 164 ProcessAssertion::~ProcessAssertion() 160 165 { 166 m_assertion.get().invalidationHandler = nil; 167 161 168 if (ProcessAssertionClient* client = this->client()) 162 169 [[WKProcessAssertionBackgroundTaskManager shared] removeClient:*client]; … … 175 182 void ProcessAndUIAssertion::updateRunInBackgroundCount() 176 183 { 177 bool shouldHoldBackgroundAssertion = state() != AssertionState::Suspended;184 bool shouldHoldBackgroundAssertion = validity() != Validity::No && state() != AssertionState::Suspended; 178 185 179 186 if (shouldHoldBackgroundAssertion) { … … 189 196 190 197 ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, AssertionState assertionState) 191 : ProcessAssertion(pid, assertionState )198 : ProcessAssertion(pid, assertionState, [this] { updateRunInBackgroundCount(); }) 192 199 { 193 200 updateRunInBackgroundCount(); … … 220 227 namespace WebKit { 221 228 222 ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState )229 ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState, std::function<void()>) 223 230 : m_assertionState(assertionState) 224 231 {
Note: See TracChangeset
for help on using the changeset viewer.