Changeset 254387 in webkit


Ignore:
Timestamp:
Jan 10, 2020 6:32:00 PM (4 years ago)
Author:
jer.noble@apple.com
Message:

[iOS] Audio from non-frontmost tab continues when app is backgrounded
https://bugs.webkit.org/show_bug.cgi?id=206101
<rdar://problem/58089916>

Reviewed by Eric Carlson.

Source/WebKit:

Tests: WKWebViewPausePlayingAudioTests.InWindow

WKWebViewPausePlayingAudioTests.OutOfWindow

The ApplicationStateTracker will only send notifications about application state to
WebPageProxies when those proxies' views are actually in-window. Add a separate application
state observer strictly for media which fires only when application state notifications are
received while the view is not in-window.

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentView.mm:

(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
(-[WKContentView _applicationDidEnterBackground:]):
(-[WKContentView _applicationWillEnterForeground:]):

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::applicationDidEnterBackgroundForMedia):
(WebKit::WebPageProxy::applicationWillEnterForegroundForMedia):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::applicationDidEnterBackgroundForMedia):
(WebKit::WebPage::applicationWillEnterForegroundForMedia):

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/ios/WKWebViewPausePlayingAudioTests.mm: Added.

(TestWebKitAPI::autoplayingConfiguration):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/platform/ipad/TestExpectations

    r253976 r254387  
    5555fast/scrolling/ios/body-overflow-hidden-height-100-percent-zoomed-1.html [ Skip ]
    5656
    57 # <rdar://problem/51918994> [ iPad Sim ] Layout test media/video-concurrent-visible-playback.html is a flaky timeout
    58 media/video-concurrent-visible-playback.html [ Pass Timeout ]
    59 
    60 # <rdar://problem/51920910> [ iPad Sim ] Layout test media/video-object-fit-change.html is a flaky timeout
    61 media/video-concurrent-visible-playback.html [ Pass Timeout ]
    62 
    6357# <rdar://problem/52914585> (Layout Test fast/forms/file/file-input-reset-using-open-panel.html is Failing)
    6458fast/forms/file/file-input-reset-using-open-panel.html [ ImageOnlyFailure ]
  • trunk/Source/WebKit/ChangeLog

    r254384 r254387  
     12020-01-10  Jer Noble  <jer.noble@apple.com>
     2
     3        [iOS] Audio from non-frontmost tab continues when app is backgrounded
     4        https://bugs.webkit.org/show_bug.cgi?id=206101
     5        <rdar://problem/58089916>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Tests: WKWebViewPausePlayingAudioTests.InWindow
     10               WKWebViewPausePlayingAudioTests.OutOfWindow
     11
     12        The ApplicationStateTracker will only send notifications about application state to
     13        WebPageProxies when those proxies' views are actually in-window. Add a separate application
     14        state observer strictly for media which fires only when application state notifications are
     15        received while the view is not in-window.
     16
     17        * UIProcess/WebPageProxy.h:
     18        * UIProcess/ios/WKContentView.mm:
     19        (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
     20        (-[WKContentView _applicationDidEnterBackground:]):
     21        (-[WKContentView _applicationWillEnterForeground:]):
     22        * UIProcess/ios/WebPageProxyIOS.mm:
     23        (WebKit::WebPageProxy::applicationDidEnterBackgroundForMedia):
     24        (WebKit::WebPageProxy::applicationWillEnterForegroundForMedia):
     25        * WebProcess/WebPage/WebPage.h:
     26        * WebProcess/WebPage/WebPage.messages.in:
     27        * WebProcess/WebPage/ios/WebPageIOS.mm:
     28        (WebKit::WebPage::applicationDidEnterBackgroundForMedia):
     29        (WebKit::WebPage::applicationWillEnterForegroundForMedia):
     30
    1312020-01-10  Simon Fraser  <simon.fraser@apple.com>
    232
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r254384 r254387  
    760760    void applicationWillResignActive();
    761761    void applicationDidBecomeActive();
     762    void applicationDidEnterBackgroundForMedia();
     763    void applicationWillEnterForegroundForMedia();
    762764    void commitPotentialTapFailed();
    763765    void didNotHandleTapAsClick(const WebCore::IntPoint&);
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r254241 r254387  
    204204    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]];
    205205    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]];
     206    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:[UIApplication sharedApplication]];
     207    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:[UIApplication sharedApplication]];
    206208
    207209#if USE(UIKIT_KEYBOARD_ADDITIONS)
     
    719721}
    720722
     723- (void)_applicationDidEnterBackground:(NSNotification*)notification
     724{
     725    if (!self.window)
     726        _page->applicationDidEnterBackgroundForMedia();
     727}
     728
     729- (void)_applicationWillEnterForeground:(NSNotification*)notification
     730{
     731    if (!self.window)
     732        _page->applicationWillEnterForegroundForMedia();
     733}
     734
    721735@end
    722736
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r254345 r254387  
    697697}
    698698
     699void WebPageProxy::applicationDidEnterBackgroundForMedia()
     700{
     701    bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
     702    RELEASE_LOG_IF_ALLOWED(ViewState, "applicationWillEnterForegroundForMedia: isSuspendedUnderLock? %d", isSuspendedUnderLock);
     703
     704    m_process->send(Messages::WebPage::ApplicationDidEnterBackgroundForMedia(isSuspendedUnderLock), m_webPageID);
     705}
     706
     707void WebPageProxy::applicationWillEnterForegroundForMedia()
     708{
     709    bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
     710    RELEASE_LOG_IF_ALLOWED(ViewState, "applicationDidEnterBackgroundForMedia: isSuspendedUnderLock? %d", isSuspendedUnderLock);
     711
     712    m_process->send(Messages::WebPage::ApplicationWillEnterForegroundForMedia(isSuspendedUnderLock), m_webPageID);
     713}
     714
    699715void WebPageProxy::applicationDidBecomeActive()
    700716{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r254384 r254387  
    978978    void applicationWillEnterForeground(bool isSuspendedUnderLock);
    979979    void applicationDidBecomeActive();
     980    void applicationDidEnterBackgroundForMedia(bool isSuspendedUnderLock);
     981    void applicationWillEnterForegroundForMedia(bool isSuspendedUnderLock);
    980982    void didFinishContentChangeObserving(WKContentChange);
    981983
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r254183 r254387  
    100100    ApplicationWillEnterForeground(bool isSuspendedUnderLock)
    101101    ApplicationDidBecomeActive()
     102    ApplicationDidEnterBackgroundForMedia(bool isSuspendedUnderLock)
     103    ApplicationWillEnterForegroundForMedia(bool isSuspendedUnderLock)
    102104    ContentSizeCategoryDidChange(String contentSizeCategory)
    103105    GetSelectionContext(WebKit::CallbackID callbackID)
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r254153 r254387  
    35973597}
    35983598
     3599void WebPage::applicationDidEnterBackgroundForMedia(bool isSuspendedUnderLock)
     3600{
     3601    [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidEnterBackgroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": @(isSuspendedUnderLock)}];
     3602}
     3603
     3604void WebPage::applicationWillEnterForegroundForMedia(bool isSuspendedUnderLock)
     3605{
     3606    [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillEnterForegroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": @(isSuspendedUnderLock)}];
     3607}
     3608
    35993609static inline void adjustVelocityDataForBoundedScale(VelocityData& velocityData, double exposedRectScale, double minimumScale, double maximumScale)
    36003610{
  • trunk/Tools/ChangeLog

    r254383 r254387  
     12020-01-10  Jer Noble  <jer.noble@apple.com>
     2
     3        [iOS] Audio from non-frontmost tab continues when app is backgrounded
     4        https://bugs.webkit.org/show_bug.cgi?id=206101
     5        <rdar://problem/58089916>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/ios/WKWebViewPausePlayingAudioTests.mm: Added.
     11        (TestWebKitAPI::autoplayingConfiguration):
     12        (TestWebKitAPI::TEST):
     13
    1142020-01-10  Jonathan Bedard  <jbedard@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r254183 r254387  
    902902                CD0BD0A81F79982D001AB2CF /* ContextMenuImgWithVideo.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */; };
    903903                CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD227E43211A4D5D00D285AF /* PreferredAudioBufferSize.mm */; };
     904                CD27A1C123C661ED006E11DD /* WKWebViewPausePlayingAudioTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD27A1C023C661ED006E11DD /* WKWebViewPausePlayingAudioTests.mm */; };
    904905                CD2D0D1A213465560018C784 /* NowPlaying.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD2D0D19213465560018C784 /* NowPlaying.mm */; };
    905906                CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */; };
     
    24162417                CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; };
    24172418                CD227E43211A4D5D00D285AF /* PreferredAudioBufferSize.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferredAudioBufferSize.mm; sourceTree = "<group>"; };
     2419                CD27A1C023C661ED006E11DD /* WKWebViewPausePlayingAudioTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewPausePlayingAudioTests.mm; sourceTree = "<group>"; };
    24182420                CD2D0D19213465560018C784 /* NowPlaying.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlaying.mm; sourceTree = "<group>"; };
    24192421                CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoQualityDisplayCompositing.mm; sourceTree = "<group>"; };
     
    32223224                                514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */,
    32233225                                1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */,
     3226                                CD27A1C023C661ED006E11DD /* WKWebViewPausePlayingAudioTests.mm */,
    32243227                        );
    32253228                        path = ios;
     
    48524855                                7C83E0C41D0A654200FEBCF3 /* RequiresUserActionForPlayback.mm in Sources */,
    48534856                                7CCE7F0E1A411AE600447C4C /* ResizeReversePaginatedWebView.cpp in Sources */,
     4857                                CD27A1C123C661ED006E11DD /* WKWebViewPausePlayingAudioTests.mm in Sources */,
    48544858                                7CCE7F0F1A411AE600447C4C /* ResizeWindowAfterCrash.cpp in Sources */,
    48554859                                5CB7AFDC23C4529700E49CF3 /* ResourceLoadDelegate.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.