Changeset 166443 in webkit
- Timestamp:
- Mar 28, 2014, 6:15:49 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166442 r166443 1 2014-03-28 Stephanie Lewis <slewis@apple.com> 2 3 Rename pluginDidEvaluate to better represent when it’s called. 4 Part of <rdar://problem/16061257> PluginProcess should AppNap when no plugins on active tab. 5 6 Reviewed by Anders Carlsson. 7 8 No new test because it’s just a name change. 9 10 * page/PageThrottler.h: 11 (WebCore::PageThrottler::pluginDidEvaluateWhileAudioIsPlaying): 12 1 13 2014-03-28 Stephanie Lewis <slewis@apple.com> 2 14 -
trunk/Source/WebCore/page/PageThrottler.h
r164948 r166443 48 48 49 49 void didReceiveUserInput() { m_hysteresis.impulse(); } 50 void pluginDidEvaluate () { m_hysteresis.impulse(); }50 void pluginDidEvaluateWhileAudioIsPlaying() { m_hysteresis.impulse(); } 51 51 std::unique_ptr<PageActivityAssertionToken> mediaActivityToken(); 52 52 std::unique_ptr<PageActivityAssertionToken> pageLoadActivityToken(); -
trunk/Source/WebKit2/ChangeLog
r166441 r166443 1 2014-03-28 Stephanie Lewis <slewis@apple.com> 2 3 Stop waking up the web process in the background because of plugin activity. 4 Part of <rdar://problem/16061257> PluginProcess should AppNap when no plugins on active tab. 5 6 Reviewed by Anders Carlsson. 7 8 Plugin activity in the background can constantly wake up web processes. This is only 9 necessary when audio is playing to support web apps like Pandora and youtube playing 10 in the background. Use a new api in CoreAudio to see if there is audio playing in 11 the PluginProcess. 12 13 * PluginProcess/PluginProcess.cpp: 14 (WebKit::PluginProcess::PluginProcess): Add a AudioHardwareListener 15 (WebKit::PluginProcess::createWebProcessConnection): tell web process current state 16 (WebKit::PluginProcess::audioHardwareDidBecomeActive): respond to audio hardware notifications 17 (WebKit::PluginProcess::audioHardwareDidBecomeInactive): 18 * PluginProcess/PluginProcess.h: 19 * PluginProcess/WebProcessConnection.cpp: tell WebProcess when audio state in PluginProcess 20 changes. 21 (WebKit::WebProcessConnection::audioHardwareDidBecomeActive): 22 (WebKit::WebProcessConnection::audioHardwareDidBecomeInactive): 23 * PluginProcess/WebProcessConnection.h: 24 * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp: 25 Only invoke pageThrottler activity when playing audio 26 (WebKit::NPRuntimeObjectMap::evaluate): 27 * WebProcess/Plugins/Plugin.h: add function to get audio state 28 (WebKit::Plugin::audioIsPlayingInPluginProcess): 29 * WebProcess/Plugins/PluginProcessConnection.cpp: store audio state 30 (WebKit::PluginProcessConnection::PluginProcessConnection): 31 (WebKit::PluginProcessConnection::didReceiveMessage): 32 (WebKit::PluginProcessConnection::audioHardwareDidBecomeActive): 33 (WebKit::PluginProcessConnection::audioHardwareDidBecomeInactive): 34 * WebProcess/Plugins/PluginProcessConnection.h: 35 (WebKit::PluginProcessConnection::audioIsPlaying): 36 * WebProcess/Plugins/PluginProcessConnection.messages.in: 37 * WebProcess/Plugins/PluginProxy.cpp: 38 (WebKit::PluginProxy::audioIsPlayingInPluginProcess): 39 * WebProcess/Plugins/PluginProxy.h: 40 * WebProcess/Plugins/PluginView.cpp: 41 (WebKit::PluginView::audioIsPlayingInPluginProcess): 42 * WebProcess/Plugins/PluginView.h: 43 1 44 2014-03-28 Stephanie Lewis <slewis@apple.com> 2 45 -
trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp
r166441 r166443 65 65 { 66 66 NetscapePlugin::setSetExceptionFunction(WebProcessConnection::setGlobalException); 67 m_audioHardwareListener = AudioHardwareListener::create(*this); 67 68 } 68 69 … … 162 163 // Create a listening connection. 163 164 RefPtr<WebProcessConnection> connection = WebProcessConnection::create(IPC::Connection::Identifier(listeningPort)); 165 166 if (m_audioHardwareListener) { 167 if (m_audioHardwareListener->hardwareActivity() == WebCore::AudioHardwareActivityType::IsActive) 168 connection->audioHardwareDidBecomeActive(); 169 else if (m_audioHardwareListener->hardwareActivity() == WebCore::AudioHardwareActivityType::IsInactive) 170 connection->audioHardwareDidBecomeInactive(); 171 } 172 164 173 m_webProcessConnections.append(connection.release()); 165 174 … … 247 256 m_visiblePluginsActivity.decrement(); 248 257 } 258 259 void PluginProcess::audioHardwareDidBecomeActive() 260 { 261 for (auto& connection : m_webProcessConnections) 262 connection->audioHardwareDidBecomeActive(); 263 } 264 265 void PluginProcess::audioHardwareDidBecomeInactive() 266 { 267 for (auto& connection : m_webProcessConnections) 268 connection->audioHardwareDidBecomeInactive(); 269 } 249 270 250 271 } // namespace WebKit -
trunk/Source/WebKit2/PluginProcess/PluginProcess.h
r166441 r166443 31 31 #include "ChildProcess.h" 32 32 #include <WebCore/CountedUserActivity.h> 33 #include <WebCore/AudioHardwareListener.h> 33 34 #include <wtf/Forward.h> 34 35 #include <wtf/NeverDestroyed.h> … … 41 42 struct PluginProcessCreationParameters; 42 43 43 class PluginProcess : public ChildProcess { 44 class PluginProcess : public ChildProcess, private WebCore::AudioHardwareListener::Client 45 { 44 46 WTF_MAKE_NONCOPYABLE(PluginProcess); 45 47 friend class NeverDestroyed<PluginProcess>; … … 96 98 void getSitesWithData(uint64_t callbackID); 97 99 void clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); 100 101 // AudioHardwareListenerClient 102 virtual void audioHardwareDidBecomeActive() override; 103 virtual void audioHardwareDidBecomeInactive() override; 98 104 99 105 void platformInitializePluginProcess(const PluginProcessCreationParameters&); … … 126 132 CountedUserActivity m_connectionActivity; 127 133 CountedUserActivity m_visiblePluginsActivity; 134 135 RefPtr<WebCore::AudioHardwareListener> m_audioHardwareListener; 128 136 }; 129 137 -
trunk/Source/WebKit2/PluginProcess/WebProcessConnection.cpp
r166441 r166443 40 40 #include "PluginProxyMessages.h" 41 41 #include "WebProcessConnectionMessages.h" 42 #include <WebCore/AudioHardwareListener.h> 42 43 #include <unistd.h> 43 44 #include <wtf/RunLoop.h> … … 349 350 } 350 351 352 void WebProcessConnection::audioHardwareDidBecomeActive() 353 { 354 m_connection->send(Messages::PluginProcessConnection::AudioHardwareDidBecomeActive(), 0); 355 } 356 357 void WebProcessConnection::audioHardwareDidBecomeInactive() 358 { 359 m_connection->send(Messages::PluginProcessConnection::AudioHardwareDidBecomeInactive(), 0); 360 } 361 351 362 } // namespace WebKit 352 363 -
trunk/Source/WebKit2/PluginProcess/WebProcessConnection.h
r166441 r166443 58 58 void pluginDidBecomeHidden(unsigned pluginInstanceID); 59 59 60 void audioHardwareDidBecomeActive(); 61 void audioHardwareDidBecomeInactive(); 62 60 63 private: 61 64 WebProcessConnection(IPC::Connection::Identifier); -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
r163647 r166443 40 40 #include <JavaScriptCore/Strong.h> 41 41 #include <JavaScriptCore/StrongInlines.h> 42 #include <WebCore/AudioHardwareListener.h> 42 43 #include <WebCore/DOMWrapperWorld.h> 43 44 #include <WebCore/Frame.h> … … 191 192 192 193 if (m_pluginView && !m_pluginView->isBeingDestroyed()) { 193 if (Page* page = m_pluginView->frame()->page()) 194 page->pageThrottler().pluginDidEvaluate(); 194 if (Page* page = m_pluginView->frame()->page()) { 195 if (m_pluginView->audioHardwareActivity() != WebCore::AudioHardwareActivityType::IsInactive) 196 page->pageThrottler().pluginDidEvaluateWhileAudioIsPlaying(); 197 } 195 198 } 196 199 -
trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h
r164192 r166443 27 27 #define Plugin_h 28 28 29 #include <WebCore/AudioHardwareListener.h> 29 30 #include <WebCore/FindOptions.h> 30 31 #include <WebCore/GraphicsLayer.h> … … 277 278 278 279 virtual String getSelectionString() const = 0; 280 281 virtual WebCore::AudioHardwareActivityType audioHardwareActivity() const { return WebCore::AudioHardwareActivityType::Unknown; } 279 282 280 283 protected: -
trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp
r161148 r166443 47 47 , m_pluginProcessToken(pluginProcessToken) 48 48 , m_supportsAsynchronousPluginInitialization(supportsAsynchronousPluginInitialization) 49 , m_audioHardwareActivity(WebCore::AudioHardwareActivityType::Unknown) 49 50 { 50 51 m_connection = IPC::Connection::createClientConnection(connectionIdentifier, this, RunLoop::main()); … … 91 92 void PluginProcessConnection::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder) 92 93 { 94 if (!decoder.destinationID()) { 95 didReceivePluginProcessConnectionMessage(connection, decoder); 96 return; 97 } 98 93 99 ASSERT(decoder.destinationID()); 94 100 … … 139 145 NPRuntimeObjectMap::setGlobalException(exceptionString); 140 146 } 147 148 void PluginProcessConnection::audioHardwareDidBecomeActive() 149 { 150 m_audioHardwareActivity = WebCore::AudioHardwareActivityType::IsActive; 151 } 152 153 void PluginProcessConnection::audioHardwareDidBecomeInactive() 154 { 155 m_audioHardwareActivity = WebCore::AudioHardwareActivityType::IsInactive; 156 } 141 157 142 158 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h
r162139 r166443 59 59 60 60 bool supportsAsynchronousPluginInitialization() const { return m_supportsAsynchronousPluginInitialization; } 61 61 WebCore::AudioHardwareActivityType audioHardwareActivity() const { return m_audioHardwareActivity; } 62 62 63 private: 63 64 PluginProcessConnection(PluginProcessConnectionManager*, uint64_t pluginProcessToken, IPC::Connection::Identifier connectionIdentifier, bool supportsAsynchronousInitialization); … … 70 71 71 72 // Message handlers. 73 void didReceivePluginProcessConnectionMessage(IPC::Connection*, IPC::MessageDecoder&); 72 74 void didReceiveSyncPluginProcessConnectionMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); 73 75 void setException(const String&); 76 void audioHardwareDidBecomeActive(); 77 void audioHardwareDidBecomeInactive(); 74 78 75 79 PluginProcessConnectionManager* m_pluginProcessConnectionManager; … … 85 89 86 90 bool m_supportsAsynchronousPluginInitialization; 91 WebCore::AudioHardwareActivityType m_audioHardwareActivity; 87 92 }; 88 93 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.messages.in
r160022 r166443 26 26 # Set a global JavaScript exception. 27 27 SetException(String exceptionString) -> () 28 29 # Plugin process audio hardware state changed 30 AudioHardwareDidBecomeActive() 31 AudioHardwareDidBecomeInactive() 28 32 } 29 33 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
r164192 r166443 710 710 return 0; 711 711 } 712 713 WebCore::AudioHardwareActivityType PluginProxy::audioHardwareActivity() const 714 { 715 return m_connection->audioHardwareActivity(); 716 } 712 717 713 718 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
r164192 r166443 139 139 140 140 virtual String getSelectionString() const override { return String(); } 141 142 virtual WebCore::AudioHardwareActivityType audioHardwareActivity() const override; 141 143 142 144 float contentsScaleFactor(); -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
r166262 r166443 545 545 return true; 546 546 } 547 547 548 WebCore::AudioHardwareActivityType PluginView::audioHardwareActivity() const 549 { 550 return m_plugin->audioHardwareActivity(); 551 } 552 548 553 NSObject *PluginView::accessibilityObject() const 549 554 { -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h
r164192 r166443 108 108 PassRefPtr<WebCore::SharedBuffer> liveResourceData() const; 109 109 bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&); 110 WebCore::AudioHardwareActivityType audioHardwareActivity() const; 110 111 111 112 private:
Note:
See TracChangeset
for help on using the changeset viewer.