⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277442 in webkit


Ignore:
Timestamp:
May 13, 2021, 11:23:49 AM (5 years ago)
Author:
jer.noble@apple.com
Message:

[ macOS Wk2 ] media/media-fragments/TC0051.html is flakey crashing
https://bugs.webkit.org/show_bug.cgi?id=222277
<rdar://problem/74600790>

Reviewed by Eric Carlson.

Source/WebCore:

In r274734, a workaround was added to detect a bug in the Photos.framework that would cause
an exception to be thrown if the URL provided to AVURLAsset had a malformed fragment identifier.
However, in an effort to reduce the runtime cost of this check, it was only done once, the first
time an AVURLAsset is created. This failed to account for the Photos.framework being dynamically
loaded and changing the behavior of AVURLAsset after the check had been performed.

Instead, fall back to a much simpler check: wrap the creation of the AVURLAsset in a @try/@catch
block, and if an exception was thrown, re-attempt to create the AVURLAsset with a manually
conformed URL.

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

(WebCore::conformFragmentIdentifierForURL):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
(WebCore::hasBrokenFragmentSupport): Deleted.

LayoutTests:

  • platform/mac-wk2/TestExpectations:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r277441 r277442  
     12021-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        [ macOS Wk2 ] media/media-fragments/TC0051.html is flakey crashing
     4        https://bugs.webkit.org/show_bug.cgi?id=222277
     5        <rdar://problem/74600790>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * platform/mac-wk2/TestExpectations:
     10
    1112021-05-13  Robert Jenner  <jenner@apple.com>
    212
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r277441 r277442  
    13441344webkit.org/b/224032 [ arm64 ] tiled-drawing/top-content-inset-fixed-attachment-cover-local.html [ Pass ImageOnlyFailure ]
    13451345
    1346 webkit.org/b/222277 media/media-fragments [ Skip ]
    1347 
    13481346webkit.org/b/224135 media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button.html [ Pass Timeout ]
    13491347
  • trunk/Source/WebCore/ChangeLog

    r277438 r277442  
     12021-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        [ macOS Wk2 ] media/media-fragments/TC0051.html is flakey crashing
     4        https://bugs.webkit.org/show_bug.cgi?id=222277
     5        <rdar://problem/74600790>
     6
     7        Reviewed by Eric Carlson.
     8
     9        In r274734, a workaround was added to detect a bug in the Photos.framework that would cause
     10        an exception to be thrown if the URL provided to AVURLAsset had a malformed fragment identifier.
     11        However, in an effort to reduce the runtime cost of this check, it was only done once, the first
     12        time an AVURLAsset is created. This failed to account for the Photos.framework being dynamically
     13        loaded and changing the behavior of AVURLAsset after the check had been performed.
     14
     15        Instead, fall back to a much simpler check: wrap the creation of the AVURLAsset in a @try/@catch
     16        block, and if an exception was thrown, re-attempt to create the AVURLAsset with a manually
     17        conformed URL.
     18
     19        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     20        (WebCore::conformFragmentIdentifierForURL):
     21        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
     22        (WebCore::hasBrokenFragmentSupport): Deleted.
     23
    1242021-05-13  Alicia Boya García  <aboya@igalia.com>
    225
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r277140 r277442  
    814814}
    815815
    816 static bool hasBrokenFragmentSupport()
     816static URL conformFragmentIdentifierForURL(const URL& url)
    817817{
    818818#if PLATFORM(MAC)
     
    823823    // criteria. Problematic strings from the TC0051.html test include "t=3&", and this problem generally is
    824824    // with subtrings between the '&' character not including an equal sign.
    825     static bool hasBrokenFragmentSupport = false;
    826     static dispatch_once_t onceToken;
    827     dispatch_once(&onceToken, ^{
    828         @try {
    829             auto selector = NSSelectorFromString(@"isURLForAssetInCollection:");
    830             auto theClass = PAL::getAVAssetCollectionClass();
    831             if (![theClass respondsToSelector:selector])
    832                 return;
    833             [theClass performSelector:selector withObject:[NSURL URLWithString:@"file:///invalid-file.mp4#t=3&"]];
    834         } @catch (NSException *exception) {
    835             hasBrokenFragmentSupport = true;
    836         }
    837     });
    838     return hasBrokenFragmentSupport;
    839 #else
    840     return false;
    841 #endif
    842 }
    843 
    844 static URL conformFragmentIdentifierForURL(const URL& url)
    845 {
    846 #if PLATFORM(MAC)
    847     ASSERT(hasBrokenFragmentSupport());
    848 
    849825    auto hasInvalidNumberOfEqualCharacters = [](const StringView& fragmentParameter) {
    850826        auto results = fragmentParameter.splitAllowingEmptyEntries('=');
     
    976952        registerFormatReaderIfNecessary();
    977953
    978     NSURL *cocoaURL = nil;
    979     if (hasBrokenFragmentSupport() && url.hasFragmentIdentifier())
     954    NSURL *cocoaURL = canonicalURL(url);
     955
     956    @try {
     957        m_avAsset = adoptNS([PAL::allocAVURLAssetInstance() initWithURL:cocoaURL options:options.get()]);
     958    } @catch(NSException *exception) {
     959        ERROR_LOG(LOGIDENTIFIER, "-[AVURLAssetInstance initWithURL:cocoaURL options:] threw an exception: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
    980960        cocoaURL = canonicalURL(conformFragmentIdentifierForURL(url));
    981     else
    982         cocoaURL = canonicalURL(url);
    983 
    984     m_avAsset = adoptNS([PAL::allocAVURLAssetInstance() initWithURL:cocoaURL options:options.get()]);
     961
     962        @try {
     963            m_avAsset = adoptNS([PAL::allocAVURLAssetInstance() initWithURL:cocoaURL options:options.get()]);
     964        } @catch(NSException *exception) {
     965            ASSERT_NOT_REACHED();
     966            ERROR_LOG(LOGIDENTIFIER, "-[AVURLAssetInstance initWithURL:cocoaURL options:] threw a second exception, bailing: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
     967            setNetworkState(MediaPlayer::NetworkState::FormatError);
     968            return;
     969        }
     970    }
    985971
    986972    AVAssetResourceLoader *resourceLoader = m_avAsset.get().resourceLoader;
Note: See TracChangeset for help on using the changeset viewer.