WebKit Bugzilla
Attachment 371447 Details for
Bug 198585
: -[WKWebView _suspendAllMediaPlayback] does not persist across navigation.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-198585-20190605162325.patch (text/plain), 16.73 KB, created by
Jer Noble
on 2019-06-05 16:23:25 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2019-06-05 16:23:25 PDT
Size:
16.73 KB
patch
obsolete
>Subversion Revision: 246122 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 530baddd576974649f7656e81767a52f8ccea19b..6f2bb70a803944897e0d294d5e1cd275c243249d 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,25 @@ >+2019-06-05 Jer Noble <jer.noble@apple.com> >+ >+ -[WKWebView _suspendAllMediaPlayback] does not persist across navigation. >+ https://bugs.webkit.org/show_bug.cgi?id=198585 >+ >+ Reviewed by Chris Dumez. >+ >+ Add a new WebPageCreationParameters entry for mediaPlaybackIsSuspended, and pass >+ that value across during WebPage creation. >+ >+ * Shared/WebPageCreationParameters.cpp: >+ (WebKit::WebPageCreationParameters::encode const): >+ (WebKit::WebPageCreationParameters::decode): >+ * Shared/WebPageCreationParameters.h: >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::suspendAllMediaPlayback): >+ (WebKit::WebPageProxy::resumeAllMediaPlayback): >+ (WebKit::WebPageProxy::creationParameters): >+ * UIProcess/WebPageProxy.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage): >+ > 2019-06-05 Wenson Hsieh <wenson_hsieh@apple.com> > > Upstream content mode support into open source from WebKitAdditions >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.cpp b/Source/WebKit/Shared/WebPageCreationParameters.cpp >index 0fdd6653314ab16f9db2daec286f977589e242e3..57a5e106307880949b54dcbc68631f015d9faab6 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.cpp >+++ b/Source/WebKit/Shared/WebPageCreationParameters.cpp >@@ -66,6 +66,7 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const > encoder << mediaVolume; > encoder << muted; > encoder << mayStartMediaWhenInWindow; >+ encoder << mediaPlaybackIsSuspended; > encoder << viewLayoutSize; > encoder << autoSizingShouldExpandToViewHeight; > encoder << viewportSizeForCSSViewportUnits; >@@ -223,6 +224,8 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod > return WTF::nullopt; > if (!decoder.decode(parameters.mayStartMediaWhenInWindow)) > return WTF::nullopt; >+ if (!decoder.decode(parameters.mediaPlaybackIsSuspended)) >+ return WTF::nullopt; > if (!decoder.decode(parameters.viewLayoutSize)) > return WTF::nullopt; > if (!decoder.decode(parameters.autoSizingShouldExpandToViewHeight)) >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.h b/Source/WebKit/Shared/WebPageCreationParameters.h >index 7092f9a6e2b446bb0ca04e6a105654f5f2ae3578..1c0c1772356b9cb0f703668d2bdec09527b145bd 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.h >+++ b/Source/WebKit/Shared/WebPageCreationParameters.h >@@ -116,6 +116,7 @@ struct WebPageCreationParameters { > float mediaVolume; > WebCore::MediaProducer::MutedStateFlags muted; > bool mayStartMediaWhenInWindow; >+ bool mediaPlaybackIsSuspended { false }; > > WebCore::IntSize viewLayoutSize; > bool autoSizingShouldExpandToViewHeight; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 36754d6b49eb4e50218cc464d882722dc4184d47..f2d6775b0c39db949f2c9fbd425a6cf908f8a447 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -5472,6 +5472,10 @@ void WebPageProxy::stopAllMediaPlayback() > > void WebPageProxy::suspendAllMediaPlayback() > { >+ if (m_mediaPlaybackIsSuspended) >+ return; >+ m_mediaPlaybackIsSuspended = true; >+ > if (!hasRunningProcess()) > return; > >@@ -5480,6 +5484,10 @@ void WebPageProxy::suspendAllMediaPlayback() > > void WebPageProxy::resumeAllMediaPlayback() > { >+ if (!m_mediaPlaybackIsSuspended) >+ return; >+ m_mediaPlaybackIsSuspended = false; >+ > if (!hasRunningProcess()) > return; > >@@ -7125,6 +7133,7 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc > parameters.mediaVolume = m_mediaVolume; > parameters.muted = m_mutedState; > parameters.mayStartMediaWhenInWindow = m_mayStartMediaWhenInWindow; >+ parameters.mediaPlaybackIsSuspended = m_mediaPlaybackIsSuspended; > parameters.viewLayoutSize = m_viewLayoutSize; > parameters.autoSizingShouldExpandToViewHeight = m_autoSizingShouldExpandToViewHeight; > parameters.viewportSizeForCSSViewportUnits = m_viewportSizeForCSSViewportUnits; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 2cce37892effc741f2c5750a53143826342861c6..1cf8b6e892d1648755c59ddec636d082f576511e 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -2412,6 +2412,7 @@ WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_2 > float m_mediaVolume { 1 }; > WebCore::MediaProducer::MutedStateFlags m_mutedState { WebCore::MediaProducer::NoneMuted }; > bool m_mayStartMediaWhenInWindow { true }; >+ bool m_mediaPlaybackIsSuspended { false }; > bool m_mediaCaptureEnabled { true }; > > bool m_waitingForDidUpdateActivityState { false }; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index 6d3d7c53a4c581964347898c49c7b1e971648c25..2ed7e931822fcb6c04f2c8e2edc99563f8ae55f8 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -539,6 +539,8 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters) > > m_page->setCanStartMedia(false); > m_mayStartMediaWhenInWindow = parameters.mayStartMediaWhenInWindow; >+ if (parameters.mediaPlaybackIsSuspended) >+ m_page->suspendAllMediaPlayback(); > > m_page->setGroupName(m_pageGroup->identifier()); > m_page->setDeviceScaleFactor(parameters.deviceScaleFactor); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index b5f4d6da42a903391e502048e4d35237769f3cf1..4d993abef0188c1ebe8f71fb4a3deb2f9c6342a9 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,16 @@ >+2019-06-05 Jer Noble <jer.noble@apple.com> >+ >+ -[WKWebView _suspendAllMediaPlayback] does not persist across navigation. >+ https://bugs.webkit.org/show_bug.cgi?id=198585 >+ >+ Reviewed by Chris Dumez. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: >+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm: Added. >+ (TEST): >+ * TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html: >+ > 2019-06-05 Wenson Hsieh <wenson_hsieh@apple.com> > > Upstream content mode support into open source from WebKitAdditions >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 4fac4e6f87787ad9a8b1666e01a2de26c4b57096..5899dbdc8a8026ae9410c79ad4553d735651e1f8 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -825,6 +825,7 @@ > CD758A6F20572EA00071834A /* video-with-paused-audio-and-playing-muted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD758A6E20572D540071834A /* video-with-paused-audio-and-playing-muted.html */; }; > CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */; }; > CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */; }; >+ CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */; }; > CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD9E292D1C90C1BA000BB800 /* audio-only.html */; }; > CDA29B2920FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */; }; > CDA29B2B20FD358400F15CED /* ExitFullscreenOnEnterPiP.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */; }; >@@ -2210,6 +2211,7 @@ > CD773F711C5057DB0002257C /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; }; > CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenDelegate.mm; sourceTree = "<group>"; }; > CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenDelegate.html; sourceTree = "<group>"; }; >+ CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewSuspendAllMediaPlayback.mm; sourceTree = "<group>"; }; > CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; }; > CD9E292B1C90A71F000BB800 /* RequiresUserActionForPlayback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequiresUserActionForPlayback.mm; sourceTree = "<group>"; }; > CD9E292D1C90C1BA000BB800 /* audio-only.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "audio-only.html"; sourceTree = "<group>"; }; >@@ -2789,6 +2791,7 @@ > D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */, > 37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */, > 93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */, >+ CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */, > 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */, > ); > name = "WebKit Cocoa"; >@@ -4559,6 +4562,7 @@ > F4FA91811E61849B007B8C1D /* WKWebViewMacEditingTests.mm in Sources */, > 37A9DBE9213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm in Sources */, > 93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */, >+ CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */, > 9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */, > 9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */, > ); >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >index e4c1809c84b325ea47a9b6f77e186f2c78329340..19e2b5cc53d305545ffd697ef497549c22135865 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >@@ -6265,3 +6265,33 @@ TEST(ProcessSwap, PassMinimumDeviceWidthOnNewWebView) > } > > #endif >+ >+TEST(ProcessSwap, SuspendAllMediaPlayback) >+{ >+ auto processPoolConfiguration = psonProcessPoolConfiguration(); >+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); >+ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; >+#if TARGET_OS_IPHONE >+ configuration.get().allowsInlineMediaPlayback = YES; >+#endif >+ [configuration setProcessPool:processPool.get()]; >+ auto handler = adoptNS([[PSONScheme alloc] init]); >+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; >+ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ >+ __block bool loaded = false; >+ [webView performAfterLoading:^{ loaded = true; }]; >+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]]; >+ >+ TestWebKitAPI::Util::run(&loaded); >+ >+ [webView _suspendAllMediaPlayback]; >+ >+ __block bool notPlaying = false; >+ [webView performAfterReceivingMessage:@"not playing" action:^() { notPlaying = true; }]; >+ [webView synchronouslyLoadTestPageNamed:@"video-with-audio"]; >+ TestWebKitAPI::Util::run(¬Playing); >+} >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..beb61aee1215a29ee827afd9f8114d068e2f8590 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+ >+#import "PlatformUtilities.h" >+#import "TestWKWebView.h" >+#import <WebKit/WKWebViewConfiguration.h> >+#import <WebKit/WKWebViewPrivate.h> >+ >+TEST(WKWebViewSuspendAllMediaPlayback, BeforeLoading) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; >+#if TARGET_OS_IPHONE >+ configuration.get().allowsInlineMediaPlayback = YES; >+#endif >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]); >+ [webView _suspendAllMediaPlayback]; >+ >+ __block bool notPlaying = false; >+ [webView performAfterReceivingMessage:@"not playing" action:^{ notPlaying = true; }]; >+ [webView synchronouslyLoadTestPageNamed:@"video-with-audio"]; >+ TestWebKitAPI::Util::run(¬Playing); >+} >+ >+ >+TEST(WKWebViewSuspendAllMediaPlayback, AfterLoading) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; >+#if TARGET_OS_IPHONE >+ configuration.get().allowsInlineMediaPlayback = YES; >+#endif >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]); >+ >+ __block bool isPlaying = false; >+ [webView performAfterReceivingMessage:@"playing" action:^{ isPlaying = true; }]; >+ >+ [webView synchronouslyLoadTestPageNamed:@"video-with-audio"]; >+ >+ TestWebKitAPI::Util::run(&isPlaying); >+ >+ __block bool isPaused = false; >+ [webView performAfterReceivingMessage:@"paused" action:^{ isPaused = true; }]; >+ [webView stringByEvaluatingJavaScript:@"document.querySelector('video').addEventListener('pause', paused);"]; >+ [webView _suspendAllMediaPlayback]; >+ >+ TestWebKitAPI::Util::run(&isPaused); >+ >+ isPlaying = false; >+ [webView performAfterReceivingMessage:@"playing" action:^{ isPlaying = true; }]; >+ [webView stringByEvaluatingJavaScript:@"document.querySelector('video').addEventListener('playing', playing);"]; >+ [webView _resumeAllMediaPlayback]; >+ >+ TestWebKitAPI::Util::run(&isPlaying); >+} >diff --git a/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html b/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html >index 141c5f98b786ce2c9064aba1362d8aa31a1d7dec..b3c3bcd02199bf5bd37485d64cc22929cf0234ad 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html >+++ b/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html >@@ -17,6 +17,12 @@ > } > } > >+ function paused() { >+ try { >+ window.webkit.messageHandlers.testHandler.postMessage('paused'); >+ } catch(e) { } >+ } >+ > function notPlaying() { > try { > window.webkit.messageHandlers.testHandler.postMessage('not playing');
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 198585
:
371442
| 371447