Changeset 219305 in webkit


Ignore:
Timestamp:
Jul 10, 2017 12:49:29 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

media element handle adding source immediately before src.
https://bugs.webkit.org/show_bug.cgi?id=174284
rdar://problem/33115439

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-07-10
Reviewed by David Kilzer.

Source/WebCore:

Test: media/video-source-before-src.html

Adding a source causes a selectMediaResource block to be enqueued.
If dataLoadingPermitted prevents creating the m_player but sets the srcAttr, then
the enqueued selectMediaResource will be in a bad state, with a srcAttr but no m_player.

This fix prevents selectMediaResource from being called, if data loading is not permitted
when adding a source element, to match how it prevents player creation when setting srcAttr.

This fix also adds a debug assert to catch the problem earlier and adds an early return to
prevent the crash in release builds.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::selectMediaResource):
(WebCore::HTMLMediaElement::sourceWasAdded):

LayoutTests:

  • media/video-source-before-src.html: Added.
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219303 r219305  
     12017-07-10  Jeremy Jones  <jeremyj@apple.com>
     2
     3        media element handle adding source immediately before src.
     4        https://bugs.webkit.org/show_bug.cgi?id=174284
     5        rdar://problem/33115439
     6
     7        Reviewed by David Kilzer.
     8
     9        * media/video-source-before-src.html: Added.
     10
    1112017-07-10  Matt Lewis  <jlewis3@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r219304 r219305  
     12017-07-10  Jeremy Jones  <jeremyj@apple.com>
     2
     3        media element handle adding source immediately before src.
     4        https://bugs.webkit.org/show_bug.cgi?id=174284
     5        rdar://problem/33115439
     6
     7        Reviewed by David Kilzer.
     8
     9        Test: media/video-source-before-src.html
     10
     11        Adding a source causes a selectMediaResource block to be enqueued.
     12        If dataLoadingPermitted prevents creating the m_player but sets the srcAttr, then
     13        the enqueued selectMediaResource will be in a bad state, with a srcAttr but no m_player.
     14
     15        This fix prevents selectMediaResource from being called, if data loading is not permitted
     16        when adding a source element, to match how it prevents player creation when setting srcAttr.
     17
     18        This fix also adds a debug assert to catch the problem earlier and adds an early return to
     19        prevent the crash in release builds.
     20
     21        * html/HTMLMediaElement.cpp:
     22        (WebCore::HTMLMediaElement::selectMediaResource):
     23        (WebCore::HTMLMediaElement::sourceWasAdded):
     24
    1252017-07-10  Megan Gardner  <megan_gardner@apple.com>
    226
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r219237 r219305  
    13241324            //    Otherwise, if the media element has no assigned media provider object but has a src attribute, then let mode be attribute.
    13251325            mode = Attribute;
     1326            ASSERT(m_player);
     1327            if (!m_player) {
     1328                RELEASE_LOG_ERROR(Media, "HTMLMediaElement::selectMediaResource(%p) - has srcAttr but m_player is not created", this);
     1329                return;
     1330            }
    13261331        } else if (auto firstSource = childrenOfType<HTMLSourceElement>(*this).first()) {
    13271332            //    Otherwise, if the media element does not have an assigned media provider object and does not have a src attribute,
     
    43634368    // attribute and whose networkState has the value NETWORK_EMPTY, the user agent must invoke
    43644369    // the media element's resource selection algorithm.
    4365     if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
     4370    if (m_networkState == NETWORK_EMPTY) {
    43664371        m_nextChildNodeToConsider = &source;
    4367         selectMediaResource();
     4372#if PLATFORM(IOS)
     4373        if (m_mediaSession->dataLoadingPermitted(*this))
     4374#endif
     4375            selectMediaResource();
    43684376        return;
    43694377    }
Note: See TracChangeset for help on using the changeset viewer.