-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] MediaSessionManager continues to monitor wireless targets when …
…a page is no longer visible https://bugs.webkit.org/show_bug.cgi?id=259084 rdar://107220858 Reviewed by Jer Noble. When a page contains a visible media element with a playback target availability listener (e.g., webkitplaybacktargetavailabilitychanged), MediaSessionManager starts to monitor for playback targets. On iOS, this is implemented by asking AVRouteDetector to monitor for AirPlay routes, increasing the system's power consumption. MediaElementSession attempted to stop monitoring when its HTML element becomes invisible, but this only occurred when m_clientDataBufferingTimer fired. However, while this timer was always scheduled when the media element became invisible, in some cases it would be stopped before firing by code calling updateClientDataBuffering() directly. In these cases MediaSessionManager would not be told to stop monitoring target availability, increasing the system's power consumption for an arbitrary amount of time. Fixed this by calling PlatformMediaSessionManager::configureWirelessTargetMonitoring() whenever MediaElementSession::updateClientDataBuffering() is called, whether directly or by m_clientDataBufferingTimer firing. While here, also renamed configureWireLessTargetMonitoring to configureWirelessTargetMonitoring. * LayoutTests/TestExpectations: Skipped wireless-route-monitoring.html. * LayoutTests/media/wireless-route-monitoring-expected.txt: Added. * LayoutTests/media/wireless-route-monitoring.html: Added. * LayoutTests/platform/ios/TestExpectations: Expected wireless-route-monitoring.html to pass on iOS. * Source/WebCore/html/MediaElementSession.cpp: (WebCore::MediaElementSession::clientDataBufferingTimerFired): (WebCore::MediaElementSession::updateClientDataBuffering): (WebCore::MediaElementSession::setHasPlaybackTargetAvailabilityListeners): * Source/WebCore/platform/audio/PlatformMediaSessionManager.h: (WebCore::PlatformMediaSessionManager::configureWirelessTargetMonitoring): (WebCore::PlatformMediaSessionManager::isMonitoringWirelessTargets const): (WebCore::PlatformMediaSessionManager::configureWireLessTargetMonitoring): Renamed to configureWirelessTargetMonitoring. * Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h: * Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::isMonitoringWirelessTargets const): (WebCore::MediaSessionManageriOS::configureWirelessTargetMonitoring): (WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Renamed to configureWirelessTargetMonitoring. * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::suspendAllMediaBuffering): (WebCore::Internals::isMonitoringWirelessRoutes const): * Source/WebCore/testing/Internals.h: * Source/WebCore/testing/Internals.idl: Canonical link: https://commits.webkit.org/265965@main
- Loading branch information
Showing
11 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
EXPECTED (internals.isMonitoringWirelessRoutes == 'false') OK | ||
RUN(video.src = findMediaFile("video", "content/test")) | ||
EVENT(canplaythrough) | ||
EXPECTED (internals.isMonitoringWirelessRoutes == 'true') OK | ||
RUN(internals.setPageVisibility(false)) | ||
RUN(internals.suspendAllMediaBuffering()) | ||
EXPECTED (internals.isMonitoringWirelessRoutes == 'false') OK | ||
END OF TEST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src=media-file.js></script> | ||
<script src=video-test.js></script> | ||
<script> | ||
window.addEventListener('load', async event => { | ||
if (!window.internals) { | ||
failTest('This test requires window.internals.'); | ||
return; | ||
} | ||
|
||
findMediaElement(); | ||
|
||
testExpected('internals.isMonitoringWirelessRoutes', false); | ||
|
||
video.addEventListener('webkitplaybacktargetavailabilitychanged', event => {}); | ||
run('video.src = findMediaFile("video", "content/test")'); | ||
await waitFor(video, 'canplaythrough'); | ||
|
||
testExpected('internals.isMonitoringWirelessRoutes', true); | ||
|
||
run('internals.setPageVisibility(false)'); | ||
run('internals.suspendAllMediaBuffering()'); | ||
|
||
testExpected('internals.isMonitoringWirelessRoutes', false); | ||
|
||
endTest(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<video></video> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters