WebKit Bugzilla
Attachment 359789 Details for
Bug 193691
: [Cocoa] Media elements will restart network buffering just before suspending
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193691-20190122153844.patch (text/plain), 26.40 KB, created by
Jer Noble
on 2019-01-22 15:38:45 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2019-01-22 15:38:45 PST
Size:
26.40 KB
patch
obsolete
>Subversion Revision: 240163 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1d16aef8fbab95ef93892d8d8df40d1657fa78c8..096a2e6e71ec48a75356a5d37a1bf83c6e3c0dcf 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,39 @@ >+2019-01-22 Jer Noble <jer.noble@apple.com> >+ >+ [Cocoa] Media elements will restart network buffering just before suspending >+ https://bugs.webkit.org/show_bug.cgi?id=193691 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ API Test: WebKit.ProcessSuspendMediaBuffering >+ >+ Allow the Page to suspend all media buffering in its child Documents. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::suspendAllMediaBuffering): >+ (WebCore::Document::resumeAllMediaBuffering): >+ * dom/Document.h: >+ * html/MediaElementSession.cpp: >+ (WebCore::MediaElementSession::dataBufferingPermitted const): >+ (WebCore::MediaElementSession::suspendBuffering): >+ (WebCore::MediaElementSession::resumeBuffering): >+ (WebCore::MediaElementSession::bufferingSuspended const): >+ * html/MediaElementSession.h: >+ * page/Page.cpp: >+ (WebCore::Page::suspendAllMediaBuffering): >+ (WebCore::Page::resumeAllMediaBuffering): >+ * page/Page.h: >+ (WebCore::Page::mediaPlaybackIsSuspended const): >+ (WebCore::Page::mediaBufferingIsSuspended const): >+ (WebCore::Page::mediaPlaybackIsSuspended): Deleted. >+ * platform/audio/PlatformMediaSession.h: >+ (WebCore::PlatformMediaSession::suspendBuffering): >+ (WebCore::PlatformMediaSession::resumeBuffering): >+ * platform/audio/PlatformMediaSessionManager.cpp: >+ (WebCore::PlatformMediaSessionManager::suspendAllMediaBufferingForDocument): >+ (WebCore::PlatformMediaSessionManager::resumeAllMediaBufferingForDocument): >+ * platform/audio/PlatformMediaSessionManager.h: >+ > 2019-01-18 Antti Koivisto <antti@apple.com> > > Implement asynchronous frame scrolling for iOS >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 9f789b9159c85bcb40ece3ab92afb61a85e0fff3..c652d7e886e20b38958c581f2531bb182219254a 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,35 @@ >+2019-01-22 Jer Noble <jer.noble@apple.com> >+ >+ [Cocoa] Media elements will restart network buffering just before suspending >+ https://bugs.webkit.org/show_bug.cgi?id=193691 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When the WebProcess receives a notification that the process is about to become >+ suspended, it tells the MemoryPressureHandler to release all critical memory. This >+ has the side effect of causing AVFoundation-backed media elements to dump their >+ in-memory caches and start downloading media data again. Instead, media elements >+ should all stop buffering media data during suspension. Add new testing SPI to >+ simulate suspension and resume messages. >+ >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _processWillSuspendImminentlyForTesting]): >+ (-[WKWebView _processDidResumeForTesting]): >+ * UIProcess/API/Cocoa/WKWebViewPrivate.h: >+ * UIProcess/WebProcessProxy.h: >+ * UIProcess/ios/WKInkPickerView.mm: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::suspendAllMediaBuffering): >+ (WebKit::WebPage::resumeAllMediaBuffering): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebProcess.cpp: >+ (WebKit::WebProcess::actualPrepareToSuspend): >+ (WebKit::WebProcess::cancelPrepareToSuspend): >+ (WebKit::WebProcess::processDidResume): >+ (WebKit::WebProcess::suspendAllMediaBuffering): >+ (WebKit::WebProcess::resumeAllMediaBuffering): >+ * WebProcess/WebProcess.h: >+ > 2019-01-18 Antti Koivisto <antti@apple.com> > > Implement asynchronous frame scrolling for iOS >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 67eb1a19aff791e62d645d693ad923779b121bdf..232614ca0b0b831a69221620c5d62bd955b27836 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -1740,6 +1740,18 @@ void Document::resumeAllMediaPlayback() > if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) > platformMediaSessionManager->resumeAllMediaPlaybackForDocument(*this); > } >+ >+void Document::suspendAllMediaBuffering() >+{ >+ if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) >+ platformMediaSessionManager->suspendAllMediaBufferingForDocument(*this); >+} >+ >+void Document::resumeAllMediaBuffering() >+{ >+ if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) >+ platformMediaSessionManager->resumeAllMediaBufferingForDocument(*this); >+} > #endif > > String Document::nodeName() const >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 308929e47f683fc868f780f76a1845d678f05bfc..8861b6778ce2332a03ab926c634e843648f33930 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -1126,6 +1126,8 @@ public: > void stopAllMediaPlayback(); > void suspendAllMediaPlayback(); > void resumeAllMediaPlayback(); >+ void suspendAllMediaBuffering(); >+ void resumeAllMediaBuffering(); > #endif > > WEBCORE_EXPORT void setShouldCreateRenderers(bool); >diff --git a/Source/WebCore/html/MediaElementSession.cpp b/Source/WebCore/html/MediaElementSession.cpp >index be6203dd7dc0c5a642167598ab009557503f4b16..6819402f89b939540118628c92ed8ccee23ad4b2 100644 >--- a/Source/WebCore/html/MediaElementSession.cpp >+++ b/Source/WebCore/html/MediaElementSession.cpp >@@ -379,6 +379,9 @@ bool MediaElementSession::dataBufferingPermitted() const > if (isSuspended()) > return false; > >+ if (bufferingSuspended()) >+ return false; >+ > if (state() == PlatformMediaSession::Playing) > return true; > >@@ -779,6 +782,23 @@ void MediaElementSession::resetPlaybackSessionState() > addBehaviorRestriction(RequireUserGestureToControlControlsManager | RequirePlaybackToControlControlsManager); > } > >+void MediaElementSession::suspendBuffering() >+{ >+ updateClientDataBuffering(); >+} >+ >+void MediaElementSession::resumeBuffering() >+{ >+ updateClientDataBuffering(); >+} >+ >+bool MediaElementSession::bufferingSuspended() const >+{ >+ if (auto* page = m_element.document().page()) >+ return page->mediaBufferingIsSuspended(); >+ return true; >+} >+ > bool MediaElementSession::allowsPictureInPicture() const > { > return m_element.document().settings().allowsPictureInPictureMediaPlayback(); >diff --git a/Source/WebCore/html/MediaElementSession.h b/Source/WebCore/html/MediaElementSession.h >index 597ba27729acc8f2e2e78caf964f5fc808e2a01e..ce058c6e11fe441c18de0652681cbaa4198147e1 100644 >--- a/Source/WebCore/html/MediaElementSession.h >+++ b/Source/WebCore/html/MediaElementSession.h >@@ -101,6 +101,10 @@ public: > > void resetPlaybackSessionState() override; > >+ void suspendBuffering() override; >+ void resumeBuffering() override; >+ bool bufferingSuspended() const; >+ > // Restrictions to modify default behaviors. > enum BehaviorRestrictionFlags : unsigned { > NoRestrictions = 0, >diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp >index db177e8dae8c60e6e718229fb3c03d36dffd5452..e3026b24a165756b23841d8a88daa384b25d488e 100644 >--- a/Source/WebCore/page/Page.cpp >+++ b/Source/WebCore/page/Page.cpp >@@ -1759,6 +1759,36 @@ void Page::resumeAllMediaPlayback() > #endif > } > >+void Page::suspendAllMediaBuffering() >+{ >+#if ENABLE(VIDEO) >+ ASSERT(!m_mediaBufferingIsSuspended); >+ if (m_mediaBufferingIsSuspended) >+ return; >+ m_mediaBufferingIsSuspended = true; >+ >+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { >+ if (auto* document = frame->document()) >+ document->suspendAllMediaBuffering(); >+ } >+#endif >+} >+ >+void Page::resumeAllMediaBuffering() >+{ >+#if ENABLE(VIDEO) >+ ASSERT(m_mediaBufferingIsSuspended); >+ if (!m_mediaBufferingIsSuspended) >+ return; >+ m_mediaBufferingIsSuspended = false; >+ >+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { >+ if (auto* document = frame->document()) >+ document->resumeAllMediaBuffering(); >+ } >+#endif >+} >+ > #if ENABLE(MEDIA_SESSION) > void Page::handleMediaEvent(MediaEventType eventType) > { >diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h >index 7f7b370bcae98ab957db4c50176dec29b7b4f926..fd23cad909d824400221a7fe115a3b94201b5fec 100644 >--- a/Source/WebCore/page/Page.h >+++ b/Source/WebCore/page/Page.h >@@ -609,7 +609,10 @@ public: > WEBCORE_EXPORT void stopAllMediaPlayback(); > WEBCORE_EXPORT void suspendAllMediaPlayback(); > WEBCORE_EXPORT void resumeAllMediaPlayback(); >- bool mediaPlaybackIsSuspended() { return m_mediaPlaybackIsSuspended; } >+ bool mediaPlaybackIsSuspended() const { return m_mediaPlaybackIsSuspended; } >+ WEBCORE_EXPORT void suspendAllMediaBuffering(); >+ WEBCORE_EXPORT void resumeAllMediaBuffering(); >+ bool mediaBufferingIsSuspended() const { return m_mediaBufferingIsSuspended; } > > #if ENABLE(MEDIA_SESSION) > WEBCORE_EXPORT void handleMediaEvent(MediaEventType); >@@ -959,6 +962,7 @@ private: > > bool m_shouldEnableICECandidateFilteringByDefault { true }; > bool m_mediaPlaybackIsSuspended { false }; >+ bool m_mediaBufferingIsSuspended { false }; > }; > > inline PageGroup& Page::group() >diff --git a/Source/WebCore/platform/audio/PlatformMediaSession.h b/Source/WebCore/platform/audio/PlatformMediaSession.h >index 25c177990cf2613f25fe0ad00d8812429b6da0f2..87e192f4fe3faac8cd64d374eed72f40d83697b6 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSession.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSession.h >@@ -113,6 +113,9 @@ public: > > void pauseSession(); > void stopSession(); >+ >+ virtual void suspendBuffering() { } >+ virtual void resumeBuffering() { } > > #if ENABLE(VIDEO) > uint64_t uniqueIdentifier() const; >diff --git a/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp b/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >index 2050c5e082f3381b671802f835b07ec54e48c5d4..b9b079d9e1fd7ffffc2085337a0331f1f277058d 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >+++ b/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >@@ -437,6 +437,22 @@ void PlatformMediaSessionManager::resumeAllMediaPlaybackForDocument(const Docume > }); > } > >+void PlatformMediaSessionManager::suspendAllMediaBufferingForDocument(const Document& document) >+{ >+ forEachSession([&] (PlatformMediaSession& session, size_t) { >+ if (session.client().hostingDocument() == &document) >+ session.suspendBuffering(); >+ }); >+} >+ >+void PlatformMediaSessionManager::resumeAllMediaBufferingForDocument(const Document& document) >+{ >+ forEachSession([&] (PlatformMediaSession& session, size_t) { >+ if (session.client().hostingDocument() == &document) >+ session.resumeBuffering(); >+ }); >+} >+ > void PlatformMediaSessionManager::forEachSession(const Function<void(PlatformMediaSession&, size_t)>& predicate) const > { > ++m_iteratingOverSessions; >diff --git a/Source/WebCore/platform/audio/PlatformMediaSessionManager.h b/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >index 065d94fedc895ad6edd5bdae20046cab2260d8f2..baf5dd8c7488111a0465413a6ba09d6203e00071 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >@@ -81,6 +81,8 @@ public: > > void suspendAllMediaPlaybackForDocument(const Document&); > void resumeAllMediaPlaybackForDocument(const Document&); >+ void suspendAllMediaBufferingForDocument(const Document&); >+ void resumeAllMediaBufferingForDocument(const Document&); > > enum SessionRestrictionFlags { > NoRestrictions = 0, >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 265e6fed613369d64100529480d15a1950090de3..7e4d703d9b734e8febcf8deb9a50db764bb488c5 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -7049,6 +7049,18 @@ - (_WKFrameHandle *)_mainFrame > return nil; > } > >+- (void)_processWillSuspendImminentlyForTesting >+{ >+ if (_page) >+ _page->process().sendProcessWillSuspendImminently(); >+} >+ >+- (void)_processDidResumeForTesting >+{ >+ if (_page) >+ _page->process().sendProcessDidResume(); >+} >+ > - (void)_denyNextUserMediaRequest > { > #if ENABLE(MEDIA_STREAM) >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >index 12b01e85d193601df1a2ba3e8411e4815cf7e477..46f5efd363cd3262120dfdd776c656836f095d79 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >@@ -547,6 +547,9 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) { > @property (nonatomic, readonly) _WKInspector *_inspector WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > @property (nonatomic, readonly) _WKFrameHandle *_mainFrame WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > >+- (void)_processWillSuspendImminentlyForTesting; >+- (void)_processDidResumeForTesting; >+ > @end > > #endif >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.h b/Source/WebKit/UIProcess/WebProcessProxy.h >index ff9e52cc31f0f808a3f03d6c1cc9b0c783f21749..a2663eba39a0a61afc166b4074b42b803e783edf 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.h >+++ b/Source/WebKit/UIProcess/WebProcessProxy.h >@@ -248,6 +248,13 @@ public: > void shutDown(); > void maybeShutDown(); > >+ // ProcessThrottlerClient >+ void sendProcessWillSuspendImminently() override; >+ void sendPrepareToSuspend() override; >+ void sendCancelPrepareToSuspend() override; >+ void sendProcessDidResume() override; >+ void didSetAssertionState(AssertionState) override; >+ > protected: > static uint64_t generatePageID(); > WebProcessProxy(WebProcessPool&, WebsiteDataStore&, IsPrewarmed); >@@ -266,7 +273,7 @@ protected: > #endif > > bool isJITEnabled() const final; >- >+ > private: > // IPC message handlers. > void updateBackForwardItem(const BackForwardListItemState&); >@@ -317,13 +324,6 @@ private: > void didChangeIsResponsive() override; > bool mayBecomeUnresponsive() override; > >- // ProcessThrottlerClient >- void sendProcessWillSuspendImminently() override; >- void sendPrepareToSuspend() override; >- void sendCancelPrepareToSuspend() override; >- void sendProcessDidResume() override; >- void didSetAssertionState(AssertionState) override; >- > // Implemented in generated WebProcessProxyMessageReceiver.cpp > void didReceiveWebProcessProxyMessage(IPC::Connection&, IPC::Decoder&); > void didReceiveSyncWebProcessProxyMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); >diff --git a/Source/WebKit/UIProcess/ios/WKInkPickerView.mm b/Source/WebKit/UIProcess/ios/WKInkPickerView.mm >index d4e35fee56b370f719d49325fb8cdb0cf0a696c9..1c2929dca5202639564e03088378a7c32da6a54b 100644 >--- a/Source/WebKit/UIProcess/ios/WKInkPickerView.mm >+++ b/Source/WebKit/UIProcess/ios/WKInkPickerView.mm >@@ -29,6 +29,7 @@ > #if HAVE(PENCILKIT) > > #import "WKContentViewInteraction.h" >+#import "WKDrawingCoordinator.h" > > #import "PencilKitSoftLink.h" > >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index dd97d6eb07ae252a6ec7ec15fce77a34f215643c..65441ef2e9ad28d8ed97b4b32076568f9f1fccb2 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -680,6 +680,17 @@ void WebPage::resumeAllMediaPlayback() > m_page->resumeAllMediaPlayback(); > } > >+void WebPage::suspendAllMediaBuffering() >+{ >+ m_page->suspendAllMediaBuffering(); >+} >+ >+void WebPage::resumeAllMediaBuffering() >+{ >+ m_page->resumeAllMediaBuffering(); >+} >+ >+ > void WebPage::reinitializeWebPage(WebPageCreationParameters&& parameters) > { > ASSERT(m_drawingArea); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index f3b934e27da9d5ea5a1bbf55f149f5a8512736e4..5018308920056af788483ed81cc4a0669f63962d 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1137,6 +1137,9 @@ public: > > void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&); > >+ void suspendAllMediaBuffering(); >+ void resumeAllMediaBuffering(); >+ > private: > WebPage(uint64_t pageID, WebPageCreationParameters&&); > >diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp >index 023065cde8ef20533001b933681e701948b25f10..694f8d4baccc79ad05184c1a72d537145de2b6c5 100644 >--- a/Source/WebKit/WebProcess/WebProcess.cpp >+++ b/Source/WebKit/WebProcess/WebProcess.cpp >@@ -1367,6 +1367,10 @@ void WebProcess::actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend shou > { > SetForScope<bool> suspensionScope(m_isSuspending, true); > >+#if ENABLE(VIDEO) >+ suspendAllMediaBuffering(); >+#endif >+ > if (!m_suppressMemoryPressureHandler) > MemoryPressureHandler::singleton().releaseMemory(Critical::Yes, Synchronous::Yes); > >@@ -1423,7 +1427,11 @@ void WebProcess::cancelPrepareToSuspend() > #if PLATFORM(IOS_FAMILY) > accessibilityProcessSuspendedNotification(false); > #endif >- >+ >+#if ENABLE(VIDEO) >+ resumeAllMediaBuffering(); >+#endif >+ > // If we've already finished cleaning up and sent ProcessReadyToSuspend, we > // shouldn't send DidCancelProcessSuspension; the UI process strictly expects one or the other. > if (!m_pageMarkingLayersAsVolatileCounter) >@@ -1488,6 +1496,10 @@ void WebProcess::processDidResume() > #if PLATFORM(IOS_FAMILY) > accessibilityProcessSuspendedNotification(false); > #endif >+ >+#if ENABLE(VIDEO) >+ resumeAllMediaBuffering(); >+#endif > } > > void WebProcess::sendPrewarmInformation(const URL& url) >@@ -1740,6 +1752,20 @@ void WebProcess::resetMockMediaDevices() > } > #endif > >+#if ENABLE(VIDEO) >+void WebProcess::suspendAllMediaBuffering() >+{ >+ for (auto& page : m_pageMap.values()) >+ page->suspendAllMediaBuffering(); >+} >+ >+void WebProcess::resumeAllMediaBuffering() >+{ >+ for (auto& page : m_pageMap.values()) >+ page->resumeAllMediaBuffering(); >+} >+#endif >+ > void WebProcess::clearCurrentModifierStateForTesting() > { > PlatformKeyboardEvent::setCurrentModifierState({ }); >diff --git a/Source/WebKit/WebProcess/WebProcess.h b/Source/WebKit/WebProcess/WebProcess.h >index 8a85cdb834c14077c23a7cf76140bb197fc4cadf..62e85e1f901f2acc3096c0c614e93e64c82cfd65 100644 >--- a/Source/WebKit/WebProcess/WebProcess.h >+++ b/Source/WebKit/WebProcess/WebProcess.h >@@ -399,6 +399,11 @@ private: > #endif > #endif > >+#if ENABLE(VIDEO) >+ void suspendAllMediaBuffering(); >+ void resumeAllMediaBuffering(); >+#endif >+ > void clearCurrentModifierStateForTesting(); > > RefPtr<WebConnectionToUIProcess> m_webConnection; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 0ccd22bd4c1faf1d3515353f54ac9d486254c56c..30836817c0fa76368452b94628bf1ba4b77ff553 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-22 Jer Noble <jer.noble@apple.com> >+ >+ [Cocoa] Media elements will restart network buffering just before suspending >+ https://bugs.webkit.org/show_bug.cgi?id=193691 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspendMediaBuffering.mm: Added. >+ (TEST): >+ > 2018-11-06 Jer Noble <jer.noble@apple.com> > > Add a git utility method that allows the caller to determine if a specific commitish is within a specified range of commits. >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 7a1072acdaa2c2aa507cdb2fc2970810845c3f0a..db249f8ad09382e87357dc081c2d00d05542dca9 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -774,6 +774,7 @@ > CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */; }; > CDA3159A1ED548F1009F60D3 /* MediaPlaybackSleepAssertion.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */; }; > CDA3159D1ED5643F009F60D3 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA3159C1ED5643F009F60D3 /* IOKit.framework */; }; >+ CDA4438E21F7A47700379489 /* ProcessSuspendMediaBuffering.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */; }; > CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB411591E09DA8E00EAD352 /* video-with-muted-audio.html */; }; > CDB5DFFF213610FA00D3E189 /* now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB5DFFE21360ED800D3E189 /* now-playing.html */; }; > CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; }; >@@ -2080,6 +2081,7 @@ > CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackSleepAssertion.mm; sourceTree = "<group>"; }; > CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = MediaPlaybackSleepAssertion.html; sourceTree = "<group>"; }; > CDA3159C1ED5643F009F60D3 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; >+ CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessSuspendMediaBuffering.mm; sourceTree = "<group>"; }; > CDB411591E09DA8E00EAD352 /* video-with-muted-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-muted-audio.html"; sourceTree = "<group>"; }; > CDB5DFFE21360ED800D3E189 /* now-playing.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "now-playing.html"; sourceTree = "<group>"; }; > CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenZoomInitialFrame.html; sourceTree = "<group>"; }; >@@ -2618,6 +2620,7 @@ > 37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */, > 93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */, > 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */, >+ CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */, > ); > name = "WebKit Cocoa"; > path = WebKitCocoa; >@@ -4328,6 +4331,7 @@ > 37A9DBE9213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm in Sources */, > 93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */, > 9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */, >+ CDA4438E21F7A47700379489 /* ProcessSuspendMediaBuffering.mm in Sources */, > 9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */, > ); > runOnlyForDeploymentPostprocessing = 0; >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspendMediaBuffering.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspendMediaBuffering.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..c584e4f0a05b7b495255d4214cac129fd1bca1b5 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspendMediaBuffering.mm >@@ -0,0 +1,65 @@ >+/* >+ * 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. >+ */ >+ >+#include "config.h" >+ >+#if WK_HAVE_C_SPI >+ >+#import "PlatformUtilities.h" >+#import "TestWKWebView.h" >+ >+#import <WebKit/WKWebViewConfigurationPrivate.h> >+#import <WebKit/WKWebViewPrivate.h> >+ >+TEST(WebKit, ProcessSuspendMediaBuffering) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ WKRetainPtr<WKContextRef> context(AdoptWK, TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest")); >+ configuration.get().processPool = (WKProcessPool *)context.get(); >+ configuration.get()._mediaDataLoadsAutomatically = YES; >+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]); >+ >+ __block bool isPlaying = false; >+ [webView performAfterReceivingMessage:@"playing" action:^() { isPlaying = true; }]; >+ >+ TestWebKitAPI::Util::run(&isPlaying); >+ >+ auto isElementAllowedToBuffer = [&] { >+ return [webView stringByEvaluatingJavaScript:@"window.internals.elementShouldBufferData(document.querySelector('video'))"].boolValue; >+ }; >+ >+ ASSERT_TRUE(isElementAllowedToBuffer()); >+ >+ [webView _processWillSuspendImminentlyForTesting]; >+ >+ ASSERT_FALSE(isElementAllowedToBuffer()); >+ >+ [webView _processDidResumeForTesting]; >+ >+ ASSERT_TRUE(isElementAllowedToBuffer()); >+} >+ >+#endif // WK_HAVE_C_SPI
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 193691
:
359789
|
360352
|
361418
|
361422
|
363016