Changeset 293609 in webkit


Ignore:
Timestamp:
Apr 29, 2022 12:57:59 AM (3 months ago)
Author:
youenn@apple.com
Message:

HTMLMediaElement can get multiple interruptions for invisible autoplay
https://bugs.webkit.org/show_bug.cgi?id=239842
<rdar://91809550>

Reviewed by Eric Carlson.

Source/WebCore:

A media element may be interrupted for invisible autoplay.
In some cases, like by calling play on the media element, the media element will no longer be in interrupted state.
This will lead to multiple invisible autoplay interruptions to be added to the same media element.
There will be only one end of interruption for invisible autoplay, which will lead to the media element to not restart as expected.

To prevent this, we store a boolean in HTMLMediaElement that tells us whether the media element has an ongoing invisible autoplay interruption.
Based on that, we make sure to always balance invisible autoplay interruption begin and end.

Test: media/video-mediastream-restricted-invisible-autoplay-not-allowed.html

  • html/HTMLMediaElement.cpp:
  • html/HTMLMediaElement.h:

LayoutTests:

  • fast/mediastream/video-mediastream-restricted-invisible-autoplay-not-allowed-expected.txt: Added.
  • fast/mediastream/video-mediastream-restricted-invisible-autoplay-not-allowed.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293603 r293609  
     12022-04-29  Youenn Fablet  <youenn@apple.com>
     2
     3        HTMLMediaElement can get multiple interruptions for invisible autoplay
     4        https://bugs.webkit.org/show_bug.cgi?id=239842
     5        <rdar://91809550>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * fast/mediastream/video-mediastream-restricted-invisible-autoplay-not-allowed-expected.txt: Added.
     10        * fast/mediastream/video-mediastream-restricted-invisible-autoplay-not-allowed.html: Added.
     11
    1122022-04-28  Patrick Griffis  <pgriffis@igalia.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r293607 r293609  
     12022-04-29  Youenn Fablet  <youenn@apple.com>
     2
     3        HTMLMediaElement can get multiple interruptions for invisible autoplay
     4        https://bugs.webkit.org/show_bug.cgi?id=239842
     5        <rdar://91809550>
     6
     7        Reviewed by Eric Carlson.
     8
     9        A media element may be interrupted for invisible autoplay.
     10        In some cases, like by calling play on the media element, the media element will no longer be in interrupted state.
     11        This will lead to multiple invisible autoplay interruptions to be added to the same media element.
     12        There will be only one end of interruption for invisible autoplay, which will lead to the media element to not restart as expected.
     13
     14        To prevent this, we store a boolean in HTMLMediaElement that tells us whether the media element has an ongoing invisible autoplay interruption.
     15        Based on that, we make sure to always balance invisible autoplay interruption begin and end.
     16
     17        Test: media/video-mediastream-restricted-invisible-autoplay-not-allowed.html
     18
     19        * html/HTMLMediaElement.cpp:
     20        * html/HTMLMediaElement.h:
     21
    1222022-04-29  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r293488 r293609  
    83808380
    83818381    if (canAutoplay) {
    8382         if (mediaSession().state() == PlatformMediaSession::Interrupted) {
    8383             if (mediaSession().interruptionType() == PlatformMediaSession::InvisibleAutoplay)
    8384                 mediaSession().endInterruption(PlatformMediaSession::MayResumePlaying);
    8385         } else if (!isPlaying())
     8382        if (m_wasInterruptedForInvisibleAutoplay) {
     8383            m_wasInterruptedForInvisibleAutoplay = false;
     8384            mediaSession().endInterruption(PlatformMediaSession::MayResumePlaying);
     8385            return;
     8386        }
     8387        if (!isPlaying())
    83868388            resumeAutoplaying();
    83878389        return;
    83888390    }
    8389     if (mediaSession().state() != PlatformMediaSession::Interrupted)
    8390         mediaSession().beginInterruption(PlatformMediaSession::InvisibleAutoplay);
     8391
     8392    if (mediaSession().state() == PlatformMediaSession::Interrupted)
     8393        return;
     8394
     8395    if (m_wasInterruptedForInvisibleAutoplay) {
     8396        m_wasInterruptedForInvisibleAutoplay = false;
     8397        mediaSession().endInterruption(PlatformMediaSession::NoFlags);
     8398    }
     8399
     8400    m_wasInterruptedForInvisibleAutoplay = true;
     8401    mediaSession().beginInterruption(PlatformMediaSession::InvisibleAutoplay);
    83918402}
    83928403
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r292585 r293609  
    12491249    AudioSessionCategory m_categoryAtMostRecentPlayback;
    12501250#endif
     1251    bool m_wasInterruptedForInvisibleAutoplay { false };
    12511252};
    12521253
Note: See TracChangeset for help on using the changeset viewer.