Bug 172640 - MediaTime class has rounding issues in different platforms
Summary: MediaTime class has rounding issues in different platforms
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Xabier Rodríguez Calvar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-26 04:05 PDT by Xabier Rodríguez Calvar
Modified: 2017-06-09 01:10 PDT (History)
5 users (show)

See Also:


Attachments
Patch (15.44 KB, patch)
2017-05-26 04:18 PDT, Xabier Rodríguez Calvar
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews122 for ios-simulator-wk2 (910.61 KB, application/zip)
2017-05-26 05:41 PDT, Build Bot
no flags Details
Patch for landing (15.40 KB, patch)
2017-06-08 05:33 PDT, Xabier Rodríguez Calvar
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xabier Rodríguez Calvar 2017-05-26 04:05:33 PDT
MediaTime class has rounding issues in different platforms
Comment 1 Xabier Rodríguez Calvar 2017-05-26 04:18:19 PDT
Created attachment 311349 [details]
Patch
Comment 2 Build Bot 2017-05-26 05:41:39 PDT
Comment on attachment 311349 [details]
Patch

Attachment 311349 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3821463

New failing tests:
fast/events/before-unload-returnValue.html
fast/css/target-fragment-match.html
Comment 3 Build Bot 2017-05-26 05:41:40 PDT
Created attachment 311350 [details]
Archive of layout-test-results from ews122 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.5
Comment 4 Xabier Rodríguez Calvar 2017-05-26 08:45:44 PDT
(In reply to Build Bot from comment #2) 
> New failing tests:
> fast/events/before-unload-returnValue.html
> fast/css/target-fragment-match.html

These seem unrelated.
Comment 5 Xabier Rodríguez Calvar 2017-05-30 08:28:47 PDT
Please r?
Comment 6 Darin Adler 2017-06-06 14:35:14 PDT
Comment on attachment 311349 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=311349&action=review

> Source/WTF/wtf/MediaTime.cpp:148
> -    return MediaTime(static_cast<int64_t>(doubleTime * timeScale), timeScale, Valid);
> +    return MediaTime(static_cast<int64_t>(std::round(doubleTime * timeScale)), timeScale, Valid);

I would have expected the old code to truncate, not round, on all platforms. Is rounding what we want here?

> Source/WTF/wtf/MediaTime.cpp:558
>  void MediaTime::dump(PrintStream &out) const

Incorrect formatting of PrintStream& here.
Comment 7 Xabier Rodríguez Calvar 2017-06-07 01:43:47 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 311349 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=311349&action=review
> 
> > Source/WTF/wtf/MediaTime.cpp:148
> > -    return MediaTime(static_cast<int64_t>(doubleTime * timeScale), timeScale, Valid);
> > +    return MediaTime(static_cast<int64_t>(std::round(doubleTime * timeScale)), timeScale, Valid);
> 
> I would have expected the old code to truncate, not round, on all platforms.
> Is rounding what we want here?

I think rounding is usually better, also in this case

> > Source/WTF/wtf/MediaTime.cpp:558
> >  void MediaTime::dump(PrintStream &out) const
> 
> Incorrect formatting of PrintStream& here.

Wdym? I changed it to be like that cause I think it is more informative. In case the stored value is a double we just print that cause the fraction is noise (literally, the double interpreted as integer because it's a union) and in case it is a fraction we print it and as informative value, its representation as double.
Comment 8 Eric Carlson 2017-06-07 06:42:19 PDT
Comment on attachment 311349 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=311349&action=review

>>> Source/WTF/wtf/MediaTime.cpp:558
>>>  void MediaTime::dump(PrintStream &out) const
>> 
>> Incorrect formatting of PrintStream& here.
> 
> Wdym? I changed it to be like that cause I think it is more informative. In case the stored value is a double we just print that cause the fraction is noise (literally, the double interpreted as integer because it's a union) and in case it is a fraction we print it and as informative value, its representation as double.

I think Darin means the "&" should be next to the type, not the variable: 

void MediaTime::dump(PrintStream& out) const
Comment 9 Eric Carlson 2017-06-07 06:43:14 PDT
Comment on attachment 311349 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=311349&action=review

>>>> Source/WTF/wtf/MediaTime.cpp:558
>>>>  void MediaTime::dump(PrintStream &out) const
>>> 
>>> Incorrect formatting of PrintStream& here.
>> 
>> Wdym? I changed it to be like that cause I think it is more informative. In case the stored value is a double we just print that cause the fraction is noise (literally, the double interpreted as integer because it's a union) and in case it is a fraction we print it and as informative value, its representation as double.
> 
> I think Darin means the "&" should be next to the type, not the variable: 
> 
> void MediaTime::dump(PrintStream& out) const

... because that is the preferred WebKit style.
Comment 10 Darin Adler 2017-06-07 08:48:19 PDT
(In reply to Eric Carlson from comment #8)
> I think Darin means the "&" should be next to the type, not the variable: 
> 
> void MediaTime::dump(PrintStream& out) const

(In reply to Eric Carlson from comment #9)
> ... because that is the preferred WebKit style.

Yes, right, that’s what I meant. Sorry my wording was unclear.
Comment 11 Xabier Rodríguez Calvar 2017-06-07 08:53:09 PDT
(In reply to Darin Adler from comment #10)
> (In reply to Eric Carlson from comment #8)
> > I think Darin means the "&" should be next to the type, not the variable: 
> > 
> > void MediaTime::dump(PrintStream& out) const
> 
> (In reply to Eric Carlson from comment #9)
> > ... because that is the preferred WebKit style.
> 
> Yes, right, that’s what I meant. Sorry my wording was unclear.

Sure! I hadn't even noticed but because that was not part of the patch, but I can change that. Might I have and r+ cq- so that I can land with that change?
Comment 12 Darin Adler 2017-06-07 08:56:46 PDT
Sure, but I think it should be someone who works on the media code and has more expertise than I. I didn’t review because I’m not familiar enough with all the uses of MediaTime to be sure that the change to rounding is safe and helpful. I suspect it is, but I would like someone else to make the call.
Comment 13 Jer Noble 2017-06-07 09:05:59 PDT
(In reply to Darin Adler from comment #12)
> Sure, but I think it should be someone who works on the media code and has
> more expertise than I. I didn’t review because I’m not familiar enough with
> all the uses of MediaTime to be sure that the change to rounding is safe and
> helpful. I suspect it is, but I would like someone else to make the call.

Looks fine to me.
Comment 14 Xabier Rodríguez Calvar 2017-06-08 05:33:00 PDT
Created attachment 312296 [details]
Patch for landing
Comment 15 WebKit Commit Bot 2017-06-08 06:10:55 PDT
Comment on attachment 312296 [details]
Patch for landing

Clearing flags on attachment: 312296

Committed r217928: <http://trac.webkit.org/changeset/217928>
Comment 16 WebKit Commit Bot 2017-06-08 06:10:56 PDT
All reviewed patches have been landed.  Closing bug.
Comment 18 Xabier Rodríguez Calvar 2017-06-09 01:10:46 PDT
(In reply to Xabier Rodríguez Calvar from comment #17)
> I am unsure about:
> 
> https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.
> html#tests=media%2Fmodern-media-controls%2Fbuttons-container%2Fbuttons-
> container-buttons-property.html&revision=217791
> 
> https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.
> html#tests=media%2Fvideo-seek-with-negative-playback.html

Flakiness dashboard says they are ok.