Bug 106285 - [Track] Closed Caption button shouldn't be visible if all the track resources have failed loading
Summary: [Track] Closed Caption button shouldn't be visible if all the track resources...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Victor Carbune
URL:
Keywords: InRadar
Depends on:
Blocks: 43668
  Show dependency treegraph
 
Reported: 2013-01-07 18:17 PST by Silvia Pfeiffer
Modified: 2013-01-31 20:04 PST (History)
5 users (show)

See Also:


Attachments
Patch (9.53 KB, patch)
2013-01-29 12:36 PST, Victor Carbune
no flags Details | Formatted Diff | Diff
Extra method (11.28 KB, patch)
2013-01-31 16:49 PST, Victor Carbune
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Silvia Pfeiffer 2013-01-07 18:17:58 PST
Closed Caption button shouldn't be visible if all the track resources have failed loading, e.g. a single track, but failed cross-origin
request, see https://bugs.webkit.org/show_bug.cgi?id=103110
Comment 1 Victor Carbune 2013-01-23 13:41:02 PST
On a second thought, I think showing a button in a disabled state would be 
better. This would indicate that <track> elements are present and are supposed
to be shown, but something went wrong.

Clicking on it in that disabled state should try reloading the tracks.
Would this make sense?
Comment 2 Silvia Pfeiffer 2013-01-23 18:16:09 PST
Sounds good to me.
Comment 3 Eric Carlson 2013-01-24 11:10:01 PST
(In reply to comment #1)
> On a second thought, I think showing a button in a disabled state would be 
> better. This would indicate that <track> elements are present and are supposed
> to be shown, but something went wrong.
> 
> Clicking on it in that disabled state should try reloading the tracks.
> Would this make sense?

In what circumstances would reloading work? How is a user supposed to know that clicking a disabled button would have this action?
Comment 4 Victor Carbune 2013-01-25 06:39:41 PST
(In reply to comment #3)
> (In reply to comment #1)
> > On a second thought, I think showing a button in a disabled state would be 
> > better. This would indicate that <track> elements are present and are supposed
> > to be shown, but something went wrong.
> > 
> > Clicking on it in that disabled state should try reloading the tracks.
> > Would this make sense?
> 
> In what circumstances would reloading work? How is a user supposed to know that clicking a disabled button would have this action?

What happens right now if a track wasn't loaded because the machine serving
it is down, or there are communication issues? Does it retry indefinitely?

I was thinking at these cases particularly; the track failed loading, but
then the machine serving it becomes available and the user can force a retry
toggling the disabled button.
Comment 5 Eric Carlson 2013-01-25 10:41:49 PST
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #1)
> > > On a second thought, I think showing a button in a disabled state would be 
> > > better. This would indicate that <track> elements are present and are supposed
> > > to be shown, but something went wrong.
> > > 
> > > Clicking on it in that disabled state should try reloading the tracks.
> > > Would this make sense?
> > 
> > In what circumstances would reloading work? How is a user supposed to know that clicking a disabled button would have this action?
> 
> What happens right now if a track wasn't loaded because the machine serving
> it is down, or there are communication issues? Does it retry indefinitely?
> 
  The same thing that happens when any other resource (eg. image, script, etc) doesn't load - nothing.

> I was thinking at these cases particularly; the track failed loading, but
> then the machine serving it becomes available and the user can force a retry
> toggling the disabled button.
>
  I think just reloading the page makes sense, that way all resources from the same server will reload.
Comment 6 Silvia Pfeiffer 2013-01-25 13:59:10 PST
Hmm I think I agree with Eric - you can always hit the browser "reload" button to get the captions. YouTube doesn't do a reload either.

Also note that the resources in a list of <track> elements may not all come from the same server. If they all don't load, it's probably not necessary to display a button.
Comment 7 Victor Carbune 2013-01-29 12:36:10 PST
Created attachment 185287 [details]
Patch

Updated behavior in several places
Comment 8 Eric Carlson 2013-01-30 11:54:39 PST
Comment on attachment 185287 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=185287&action=review

> Source/WebCore/html/HTMLMediaElement.cpp:1336
> +        if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading
> +            || m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::NotLoaded)
>              return false;

Won't this allow m_readyState to get stuck at HAVE_CURRENT_DATA if a track fails to load?
Comment 9 Victor Carbune 2013-01-30 16:33:23 PST
(In reply to comment #8)
> (From update of attachment 185287 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185287&action=review
> 
> > Source/WebCore/html/HTMLMediaElement.cpp:1336
> > +        if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading
> > +            || m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::NotLoaded)
> >              return false;
> 
> Won't this allow m_readyState to get stuck at HAVE_CURRENT_DATA if a track fails to load?

I will look closer in the code, but do you have a specific case in which you
would expect to fail (i.e., visually / behavior?)
Comment 10 Eric Carlson 2013-01-31 06:46:30 PST
(In reply to comment #9)
> (In reply to comment #8)
> > (From update of attachment 185287 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=185287&action=review
> > 
> > > Source/WebCore/html/HTMLMediaElement.cpp:1336
> > > +        if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading
> > > +            || m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::NotLoaded)
> > >              return false;
> > 
> > Won't this allow m_readyState to get stuck at HAVE_CURRENT_DATA if a track fails to load?
> 
> I will look closer in the code, but do you have a specific case in which you
> would expect to fail (i.e., visually / behavior?)

HTMLMediaElement::mediaPlayerReadyStateChanged has this:

    if (tracksAreReady)
        m_readyState = newState;
    else {
        // If a media file has text tracks the readyState may not progress beyond HAVE_FUTURE_DATA until
        // the text tracks are ready, regardless of the state of the media file.
        if (newState <= HAVE_METADATA)
            m_readyState = newState;
        else
            m_readyState = HAVE_CURRENT_DATA;
    }

So I believe that a track that never loads, eg. one that has a bogus url, will prevent the element's m_readyState from advancing beyond HAVE_CURRENT_DATA.
Comment 11 Victor Carbune 2013-01-31 11:48:02 PST
(In reply to comment #10)
> So I believe that a track that never loads, eg. one that has a bogus url, will prevent the element's m_readyState from advancing beyond HAVE_CURRENT_DATA.

I think we're safe: if it fails to load, the readinessState changes to FailedToLoad and doesn't remain NotLoaded (as this is the check I added)
 
It's following the spec comment from ::textTracksAreReady - "[...] have a text track readiness state of loaded or failed to load." so it should be fine.

I manually tested, but I could add the case in a layout test as well if you
prefer.
Comment 12 Eric Carlson 2013-01-31 13:58:52 PST
(In reply to comment #11)
> (In reply to comment #10)
> > So I believe that a track that never loads, eg. one that has a bogus url, will prevent the element's m_readyState from advancing beyond HAVE_CURRENT_DATA.
> 
> I think we're safe: if it fails to load, the readinessState changes to FailedToLoad and doesn't remain NotLoaded (as this is the check I added)
> 
> It's following the spec comment from ::textTracksAreReady - "[...] have a text track readiness state of loaded or failed to load." so it should be fine.
> 
  You are correct, of course. 

> I manually tested, but I could add the case in a layout test as well if you
> prefer.
>
  I think this is already covered by the existing tests, if it actually was a problem a <video> with an unload able <track> would never reach canplaythrough.
Comment 13 Victor Carbune 2013-01-31 16:49:06 PST
Created attachment 185897 [details]
Extra method

Added extra method for refreshing the cc button visibility
Comment 14 Radar WebKit Bug Importer 2013-01-31 19:50:48 PST
<rdar://problem/13131121>
Comment 15 WebKit Review Bot 2013-01-31 20:04:38 PST
Comment on attachment 185897 [details]
Extra method

Clearing flags on attachment: 185897

Committed r141531: <http://trac.webkit.org/changeset/141531>
Comment 16 WebKit Review Bot 2013-01-31 20:04:43 PST
All reviewed patches have been landed.  Closing bug.