WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
190590
[MSE] timestampOffset can introduce floating-point rounding errors to incoming samples
https://bugs.webkit.org/show_bug.cgi?id=190590
Summary
[MSE] timestampOffset can introduce floating-point rounding errors to incomin...
Jer Noble
Reported
2018-10-15 10:30:25 PDT
[MSE] timestampOffset can introduce floating-point rounding errors to incoming samples
Attachments
Patch
(12.88 KB, patch)
2018-10-15 10:42 PDT
,
Jer Noble
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews102 for mac-sierra
(2.46 MB, application/zip)
2018-10-15 11:31 PDT
,
EWS Watchlist
no flags
Details
Archive of layout-test-results from ews104 for mac-sierra-wk2
(3.18 MB, application/zip)
2018-10-15 11:46 PDT
,
EWS Watchlist
no flags
Details
Archive of layout-test-results from ews112 for mac-sierra
(3.06 MB, application/zip)
2018-10-15 12:46 PDT
,
EWS Watchlist
no flags
Details
Patch
(16.51 KB, patch)
2018-10-15 12:58 PDT
,
Jer Noble
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews100 for mac-sierra
(2.44 MB, application/zip)
2018-10-15 14:07 PDT
,
EWS Watchlist
no flags
Details
Archive of layout-test-results from ews104 for mac-sierra-wk2
(3.25 MB, application/zip)
2018-10-15 14:20 PDT
,
EWS Watchlist
no flags
Details
Archive of layout-test-results from ews113 for mac-sierra
(3.15 MB, application/zip)
2018-10-15 15:12 PDT
,
EWS Watchlist
no flags
Details
Patch
(19.39 KB, patch)
2018-10-16 13:59 PDT
,
Jer Noble
no flags
Details
Formatted Diff
Diff
Patch
(20.20 KB, patch)
2018-10-18 11:37 PDT
,
Jer Noble
no flags
Details
Formatted Diff
Diff
Show Obsolete
(9)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2018-10-15 10:31:57 PDT
<
rdar://problem/45275626
>
Jer Noble
Comment 2
2018-10-15 10:42:49 PDT
Created
attachment 352342
[details]
Patch
EWS Watchlist
Comment 3
2018-10-15 11:31:44 PDT
Comment hidden (obsolete)
Comment on
attachment 352342
[details]
Patch
Attachment 352342
[details]
did not pass mac-ews (mac): Output:
https://webkit-queues.webkit.org/results/9590165
New failing tests: media/media-source/media-source-sequence-timestamps.html media/media-source/media-source-timeoffset.html
EWS Watchlist
Comment 4
2018-10-15 11:31:45 PDT
Comment hidden (obsolete)
Created
attachment 352347
[details]
Archive of layout-test-results from ews102 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 5
2018-10-15 11:46:16 PDT
Comment hidden (obsolete)
Comment on
attachment 352342
[details]
Patch
Attachment 352342
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
https://webkit-queues.webkit.org/results/9590399
New failing tests: media/media-source/media-source-sequence-timestamps.html media/media-source/media-source-timeoffset.html
EWS Watchlist
Comment 6
2018-10-15 11:46:17 PDT
Comment hidden (obsolete)
Created
attachment 352353
[details]
Archive of layout-test-results from ews104 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 7
2018-10-15 12:46:40 PDT
Comment hidden (obsolete)
Comment on
attachment 352342
[details]
Patch
Attachment 352342
[details]
did not pass mac-debug-ews (mac): Output:
https://webkit-queues.webkit.org/results/9591336
New failing tests: media/media-source/media-source-sequence-timestamps.html media/media-source/media-source-timeoffset.html
EWS Watchlist
Comment 8
2018-10-15 12:46:42 PDT
Comment hidden (obsolete)
Created
attachment 352362
[details]
Archive of layout-test-results from ews112 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-sierra Platform: Mac OS X 10.12.6
Jer Noble
Comment 9
2018-10-15 12:58:47 PDT
Created
attachment 352365
[details]
Patch
EWS Watchlist
Comment 10
2018-10-15 14:07:48 PDT
Comment hidden (obsolete)
Comment on
attachment 352365
[details]
Patch
Attachment 352365
[details]
did not pass mac-ews (mac): Output:
https://webkit-queues.webkit.org/results/9595334
New failing tests: media/media-source/media-source-sequence-timestamps.html
EWS Watchlist
Comment 11
2018-10-15 14:07:49 PDT
Comment hidden (obsolete)
Created
attachment 352376
[details]
Archive of layout-test-results from ews100 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 12
2018-10-15 14:20:23 PDT
Comment hidden (obsolete)
Comment on
attachment 352365
[details]
Patch
Attachment 352365
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
https://webkit-queues.webkit.org/results/9595524
New failing tests: media/media-source/media-source-sequence-timestamps.html
EWS Watchlist
Comment 13
2018-10-15 14:20:25 PDT
Comment hidden (obsolete)
Created
attachment 352377
[details]
Archive of layout-test-results from ews104 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 14
2018-10-15 15:12:54 PDT
Comment hidden (obsolete)
Comment on
attachment 352365
[details]
Patch
Attachment 352365
[details]
did not pass mac-debug-ews (mac): Output:
https://webkit-queues.webkit.org/results/9596288
New failing tests: media/media-source/media-source-sequence-timestamps.html
EWS Watchlist
Comment 15
2018-10-15 15:12:55 PDT
Comment hidden (obsolete)
Created
attachment 352387
[details]
Archive of layout-test-results from ews113 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-sierra Platform: Mac OS X 10.12.6
Alicia Boya García
Comment 16
2018-10-16 09:50:30 PDT
Comment on
attachment 352365
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=352365&action=review
> Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1485 > + if (timeScale > std::numeric_limits<uint32_t>::max() / 2)
MediaTime::MaximumTimeScale should be used instead
Jer Noble
Comment 17
2018-10-16 13:59:35 PDT
Created
attachment 352500
[details]
Patch
Alicia Boya García
Comment 18
2018-10-16 16:48:32 PDT
Comment on
attachment 352500
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=352500&action=review
Nits aside, LGTM.
> Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1424 > + // NOTE: this is out-of-order, but we need the timescale from the
Is it worth it to reorder the code? We colud use `sample.duration` instead of `frameDuration`.
> Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1499 > + if (!trackBuffer.roundedTimestampOffset.isValid() || presentationTimestamp.timeScale() != trackBuffer.lastFrameTimescale) {
A TrackBuffer with samples with changing timescales is very rare. Should we add a mock test? (e.g. another one similar to our current test but where the second append has a different timescale)
> LayoutTests/media/media-source/media-source-timestampoffset-rounding-error.html:4 > + <title>media-source-append-acb-tolerance</title>
media-source-timestampoffset-rounding-error
> LayoutTests/media/media-source/media-source-timestampoffset-rounding-error.html:50 > + run('sourceBuffer.appendBuffer(makeVideo(2))');
makeVideo(1)
Alicia Boya García
Comment 19
2018-10-16 17:00:45 PDT
Let me check the algorithm once more...
Alicia Boya García
Comment 20
2018-10-17 23:48:44 PDT
Comment on
attachment 352500
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=352500&action=review
> Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1489 > + if (timeScale > MediaTime::MaximumTimeScale / 2)
This / 2 should not be there, since otherwise in the (hypothetical) case where roundingMargin is 1/MaximumTimeScale and we only need one multiplication to get there we would not do it even if it's helpful. Even then, this would be problematic if MaximumTimescale >= 2^31, since doubling would cause overflow. We have a patch to make it 1e9 (which happens to be slightly < 2^31), but this assumption is not obvious from reading the algorithm.
> Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1492 > + } while (abs(roundedTime - time) > roundingMargin);
I would argue that this should be >=. The idea is that if we consider microsecond precision we ignore differences smaller than 1 us: conversely 1 us is noticeable enough to make a difference.
Alicia Boya García
Comment 21
2018-10-17 23:53:31 PDT
Here is the algorithm modified to fix these problems, making no assumptions about the values of roundingMargin and MaximumTimeScale: auto roundTowardsTimeScaleWithRoundingMargin = [] (const MediaTime& time, uint32_t timeScale, const MediaTime& roundingMargin) { while (true) { MediaTime roundedTime = time.toTimeScale(timeScale); if (abs(roundedTime - time) < roundingMargin || timeScale >= MediaTime::MaximumTimeScale) return roundedTime; timeScale = std::min<uint64_t>(static_cast<uint64_t>(timeScale) * 2, MediaTime::MaximumTimeScale); } };
Jer Noble
Comment 22
2018-10-18 10:50:56 PDT
(In reply to Alicia Boya García from
comment #21
)
> Here is the algorithm modified to fix these problems, making no assumptions > about the values of roundingMargin and MaximumTimeScale: > > auto roundTowardsTimeScaleWithRoundingMargin = [] (const MediaTime& time, > uint32_t timeScale, const MediaTime& roundingMargin) { > while (true) { > MediaTime roundedTime = time.toTimeScale(timeScale); > if (abs(roundedTime - time) < roundingMargin || timeScale >= > MediaTime::MaximumTimeScale) > return roundedTime; > > timeScale = std::min<uint64_t>(static_cast<uint64_t>(timeScale) * 2, > MediaTime::MaximumTimeScale); > } > };
Thanks for this! We have nice convenience methods for doing checked arithmetic like this; I'll see if I can update your algorithm in terms of CheckedArithmetic.h.
Jer Noble
Comment 23
2018-10-18 11:14:57 PDT
(In reply to Alicia Boya García from
comment #18
)
> Comment on
attachment 352500
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=352500&action=review
> > Nits aside, LGTM. > > > Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1424 > > + // NOTE: this is out-of-order, but we need the timescale from the > > Is it worth it to reorder the code? We colud use `sample.duration` instead > of `frameDuration`.
True, but since we have to call sample.duration() already to create frameDuration, it would be a shame to have to call it twice.
> > Source/WebCore/Modules/mediasource/SourceBuffer.cpp:1499 > > + if (!trackBuffer.roundedTimestampOffset.isValid() || presentationTimestamp.timeScale() != trackBuffer.lastFrameTimescale) { > > A TrackBuffer with samples with changing timescales is very rare. Should we > add a mock test? (e.g. another one similar to our current test but where the > second append has a different timescale)
Sure, we could do that. Since trackBuffers are not recreated across variants, timeScale changes are definitely possible, if rare.
> > LayoutTests/media/media-source/media-source-timestampoffset-rounding-error.html:4 > > + <title>media-source-append-acb-tolerance</title> > > media-source-timestampoffset-rounding-error
Whoops.
> > LayoutTests/media/media-source/media-source-timestampoffset-rounding-error.html:50 > > + run('sourceBuffer.appendBuffer(makeVideo(2))'); > > makeVideo(1)
Changed.
Jer Noble
Comment 24
2018-10-18 11:37:45 PDT
Created
attachment 352712
[details]
Patch
Eric Carlson
Comment 25
2018-10-18 14:49:04 PDT
Comment on
attachment 352712
[details]
Patch rs=me based on Alicia's review.
WebKit Commit Bot
Comment 26
2018-10-18 16:02:23 PDT
Comment on
attachment 352712
[details]
Patch Clearing flags on attachment: 352712 Committed
r237274
: <
https://trac.webkit.org/changeset/237274
>
WebKit Commit Bot
Comment 27
2018-10-18 16:02:25 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug