Bug 90734

Summary: [GStreamer] usec rounding is wrong during accurate seeking
Product: WebKit Reporter: Philippe Normand <pnormand>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cgarcia, commit-queue, dglazkov, eric.carlson, feature-media-reviews, glenn, gustavo, gyuyoung.kim, jer.noble, menard, mrobinson, pnormand, rakuco, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
webkit.review.bot: commit-queue-
Archive of layout-test-results from gce-cr-linux-06
none
Patch
none
Archive of layout-test-results from gce-cr-linux-05
none
Patch
buildbot: commit-queue-
Archive of layout-test-results from webkit-ews-02 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2
none
Patch
none
Patch
none
Patch
mcatanzaro: review-
patch cgarcia: review+

Description Philippe Normand 2012-07-07 20:04:49 PDT
The current approach is dummy :( We should switch to a floor()-based rounding solution.
Comment 1 Philippe Normand 2012-07-07 20:09:05 PDT
With the current implementation 6.027200 seconds rounds to 6.030000. Kind of far fetched rounding.
Comment 2 Philippe Normand 2012-07-07 20:39:36 PDT
Created attachment 151154 [details]
Patch
Comment 3 Martin Robinson 2012-07-09 08:00:20 PDT
Can you give an example of how this affects rounding? Before, 6.0272 was rounded to 6.03. What is it rounded to now? Does this affect tests at all?
Comment 4 Philippe Normand 2012-07-18 07:06:19 PDT
(In reply to comment #3)
> Can you give an example of how this affects rounding? Before, 6.0272 was rounded to 6.03.

Yes. Example when running media/video-seek-past-end-playing.html

Seek to 6.027200: 6.000000 secs 30000 usecs
Seek: 0:00:06.030000000

> What is it rounded to now?

Now, same test with the patch:

Seek to 6.027200: 6.000000 secs 27200 usecs
Seek: 0:00:06.027200000

> Does this affect tests at all?

Yes, well with the patch media/video-frame-accurate-seek.html still passes.
The issue with the previous rounding "strategy" is that some values were correctly rounded and some not, as you can see above. Maybe I can update the layout test!
Comment 5 Philippe Normand 2012-07-18 07:21:55 PDT
Created attachment 153007 [details]
Patch
Comment 6 WebKit Review Bot 2012-07-18 08:00:48 PDT
Comment on attachment 153007 [details]
Patch

Attachment 153007 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13273552

New failing tests:
media/video-frame-accurate-seek.html
Comment 7 WebKit Review Bot 2012-07-18 08:00:52 PDT
Created attachment 153014 [details]
Archive of layout-test-results from gce-cr-linux-06

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: gce-cr-linux-06  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Comment 8 Philippe Normand 2012-07-18 08:32:54 PDT
Created attachment 153019 [details]
Patch
Comment 9 WebKit Review Bot 2012-07-18 09:08:05 PDT
Comment on attachment 153019 [details]
Patch

Attachment 153019 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13282548

New failing tests:
media/video-frame-accurate-seek.html
Comment 10 WebKit Review Bot 2012-07-18 09:08:13 PDT
Created attachment 153023 [details]
Archive of layout-test-results from gce-cr-linux-05

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: gce-cr-linux-05  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Comment 11 Philippe Normand 2013-04-12 13:09:38 PDT
Comment on attachment 153019 [details]
Patch

I need to rework/rebase this patch
Comment 12 Philippe Normand 2013-04-14 10:12:41 PDT
I think there might be some small bugs in the GStreamer decoders, making sure currentTime() is as accurate as the seek method I can still see the frame displayed is either the one preceding or following the one requested. The video-frame-accurate-seek test actually shows the issue too, 3rd video should show frame #14 but shows frame #15 instead.
Comment 13 Philippe Normand 2013-04-14 10:45:28 PDT
Created attachment 198003 [details]
Patch
Comment 14 Build Bot 2013-04-15 00:56:19 PDT
Comment on attachment 198003 [details]
Patch

Attachment 198003 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/47297

New failing tests:
http/tests/ssl/ping-with-unsafe-redirect.html
media/video-frame-accurate-seek.html
Comment 15 Build Bot 2013-04-15 00:56:22 PDT
Created attachment 198030 [details]
Archive of layout-test-results from webkit-ews-02 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-02  Port: mac-mountainlion  Platform: Mac OS X 10.8.2
Comment 16 Build Bot 2013-04-15 01:59:12 PDT
Comment on attachment 198003 [details]
Patch

Attachment 198003 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/139189

New failing tests:
http/tests/ssl/ping-with-unsafe-redirect.html
media/video-frame-accurate-seek.html
Comment 17 Build Bot 2013-04-15 01:59:17 PDT
Created attachment 198037 [details]
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-03  Port: mac-mountainlion  Platform: Mac OS X 10.8.2
Comment 18 Build Bot 2013-04-15 02:24:41 PDT
Comment on attachment 198003 [details]
Patch

Attachment 198003 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/30262

New failing tests:
media/video-frame-accurate-seek.html
Comment 19 Build Bot 2013-04-15 02:24:46 PDT
Created attachment 198040 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.2
Comment 20 Philippe Normand 2013-05-01 15:18:39 PDT
Created attachment 200245 [details]
Patch
Comment 21 Philippe Normand 2014-09-19 00:47:11 PDT
Created attachment 238351 [details]
Patch

Rebased.
Comment 22 Philippe Normand 2014-09-19 00:49:14 PDT
Comment on attachment 238351 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp:158
> +    timeValue.tv_usec = static_cast<glong>(floor(microSeconds = 0.5));

oops.
Comment 23 Philippe Normand 2014-09-19 00:50:17 PDT
Created attachment 238352 [details]
Patch
Comment 24 Michael Catanzaro 2016-01-02 10:03:18 PST
Comment on attachment 238352 [details]
Patch

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

The code changes in this patch look fine, but I don't understand the test.

> LayoutTests/media/video-frame-accurate-seek.html:8
> +        <p>Test that setting currentTime is frame-accurate. Four videos below should be showing up, The first three at frames 12, 13, and 14. The last video should display at 6.0272 seconds.</p>

The -> the

> LayoutTests/platform/gtk/media/video-frame-accurate-seek-expected.txt:9
> +          text run at (0,17) width 356: "and 14. The last video should display at 6.0272 seconds."

It seems like something is wrong with this test. The expected result for the first three videos shows 12, 13, and 15, but the test says it's expected to show 12, 13, and 14. The last video displays 6.01 seconds, not 6.0272 or 6.03.

> LayoutTests/platform/mac/TestExpectations:1392
> +webkit.org/b/90734 media/video-frame-accurate-seek.html [ Failure ]

I think you should file new bugs for the EFL and Mac rebaselines, else they probably won't happen if you add an expectation to hide the failures.
Comment 25 Philippe Normand 2016-01-04 00:33:00 PST
(In reply to comment #24)
> Comment on attachment 238352 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=238352&action=review
> 
> The code changes in this patch look fine, but I don't understand the test.
> 
> > LayoutTests/media/video-frame-accurate-seek.html:8
> > +        <p>Test that setting currentTime is frame-accurate. Four videos below should be showing up, The first three at frames 12, 13, and 14. The last video should display at 6.0272 seconds.</p>
> 
> The -> the
> 
> > LayoutTests/platform/gtk/media/video-frame-accurate-seek-expected.txt:9
> > +          text run at (0,17) width 356: "and 14. The last video should display at 6.0272 seconds."
> 
> It seems like something is wrong with this test. The expected result for the
> first three videos shows 12, 13, and 15, but the test says it's expected to
> show 12, 13, and 14. The last video displays 6.01 seconds, not 6.0272 or
> 6.03.
> 

See comment 12.
Comment 26 Philippe Normand 2016-06-21 04:44:14 PDT
(In reply to comment #24)
> Comment on attachment 238352 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=238352&action=review
> 
> The code changes in this patch look fine, but I don't understand the test.
> 
> > LayoutTests/media/video-frame-accurate-seek.html:8
> > +        <p>Test that setting currentTime is frame-accurate. Four videos below should be showing up, The first three at frames 12, 13, and 14. The last video should display at 6.0272 seconds.</p>
> 
> The -> the
> 
> > LayoutTests/platform/gtk/media/video-frame-accurate-seek-expected.txt:9
> > +          text run at (0,17) width 356: "and 14. The last video should display at 6.0272 seconds."
> 
> It seems like something is wrong with this test. The expected result for the
> first three videos shows 12, 13, and 15, but the test says it's expected to
> show 12, 13, and 14. 

This now works as expected \o/

> The last video displays 6.01 seconds, not 6.0272 or
> 6.03.
> 

That's because 6.01 means (6 * 25) + 1 frames = 151. And not 0.01 seconds.

So we do a seek to 6.0272 seconds which means 6 seconds and one half-frame (0.02 = 1/50) but the video is at 25fps so the demuxer choses instead to jump to the next full frame, if I understand correctly.
Comment 27 Philippe Normand 2016-06-28 04:13:11 PDT
Created attachment 282241 [details]
patch
Comment 28 Philippe Normand 2016-06-28 04:26:42 PDT
Committed r202558: <http://trac.webkit.org/changeset/202558>