Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fd06c147ae1974257528ecbb7c3b2ef7ac65126e
      
https://github.com/WebKit/WebKit/commit/fd06c147ae1974257528ecbb7c3b2ef7ac65126e
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-01-06 (Tue, 06 Jan 2026)

  Changed paths:
    M Source/WTF/wtf/MediaTime.cpp
    M Source/WTF/wtf/MediaTime.h
    M Source/WebCore/Modules/mediasource/SampleMap.cpp
    M Source/WebCore/platform/MediaSamplesBlock.h
    M Source/WebCore/platform/graphics/SourceBufferPrivate.cpp
    M Source/WebCore/platform/graphics/TrackBuffer.cpp
    M Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/SampleMap.cpp

  Log Message:
  -----------
  StabilityTracer: com.apple.WebKit.GPU at com.apple.WebCore:  
WebCore::DecodeOrderSampleMap::findSamplesBetweenDecodeKeys
https://bugs.webkit.org/show_bug.cgi?id=304975
rdar://161260966

Reviewed by Youenn Fablet.

A comparison with MediaTime::invalidTime could incorrectly yield true.
(Such as MediaTime::invalidTime() > MediaTime::zeroTime() or 
MediaTime::invalidTime() > MediaTime::positiveInfiniteTime())

MediaTime::invalidTime() should be treated as a NaN double. We change the 
spaceship operator to return a partial_ordering
instead of weak_ordering.
Otherwise, the comparison to determine if we are searching past the end key 
could fail and we would iterate over the table infinitely.

We amend code that didn't handle the case where the buffered range was empty or 
could use an invalidTime in their calculations.
For all those, an early exit was required but missing.

Tests: Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp
       Tools/TestWebKitAPI/Tests/WebCore/SampleMap.cpp
* Source/WTF/wtf/MediaTime.cpp:
(WTF::operator<=>):
* Source/WTF/wtf/MediaTime.h:
* Source/WebCore/Modules/mediasource/SampleMap.cpp: Add an extra safeguard to 
make sure we can never iterate past the end of the map.
(WebCore::DecodeOrderSampleMap::findSamplesBetweenDecodeKeys):
* Source/WebCore/platform/MediaSamplesBlock.h:
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::computeEvictionData): Handle case where the 
buffered range is empty as we could have provided
an invalid iterator otherwise.
(WebCore::SourceBufferPrivate::maximumBufferedTime const): Do not
* Source/WebCore/platform/graphics/TrackBuffer.cpp:
(WebCore::TrackBuffer::maximumBufferedTime const): Return MediaTime::zeroTime() 
instead of invalidTime when buffered is empty.
MediaSource is by spec starting at 0.
(WebCore::TrackBuffer::removeCodedFrames): Fix exposed an existing issue if we 
attempted to remove samples in invalid interval (start past 
presentationOrder().end())
We now exit early if the iterator found is invalid.
(WebCore::TrackBuffer::codedFramesIntervalSize): same as above.
* Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp:
(TestWebKitAPI::TEST(WTF, MediaTime)):
* Tools/TestWebKitAPI/Tests/WebCore/SampleMap.cpp:
(TestWebKitAPI::TEST_F(SampleMapTest, findSamplesBetweenDecodeKeys)):
(TestWebKitAPI::TEST_F(SampleMapTest, findSamplesBetweenDecodeKeysWithNaN)):

Canonical link: https://commits.webkit.org/305199@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to