WebKit Bugzilla
Attachment 373424 Details for
Bug 199471
: HTMLMediaElement can hold onto display sleep assertion while process is suspended.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199471-20190703153923.patch (text/plain), 6.16 KB, created by
Jer Noble
on 2019-07-03 15:39:24 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2019-07-03 15:39:24 PDT
Size:
6.16 KB
patch
obsolete
>Subversion Revision: 247109 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c96b6d02aaf4197efd12f928061259f195758051..21222a72b9b108cd4c155376ae7b9d530513f7ea 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,32 @@ >+2019-07-03 Jer Noble <jer.noble@apple.com> >+ >+ HTMLMediaElement can hold onto display sleep assertion while process is suspended. >+ https://bugs.webkit.org/show_bug.cgi?id=199471 >+ <rdar://problem/52124320> >+ >+ If the WebContent process is suspended before HTMLMediaElement gets a callback telling it >+ that the MediaPlayer has stopped playing, the SleepDisabler may stay set (and hold a display >+ or system sleep assertion) for the entire duration the process is suspended, causing excess >+ power drain. >+ >+ Add a PlatformMediaSessionClient method (and an implementation in HTMLMediaElement) which will >+ be called during the preperation for process suspension, and in this callback, clear the >+ SleepDisabler token. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * html/HTMLMediaElement.cpp: >+ (WebCore::HTMLMediaElement::shouldDisableSleep const): >+ (WebCore::HTMLMediaElement::processIsSuspendedChanged): >+ * html/HTMLMediaElement.h: >+ * platform/audio/PlatformMediaSession.h: >+ (WebCore::PlatformMediaSessionClient::processIsSuspendedChanged): >+ * platform/audio/PlatformMediaSessionManager.cpp: >+ (WebCore::PlatformMediaSessionManager::processWillSuspend): >+ (WebCore::PlatformMediaSessionManager::processDidResume): >+ * platform/audio/PlatformMediaSessionManager.h: >+ (WebCore::PlatformMediaSessionManager::processIsSuspended const): >+ > 2019-07-03 Robin Morisset <rmorisset@apple.com> > > [WHLSL] WHLSL::AST::Node is useless >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 24c687e5b21c75ac4cb0a3b772a18c72dedc22a1..9916a3a20643119811a7e45e1302287368bf1e31 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -6923,6 +6923,9 @@ HTMLMediaElement::SleepType HTMLMediaElement::shouldDisableSleep() const > return SleepType::System; > #endif > >+ if (PlatformMediaSessionManager::sharedManager().processIsSuspended()) >+ return SleepType::None; >+ > bool shouldBeAbleToSleep = !hasVideo() || !hasAudio(); > #if ENABLE(MEDIA_STREAM) > // Remote media stream video tracks may have their corresponding audio tracks being played outside of the media element. Let's ensure to not IDLE the screen in that case. >@@ -7742,6 +7745,12 @@ bool HTMLMediaElement::processingUserGestureForMedia() const > { > return document().processingUserGestureForMedia(); > } >+ >+void HTMLMediaElement::processIsSuspendedChanged() >+{ >+ updateSleepDisabling(); >+} >+ > #if ENABLE(WIRELESS_PLAYBACK_TARGET) > > void HTMLMediaElement::scheduleUpdateMediaState() >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index 2f7047efa3874467041ac89806090417f1781b4a..682e22332d3d3dfef5838365d974b4c75acc684e 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -894,6 +894,7 @@ private: > bool canProduceAudio() const final; > bool processingUserGestureForMedia() const final; > bool hasMediaStreamSource() const final; >+ void processIsSuspendedChanged() final; > > void pageMutedStateDidChange() override; > >diff --git a/Source/WebCore/platform/audio/PlatformMediaSession.h b/Source/WebCore/platform/audio/PlatformMediaSession.h >index 9c3511765ad09ab252c16a9cf3395af7ed7a14c3..1d04187f1b5a252db8ad21cf935c39f85c57a799 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSession.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSession.h >@@ -259,6 +259,8 @@ public: > > virtual bool hasMediaStreamSource() const { return false; } > >+ virtual void processIsSuspendedChanged() { } >+ > protected: > virtual ~PlatformMediaSessionClient() = default; > }; >diff --git a/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp b/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >index b42c2148b8d317a1b7b938f957c1545167bd5b4b..6f9969536e54da37077671090ea4d3aeb3fa636e 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >+++ b/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >@@ -368,6 +368,10 @@ void PlatformMediaSessionManager::processWillSuspend() > return; > m_processIsSuspended = true; > >+ forEachSession([&] (auto& session) { >+ session.client().processIsSuspendedChanged(); >+ }); >+ > #if USE(AUDIO_SESSION) > if (m_becameActive && shouldDeactivateAudioSession()) { > AudioSession::sharedSession().tryToSetActive(false); >@@ -383,6 +387,10 @@ void PlatformMediaSessionManager::processDidResume() > return; > m_processIsSuspended = false; > >+ forEachSession([&] (auto& session) { >+ session.client().processIsSuspendedChanged(); >+ }); >+ > #if USE(AUDIO_SESSION) > if (!m_becameActive && activeAudioSessionRequired()) { > m_becameActive = AudioSession::sharedSession().tryToSetActive(true); >diff --git a/Source/WebCore/platform/audio/PlatformMediaSessionManager.h b/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >index b9119e09f52ac8de646274bbbe1e838d55aaf71b..c32739791216da9ab5fe1c06410e32e0d2344459 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >@@ -134,6 +134,8 @@ public: > > void forEachMatchingSession(const Function<bool(const PlatformMediaSession&)>& predicate, const Function<void(PlatformMediaSession&)>& matchingCallback); > >+ bool processIsSuspended() const { return m_processIsSuspended; } >+ > protected: > friend class PlatformMediaSession; > explicit PlatformMediaSessionManager(); >@@ -147,8 +149,6 @@ protected: > > AudioHardwareListener* audioHardwareListener() { return m_audioHardwareListener.get(); } > >- bool processIsSuspended() const { return m_processIsSuspended; } >- > #if !RELEASE_LOG_DISABLED > const Logger& logger() const final { return m_logger; } > const void* logIdentifier() const final { return nullptr; }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199471
: 373424