Title: [276281] trunk/Source/WebKit
Revision
276281
Author
jer.no...@apple.com
Date
2021-04-19 19:26:20 -0700 (Mon, 19 Apr 2021)

Log Message

[iOS] Media playback continues after backgrounding hosting application
https://bugs.webkit.org/show_bug.cgi?id=224776
<rdar://75707807>

Reviewed by Eric Carlson.

Tested by existing API test: WKWebViewPausePlayingAudioTests.OutOfWindow

When the MediaSessionHelperIOS was moved into the GPU process, no object remains listening for the
UIApplication{Will,Did}Enter{Foreground,Background}Notification rebroadcasted by WebPageIOS.

Rather than just rebroadcast the UIKit notification to all listeners within the WebContent process,
which may or may not be listening, just tell the current PlatformMediaSessionManager directly.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::applicationWillResignActive):
(WebKit::WebPage::applicationDidEnterBackground):
(WebKit::WebPage::applicationWillEnterForeground):
(WebKit::WebPage::applicationDidBecomeActive):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (276280 => 276281)


--- trunk/Source/WebKit/ChangeLog	2021-04-20 01:02:01 UTC (rev 276280)
+++ trunk/Source/WebKit/ChangeLog	2021-04-20 02:26:20 UTC (rev 276281)
@@ -1,3 +1,25 @@
+2021-04-19  Jer Noble  <jer.no...@apple.com>
+
+        [iOS] Media playback continues after backgrounding hosting application
+        https://bugs.webkit.org/show_bug.cgi?id=224776
+        <rdar://75707807>
+
+        Reviewed by Eric Carlson.
+
+        Tested by existing API test: WKWebViewPausePlayingAudioTests.OutOfWindow
+
+        When the MediaSessionHelperIOS was moved into the GPU process, no object remains listening for the
+        UIApplication{Will,Did}Enter{Foreground,Background}Notification rebroadcasted by WebPageIOS.
+
+        Rather than just rebroadcast the UIKit notification to all listeners within the WebContent process,
+        which may or may not be listening, just tell the current PlatformMediaSessionManager directly.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::applicationWillResignActive):
+        (WebKit::WebPage::applicationDidEnterBackground):
+        (WebKit::WebPage::applicationWillEnterForeground):
+        (WebKit::WebPage::applicationDidBecomeActive):
+
 2021-04-19  Chris Dumez  <cdu...@apple.com>
 
         MotionMark's Canvas-Arcs subtest is broken if the GPUProcess is not yet running

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (276280 => 276281)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-04-20 01:02:01 UTC (rev 276280)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-04-20 02:26:20 UTC (rev 276281)
@@ -117,6 +117,7 @@
 #import <WebCore/PagePasteboardContext.h>
 #import <WebCore/Pasteboard.h>
 #import <WebCore/PlatformKeyboardEvent.h>
+#import <WebCore/PlatformMediaSessionManager.h>
 #import <WebCore/PlatformMouseEvent.h>
 #import <WebCore/PointerCaptureController.h>
 #import <WebCore/PointerCharacteristics.h>
@@ -3745,6 +3746,11 @@
 void WebPage::applicationWillResignActive()
 {
     [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillResignActiveNotification object:nil];
+
+    // FIXME(224775): Move to WebProcess
+    if (auto* manager = PlatformMediaSessionManager::sharedManagerIfExists())
+        manager->applicationWillBecomeInactive();
+
     if (m_page)
         m_page->applicationWillResignActive();
 }
@@ -3756,6 +3762,10 @@
     m_isSuspendedUnderLock = isSuspendedUnderLock;
     freezeLayerTree(LayerTreeFreezeReason::BackgroundApplication);
 
+    // FIXME(224775): Move to WebProcess
+    if (auto* manager = PlatformMediaSessionManager::sharedManagerIfExists())
+        manager->applicationDidEnterBackground(isSuspendedUnderLock);
+
     if (m_page)
         m_page->applicationDidEnterBackground();
 }
@@ -3774,6 +3784,10 @@
 
     [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillEnterForegroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": @(isSuspendedUnderLock)}];
 
+    // FIXME(224775): Move to WebProcess
+    if (auto* manager = PlatformMediaSessionManager::sharedManagerIfExists())
+        manager->applicationWillEnterForeground(isSuspendedUnderLock);
+
     if (m_page)
         m_page->applicationWillEnterForeground();
 }
@@ -3781,6 +3795,11 @@
 void WebPage::applicationDidBecomeActive()
 {
     [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidBecomeActiveNotification object:nil];
+
+    // FIXME(224775): Move to WebProcess
+    if (auto* manager = PlatformMediaSessionManager::sharedManagerIfExists())
+        manager->applicationDidBecomeActive();
+
     if (m_page)
         m_page->applicationDidBecomeActive();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to