<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169647] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169647">169647</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-06-06 09:20:31 -0700 (Fri, 06 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION(169440): Repro crash when playing a video with captions
https://bugs.webkit.org/show_bug.cgi?id=133459
<rdar://problem/17079081>
Reviewed by Eric Carlson.
The change I made in <a href="http://trac.webkit.org/projects/webkit/changeset/169440">r169440</a> introduced a crash for paint-on captions. This
resolves the problem as follows:
1. No longer attempt to modify the start/endTime in the TextTrack implementation.
2. Check for extensions to existing cues when we are about to add new arriving
cues. If they extend a current pending cue, don't set an end-time for the
pending cue, and throw away the new duplicate. Otherwise set the end time
as previously and continue.
* html/track/TextTrack.cpp:
(WebCore::TextTrack::hasCue): Remove 'doesExtendCue' case since this is
no longer possible.
* platform/graphics/InbandTextTrackPrivateClient.h:
(WebCore::GenericCueData::doesExtendCueData): Added.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processCue): Check for cues extending
other cues and handle appropriately.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmltrackTextTrackcpp">trunk/Source/WebCore/html/track/TextTrack.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsInbandTextTrackPrivateClienth">trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationInbandTextTrackPrivateAVFcpp">trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169646 => 169647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-06 16:19:54 UTC (rev 169646)
+++ trunk/Source/WebCore/ChangeLog        2014-06-06 16:20:31 UTC (rev 169647)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-06-05 Brent Fulgham <bfulgham@apple.com>
+
+ REGRESSION(169440): Repro crash when playing a video with captions
+ https://bugs.webkit.org/show_bug.cgi?id=133459
+ <rdar://problem/17079081>
+
+ Reviewed by Eric Carlson.
+
+ The change I made in r169440 introduced a crash for paint-on captions. This
+ resolves the problem as follows:
+ 1. No longer attempt to modify the start/endTime in the TextTrack implementation.
+ 2. Check for extensions to existing cues when we are about to add new arriving
+ cues. If they extend a current pending cue, don't set an end-time for the
+ pending cue, and throw away the new duplicate. Otherwise set the end time
+ as previously and continue.
+
+ * html/track/TextTrack.cpp:
+ (WebCore::TextTrack::hasCue): Remove 'doesExtendCue' case since this is
+ no longer possible.
+ * platform/graphics/InbandTextTrackPrivateClient.h:
+ (WebCore::GenericCueData::doesExtendCueData): Added.
+ * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+ (WebCore::InbandTextTrackPrivateAVF::processCue): Check for cues extending
+ other cues and handle appropriately.
+
</ins><span class="cx"> 2014-06-06 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> ROLLOUT: r169630: Caused a retain cycle.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackTextTrackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (169646 => 169647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/TextTrack.cpp        2014-06-06 16:19:54 UTC (rev 169646)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp        2014-06-06 16:20:31 UTC (rev 169647)
</span><span class="lines">@@ -522,11 +522,6 @@
</span><span class="cx"> if (!existingCue)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (existingCue->doesExtendCue(*cue)) {
- existingCue->setEndTime(cue->endTime(), IGNORE_EXCEPTION);
- return true;
- }
-
</del><span class="cx"> if (cue->startTime() > (existingCue->startTime() + startTimeVariance()))
</span><span class="cx"> return false;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsInbandTextTrackPrivateClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h (169646 => 169647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h        2014-06-06 16:19:54 UTC (rev 169646)
+++ trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h        2014-06-06 16:20:31 UTC (rev 169647)
</span><span class="lines">@@ -100,7 +100,9 @@
</span><span class="cx"> };
</span><span class="cx"> Status status() { return m_status; }
</span><span class="cx"> void setStatus(Status status) { m_status = status; }
</span><del>-
</del><ins>+
+ bool doesExtendCueData(const GenericCueData&) const;
+
</ins><span class="cx"> private:
</span><span class="cx"> GenericCueData()
</span><span class="cx"> : m_startTime(0)
</span><span class="lines">@@ -132,6 +134,36 @@
</span><span class="cx"> Status m_status;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+inline bool GenericCueData::doesExtendCueData(const GenericCueData& other) const
+{
+ if (m_relativeFontSize != other.m_relativeFontSize)
+ return false;
+ if (m_baseFontSize != other.m_baseFontSize)
+ return false;
+ if (m_position != other.m_position)
+ return false;
+ if (m_line != other.m_line)
+ return false;
+ if (m_size != other.m_size)
+ return false;
+ if (m_align != other.m_align)
+ return false;
+ if (m_foregroundColor != other.m_foregroundColor)
+ return false;
+ if (m_backgroundColor != other.m_backgroundColor)
+ return false;
+ if (m_highlightColor != other.m_highlightColor)
+ return false;
+ if (m_fontName != other.m_fontName)
+ return false;
+ if (m_id != other.m_id)
+ return false;
+ if (m_content != other.m_content)
+ return false;
+
+ return true;
+}
+
</ins><span class="cx"> class InbandTextTrackPrivateClient : public TrackPrivateBaseClient {
</span><span class="cx"> public:
</span><span class="cx"> virtual ~InbandTextTrackPrivateClient() { }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationInbandTextTrackPrivateAVFcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (169646 => 169647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp        2014-06-06 16:19:54 UTC (rev 169646)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp        2014-06-06 16:20:31 UTC (rev 169647)
</span><span class="lines">@@ -360,20 +360,64 @@
</span><span class="cx">
</span><span class="cx"> LOG(Media, "InbandTextTrackPrivateAVF::processCue - %li cues at time %.2f\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, time);
</span><span class="cx">
</span><ins>+ Vector<RefPtr<GenericCueData>> arrivingCues;
+ if (attributedStrings) {
+ CFIndex count = CFArrayGetCount(attributedStrings);
+ for (CFIndex i = 0; i < count; i++) {
+ CFAttributedStringRef attributedString = static_cast<CFAttributedStringRef>(CFArrayGetValueAtIndex(attributedStrings, i));
+
+ if (!attributedString || !CFAttributedStringGetLength(attributedString))
+ continue;
+
+ RefPtr<GenericCueData> cueData = GenericCueData::create();
+ processCueAttributes(attributedString, cueData.get());
+ if (!cueData->content().length())
+ continue;
+
+ arrivingCues.append(cueData);
+
+ cueData->setStartTime(time);
+ cueData->setEndTime(std::numeric_limits<double>::infinity());
+
+ // AVFoundation cue "position" is to the center of the text so adjust relative to the edge because we will use it to
+ // set CSS "left".
+ if (cueData->position() >= 0 && cueData->size() > 0)
+ cueData->setPosition(cueData->position() - cueData->size() / 2);
+
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - considering cue for time = %.2f, position = %.2f, line = %.2f", this, cueData->startTime(), cueData->position(), cueData->line());
+
+ cueData->setStatus(GenericCueData::Partial);
+ }
+ }
+
</ins><span class="cx"> if (m_pendingCueStatus != None) {
</span><span class="cx"> // Cues do not have an explicit duration, they are displayed until the next "cue" (which might be empty) is emitted.
</span><span class="cx"> m_currentCueEndTime = time;
</span><span class="cx">
</span><span class="cx"> if (m_currentCueEndTime >= m_currentCueStartTime) {
</span><del>- for (size_t i = 0; i < m_cues.size(); i++) {
- GenericCueData* cueData = m_cues[i].get();
</del><ins>+ for (auto& cueData : m_cues) {
+ // See if one of the newly-arrived cues is an extension of this cue.
+ Vector<RefPtr<GenericCueData>> nonExtensionCues;
+ for (auto& arrivingCue : arrivingCues) {
+ if (!arrivingCue->doesExtendCueData(*cueData))
+ nonExtensionCues.append(arrivingCue);
+ else
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - found an extension cue for time = %.2f, position = %.2f, line = %.2f", this, arrivingCue->startTime(), arrivingCue->position(), arrivingCue->line());
+ }
</ins><span class="cx">
</span><ins>+ bool currentCueIsExtended = (arrivingCues.size() != nonExtensionCues.size());
+
+ arrivingCues = nonExtensionCues;
+
+ if (currentCueIsExtended)
+ continue;
+
</ins><span class="cx"> if (m_pendingCueStatus == Valid) {
</span><span class="cx"> cueData->setEndTime(m_currentCueEndTime);
</span><span class="cx"> cueData->setStatus(GenericCueData::Complete);
</span><span class="cx">
</span><span class="cx"> LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - updating cue: start=%.2f, end=%.2f, content=\"%s\"", this, cueData->startTime(), m_currentCueEndTime, cueData->content().utf8().data());
</span><del>- client()->updateGenericCue(this, cueData);
</del><ins>+ client()->updateGenericCue(this, cueData.get());
</ins><span class="cx"> } else {
</span><span class="cx"> // We have to assume that the implicit duration is invalid for cues delivered during a seek because the AVF decode pipeline may not
</span><span class="cx"> // see every cue, so DO NOT update cue duration while seeking.
</span><span class="lines">@@ -386,38 +430,17 @@
</span><span class="cx"> resetCueValues();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!attributedStrings)
</del><ins>+ if (arrivingCues.isEmpty())
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- CFIndex count = CFArrayGetCount(attributedStrings);
- if (!count)
- return;
</del><ins>+ m_currentCueStartTime = time;
</ins><span class="cx">
</span><del>- for (CFIndex i = 0; i < count; i++) {
- CFAttributedStringRef attributedString = static_cast<CFAttributedStringRef>(CFArrayGetValueAtIndex(attributedStrings, i));
</del><ins>+ for (auto& cueData : arrivingCues) {
</ins><span class="cx">
</span><del>- if (!attributedString || !CFAttributedStringGetLength(attributedString))
- continue;
-
- RefPtr<GenericCueData> cueData = GenericCueData::create();
- processCueAttributes(attributedString, cueData.get());
- if (!cueData->content().length())
- continue;
-
</del><span class="cx"> m_cues.append(cueData);
</span><del>-
- m_currentCueStartTime = time;
- cueData->setStartTime(m_currentCueStartTime);
- cueData->setEndTime(std::numeric_limits<double>::infinity());
</del><span class="cx">
</span><del>- // AVFoundation cue "position" is to the center of the text so adjust relative to the edge because we will use it to
- // set CSS "left".
- if (cueData->position() >= 0 && cueData->size() > 0)
- cueData->setPosition(cueData->position() - cueData->size() / 2);
-
</del><span class="cx"> LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - adding cue for time = %.2f, position = %.2f, line = %.2f", this, cueData->startTime(), cueData->position(), cueData->line());
</span><span class="cx">
</span><del>- cueData->setStatus(GenericCueData::Partial);
</del><span class="cx"> client()->addGenericCue(this, cueData.release());
</span><span class="cx">
</span><span class="cx"> m_pendingCueStatus = seeking() ? DeliveredDuringSeek : Valid;
</span></span></pre>
</div>
</div>
</body>
</html>