Changeset 254767 in webkit
- Timestamp:
- Jan 17, 2020 2:31:58 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r254766 r254767 1 2020-01-17 Eric Carlson <eric.carlson@apple.com> 2 3 REGRESSION (r254483): media/track/track-cues-sorted-before-dispatch.html became very flaky 4 https://bugs.webkit.org/show_bug.cgi?id=206225 5 <rdar://problem/58634315> 6 7 Reviewed by Jer Noble. 8 9 The list of text track cues that are to fire events are sorted before events are 10 fired. Cue were being sorted by track, then by start time, and then by end time. 11 This meant that the sort order of two cues in the same track with identical start 12 and end times was not stable, causing this test to be flaky. The spec says to sort 13 by a cue's position in the track cue list when start and end times are identical, 14 so do that. 15 16 No new tests, this fixes a flaky test. 17 18 * html/track/TextTrackCue.cpp: 19 (WebCore::TextTrackCue::cueIndex const): 20 (WebCore::TextTrackCue::isOrderedBefore const): 21 * html/track/TextTrackCue.h: 22 * html/track/TextTrackCueList.cpp: 23 (WebCore::cueSortsBefore): 24 (WebCore::TextTrackCueList::cueIndex const): 25 (WebCore::TextTrackCueList::add): 26 (WebCore::TextTrackCueList::updateCueIndex): 27 (WebCore::compareCues): Deleted. 28 * html/track/TextTrackCueList.h: 29 1 30 2020-01-17 Andres Gonzalez <andresg_22@apple.com> 2 31 -
trunk/Source/WebCore/html/track/TextTrackCue.cpp
r253290 r254767 1 1 /* 2 2 * Copyright (C) 2011, 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2011-20 17Apple Inc. All rights reserved.3 * Copyright (C) 2011-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 51 51 #include "VTTCue.h" 52 52 #include "VTTRegionList.h" 53 #include <limits.h> 53 54 #include <wtf/HexNumber.h> 54 55 #include <wtf/IsoMallocInlines.h> … … 339 340 } 340 341 342 unsigned TextTrackCue::cueIndex() const 343 { 344 ASSERT(m_track && m_track->cues()); 345 if (!m_track || !m_track->cues()) 346 return std::numeric_limits<unsigned>::max(); 347 348 return m_track->cues()->cueIndex(*this); 349 } 350 341 351 bool TextTrackCue::isOrderedBefore(const TextTrackCue* other) const 342 352 { 343 return startMediaTime() < other->startMediaTime() || (startMediaTime() == other->startMediaTime() && endMediaTime() > other->endMediaTime()); 353 // ... cues must be sorted by their start time, earliest first; 354 if (startMediaTime() != other->startMediaTime()) 355 return startMediaTime() < other->startMediaTime(); 356 357 // then, any cues with the same start time must be sorted by their end time, latest first; 358 if (endMediaTime() != other->endMediaTime()) 359 return endMediaTime() > other->endMediaTime(); 360 361 // and finally, any cues with identical end times must be sorted in the order they were last added to 362 // their respective text track list of cues, oldest first (so e.g. for cues from a WebVTT file, that 363 // would initially be the order in which the cues were listed in the file) 364 return cueIndex() < other->cueIndex(); 344 365 } 345 366 -
trunk/Source/WebCore/html/track/TextTrackCue.h
r253290 r254767 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2012-20 17Apple Inc. All rights reserved.3 * Copyright (C) 2012-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 128 128 virtual void updateDisplayTree(const MediaTime&) { }; 129 129 130 unsigned cueIndex() const; 131 130 132 protected: 131 133 TextTrackCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, DocumentFragment&&); -
trunk/Source/WebCore/html/track/TextTrackCueList.cpp
r221155 r254767 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2017 Apple Inc. All rights reserved.3 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 35 35 36 36 #ifdef CHECK_SORTING 37 #define ASSERT_SORTED(begin, end) ASSERT(std::is_sorted(begin, end, c ompareCues))37 #define ASSERT_SORTED(begin, end) ASSERT(std::is_sorted(begin, end, cueSortsBefore)) 38 38 #else 39 39 #define ASSERT_SORTED(begin, end) ((void)0) … … 42 42 namespace WebCore { 43 43 44 static inline bool c ompareCues(const RefPtr<TextTrackCue>& a, const RefPtr<TextTrackCue>& b)44 static inline bool cueSortsBefore(const RefPtr<TextTrackCue>& a, const RefPtr<TextTrackCue>& b) 45 45 { 46 return a->isOrderedBefore(b.get()); 46 if (a->startMediaTime() < b->startMediaTime()) 47 return true; 48 49 return a->startMediaTime() == b->startMediaTime() && a->endMediaTime() > b->endMediaTime(); 47 50 } 48 51 49 unsigned TextTrackCueList::cueIndex( TextTrackCue& cue) const52 unsigned TextTrackCueList::cueIndex(const TextTrackCue& cue) const 50 53 { 51 54 ASSERT(m_vector.contains(&cue)); … … 94 97 95 98 RefPtr<TextTrackCue> cueRefPtr { WTFMove(cue) }; 96 unsigned insertionPosition = std::upper_bound(m_vector.begin(), m_vector.end(), cueRefPtr, c ompareCues) - m_vector.begin();99 unsigned insertionPosition = std::upper_bound(m_vector.begin(), m_vector.end(), cueRefPtr, cueSortsBefore) - m_vector.begin(); 97 100 ASSERT_SORTED(m_vector.begin(), m_vector.end()); 98 101 m_vector.insert(insertionPosition, WTFMove(cueRefPtr)); … … 114 117 } 115 118 116 void TextTrackCueList::updateCueIndex( TextTrackCue& cue)119 void TextTrackCueList::updateCueIndex(const TextTrackCue& cue) 117 120 { 118 121 auto cuePosition = m_vector.begin() + cueIndex(cue); … … 122 125 ASSERT_SORTED(afterCuePosition, m_vector.end()); 123 126 124 auto reinsertionPosition = std::upper_bound(m_vector.begin(), cuePosition, *cuePosition, c ompareCues);127 auto reinsertionPosition = std::upper_bound(m_vector.begin(), cuePosition, *cuePosition, cueSortsBefore); 125 128 if (reinsertionPosition != cuePosition) 126 129 std::rotate(reinsertionPosition, cuePosition, afterCuePosition); 127 130 else { 128 reinsertionPosition = std::upper_bound(afterCuePosition, m_vector.end(), *cuePosition, c ompareCues);131 reinsertionPosition = std::upper_bound(afterCuePosition, m_vector.end(), *cuePosition, cueSortsBefore); 129 132 if (reinsertionPosition != afterCuePosition) 130 133 std::rotate(cuePosition, afterCuePosition, reinsertionPosition); -
trunk/Source/WebCore/html/track/TextTrackCueList.h
r221155 r254767 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2017 Apple Inc. All rights reserved.3 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 41 41 TextTrackCue* getCueById(const String&) const; 42 42 43 unsigned cueIndex( TextTrackCue&) const;43 unsigned cueIndex(const TextTrackCue&) const; 44 44 45 45 void add(Ref<TextTrackCue>&&); 46 46 void remove(TextTrackCue&); 47 void updateCueIndex( TextTrackCue&);47 void updateCueIndex(const TextTrackCue&); 48 48 49 49 void clear();
Note: See TracChangeset
for help on using the changeset viewer.