Changeset 148064 in webkit


Ignore:
Timestamp:
Apr 9, 2013 4:52:23 PM (11 years ago)
Author:
jer.noble@apple.com
Message:

hang in mediaSelectionGroupForMediaCharacteristic
https://bugs.webkit.org/show_bug.cgi?id=114054

Reviewed by Eric Carlson.

No new tests; Fixes sporadic hangs in media/ tests.

-[AVURLAsset mediaSelectionGroupForMediaCharacteristic:] can deadlock in certain situations: When AVURLAsset
posts a synchronous AVAssetResourceLoader notification to the main thread, calling -mediaSelectionGroupForMediaCharacteristic:
on the main thread requires IO to occur if the media characteristics are not yet loaded. Instead of blocking,
bail out early if the media characteristics are not yet known.

Add a new method, safeMediaSelectionGroupForLegibleMedia(), which first checks selection group availability
before calling mediaSelectionGroupForMediaCharacteristic:.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:

(MediaPlayerPrivateAVFoundationObjC):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::safeMediaSelectionGroupForLegibleMedia): Added.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Use new safe method.
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::processTextTracks): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTrack): Ditto.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148063 r148064  
     12013-04-09  Jer Noble  <jer.noble@apple.com>
     2
     3        hang in mediaSelectionGroupForMediaCharacteristic
     4        https://bugs.webkit.org/show_bug.cgi?id=114054
     5
     6        Reviewed by Eric Carlson.
     7
     8        No new tests; Fixes sporadic hangs in media/ tests.
     9
     10        -[AVURLAsset mediaSelectionGroupForMediaCharacteristic:] can deadlock in certain situations: When AVURLAsset
     11        posts a synchronous AVAssetResourceLoader notification to the main thread, calling -mediaSelectionGroupForMediaCharacteristic:
     12        on the main thread requires IO to occur if the media characteristics are not yet loaded. Instead of blocking,
     13        bail out early if the media characteristics are not yet known.
     14       
     15        Add a new method, safeMediaSelectionGroupForLegibleMedia(), which first checks selection group availability
     16        before calling mediaSelectionGroupForMediaCharacteristic:.
     17
     18        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     19        (MediaPlayerPrivateAVFoundationObjC):
     20        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     21        (WebCore::MediaPlayerPrivateAVFoundationObjC::safeMediaSelectionGroupForLegibleMedia): Added.
     22        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Use new safe method.
     23        (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Ditto.
     24        (WebCore::MediaPlayerPrivateAVFoundationObjC::processTextTracks): Ditto.
     25        (WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTrack): Ditto.
     26
    1272013-04-09  Chris Fleizach  <cfleizach@apple.com>
    228
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r147675 r148064  
    3333
    3434OBJC_CLASS AVURLAsset;
     35OBJC_CLASS AVMediaSelectionGroup;
    3536OBJC_CLASS AVPlayer;
    3637OBJC_CLASS AVPlayerItem;
     
    167168    void processTextTracks();
    168169    void clearTextTracks();
     170    AVMediaSelectionGroup* safeMediaSelectionGroupForLegibleMedia();
    169171#endif
    170172
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r148050 r148064  
    467467    // We enabled automatic media selection because we want alternate audio tracks to be enabled/disabled automatically,
    468468    // but set the selected legible track to nil so text tracks will not be automatically configured.
    469     [m_avPlayerItem.get() selectMediaOption:nil inMediaSelectionGroup:[m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible]];
     469    [m_avPlayerItem.get() selectMediaOption:nil inMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
    470470
    471471    [m_legibleOutput.get() setDelegate:m_objcObserver.get() queue:dispatch_get_main_queue()];
     
    986986#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
    987987    if (!hasCaptions && m_legibleOutput) {
    988         AVMediaSelectionGroupType *legibleGroup = [m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
     988        AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia();
    989989        hasCaptions = [[AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]] count];
    990990    }
     
    12971297}
    12981298
     1299AVMediaSelectionGroupType* MediaPlayerPrivateAVFoundationObjC::safeMediaSelectionGroupForLegibleMedia()
     1300{
     1301    if (!m_avAsset)
     1302        return nil;
     1303
     1304    if ([m_avAsset.get() statusOfValueForKey:@"availableMediaCharacteristicsWithMediaSelectionOptions" error:NULL] != AVKeyValueStatusLoaded)
     1305        return nil;
     1306
     1307    return [m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
     1308}
     1309
    12991310void MediaPlayerPrivateAVFoundationObjC::processTextTracks()
    13001311{
    1301     AVMediaSelectionGroupType *legibleGroup = [m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
     1312    AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia();
    13021313    if (!legibleGroup) {
    13031314        LOG(Media, "MediaPlayerPrivateAVFoundationObjC::processTextTracks(%p) - nil mediaSelectionGroup", this);
     
    13691380    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(%p) - selecting media option %p, language = %s", this, mediaSelectionOption, [[[mediaSelectionOption locale] localeIdentifier] UTF8String]);
    13701381
    1371     [m_avPlayerItem.get() selectMediaOption:mediaSelectionOption inMediaSelectionGroup:[m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible]];
     1382    [m_avPlayerItem.get() selectMediaOption:mediaSelectionOption inMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
    13721383    m_currentTrack = trackPrivate;
    13731384}
Note: See TracChangeset for help on using the changeset viewer.