Consider the following code: ``` auto invalid = MediaTime::invalidTime(); auto cminvalid = PAL::toCMTime(invalid); auto invalid2 = PAL::toMediaTime(cminvalid); ASSERT(invalid == invalid2); ``` the assertion will fail. The reason is that PAL::toCMTime(MediaTime::invalidTime()) will generate a CMTime that has the flag kCMTimeFlags_HasBeenRounded set. This causes failure here https://webkit-search.igalia.com/webkit/rev/ceb5e25a803df6cd6ea1c45859e4e03bbf659f75/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleByteRange.cpp#49
Actually, earlier description is incorrect: the code of toCMTime is as follow: ``` CMTime time; if (mediaTime.hasDoubleValue()) time = CMTimeMakeWithSeconds(mediaTime.toDouble(), mediaTime.timeScale()); else time = CMTimeMake(mediaTime.timeValue(), mediaTime.timeScale()); if (mediaTime.isValid()) time.flags |= kCMTimeFlags_Valid; if (mediaTime.hasBeenRounded()) time.flags |= kCMTimeFlags_HasBeenRounded; if (mediaTime.isPositiveInfinite()) time.flags |= kCMTimeFlags_PositiveInfinity; if (mediaTime.isNegativeInfinite()) time.flags |= kCMTimeFlags_NegativeInfinity; return time; ``` what converting MediaTime::invalidTime() : `CMTimeMake(mediaTime.timeValue(), mediaTime.timeScale());` will return a valid time and that flag isn't reset.
<rdar://problem/89814921>
Created attachment 453845 [details] Patch
Created attachment 453886 [details] Patch
Created attachment 453887 [details] Patch
Created attachment 453888 [details] Patch Fix iOS compilation
Comment on attachment 453888 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453888&action=review > Source/WebCore/PAL/ChangeLog:15 > +2022-03-04 Jean-Yves Avenard <jya@apple.com> Nit: This ChangeLog entry should get merged with the one above it.
Created attachment 454028 [details] Patch
Created attachment 454031 [details] Patch
Committed r290964 (248144@main): <https://commits.webkit.org/248144@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 454031 [details].