After discussing this with rniwa, I have decided not to add a PerformanceTest test for this change. Ryosuke explained that performance tests should not be used as regression tests. It would also be difficult to write a LayoutTest for this change to verify that decoders are not active during the running of such a test, as other video-decoder-using tests may be active concurrently with this hypothetical test.
The only remaining test to write would be one that returned the number of "active" tracks (rather than just enabled tracks) when the page is not visible. The only thing this test would verify is that we actually disable the tracks when pages are backgrounded, but not that decoders stop or that CPU resources are returned.
Created attachment 294220[details]
Archive of layout-test-results from ews103 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294221[details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Created attachment 294222[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Created attachment 294238[details]
Archive of layout-test-results from ews103 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294241[details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Created attachment 294263[details]
Archive of layout-test-results from ews126 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Created attachment 294265[details]
Archive of layout-test-results from ews100 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294291[details]
Archive of layout-test-results from ews113 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113 Port: mac-yosemite Platform: Mac OS X 10.10.5
(In reply to comment #22)
> What happens to videos being drawn to canvases. Do they still work?
No, they don't. If they're in the background they get black frames.
(In reply to comment #23)
> (In reply to comment #22)
> > What happens to videos being drawn to canvases. Do they still work?
>
> No, they don't. If they're in the background they get black frames.
Seems like should still work, no?
Created attachment 294714[details]
Archive of layout-test-results from ews101 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294715[details]
Archive of layout-test-results from ews116 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294717[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
(In reply to comment #24)
> (In reply to comment #23)
> > (In reply to comment #22)
> > > What happens to videos being drawn to canvases. Do they still work?
> >
> > No, they don't. If they're in the background they get black frames.
>
> Seems like should still work, no?
No.
There's no way to synchronously enable a track and paint it. We could hypothetically not disable tracks of videos that have been painted to a canvas, but we'd still not be able to synchronously paint a disabled track that has never before been painted, and since we paint videos when tab snapshots are taken, we'd likely never be able to disable videos in background tabs.
The way I see it, this is similar to disabling/coalescing timers in background tabs. Page authors can't depend on foreground tab behavior continuing when their tab is backgrounded.
Created attachment 294744[details]
Archive of layout-test-results from ews103 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294750[details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Created attachment 294751[details]
Archive of layout-test-results from ews113 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294753[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Created attachment 294903[details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2
The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Created attachment 294908[details]
Archive of layout-test-results from ews102 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294909[details]
Archive of layout-test-results from ews115 for mac-yosemite
The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115 Port: mac-yosemite Platform: Mac OS X 10.10.5
Created attachment 294910[details]
Archive of layout-test-results from ews124 for ios-simulator-wk2
The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
(In reply to comment #32)
> (In reply to comment #24)
> > (In reply to comment #23)
> > > (In reply to comment #22)
> > > > What happens to videos being drawn to canvases. Do they still work?
> > >
> > > No, they don't. If they're in the background they get black frames.
> >
> > Seems like should still work, no?
>
> No.
>
> There's no way to synchronously enable a track and paint it. We could
> hypothetically not disable tracks of videos that have been painted to a
> canvas, but we'd still not be able to synchronously paint a disabled track
> that has never before been painted, and since we paint videos when tab
> snapshots are taken, we'd likely never be able to disable videos in
> background tabs.
>
> The way I see it, this is similar to disabling/coalescing timers in
> background tabs. Page authors can't depend on foreground tab behavior
> continuing when their tab is backgrounded.
Agreed. If our choices are:
[1] Continue decoding video frames in background tabs.
[2] Stop decoding video frames in background tabs, continue everything else.
[3] Stop decoding video frames in background tabs, stop everything else.
We should test [2] for web compatibility. [1] is bad for CPU, memory, battery usage. [2] is better than [3] if we believe there is value in running background tabs at all.
(In reply to comment #32)
> (In reply to comment #24)
> > (In reply to comment #23)
> > > (In reply to comment #22)
> > > > What happens to videos being drawn to canvases. Do they still work?
> > >
> > > No, they don't. If they're in the background they get black frames.
> >
> > Seems like should still work, no?
>
> No.
>
> There's no way to synchronously enable a track and paint it. We could
> hypothetically not disable tracks of videos that have been painted to a
> canvas, but we'd still not be able to synchronously paint a disabled track
> that has never before been painted, and since we paint videos when tab
> snapshots are taken, we'd likely never be able to disable videos in
> background tabs.
>
> The way I see it, this is similar to disabling/coalescing timers in
> background tabs. Page authors can't depend on foreground tab behavior
> continuing when their tab is backgrounded.
I don't think these are exactly the same. Imagine a page that is doing some kind of image analysis on a video. Going into a background tab should not break that functionality. Timer throttling might slow something down, but it won't change the result.
(In reply to comment #53)
> I don't think these are exactly the same. Imagine a page that is doing some
> kind of image analysis on a video. Going into a background tab should not
> break that functionality. Timer throttling might slow something down, but it
> won't change the result.
That's not really true, especially with your image analysis example. If the page is playing a video in a background tab and doing analysis on the output, it's going to set a timer to fire at the frame rate of the video, e.g. 24 times per second. If timers are being throttled, the page is definitely going to miss decoded frames, which is functionally equivalent to those frames never being decoded.
Comment on attachment 294891[details]
Patch
Patches that have been up for review since 2016 are almost certainly too stale to be relevant to trunk in their current form.
If this patch is still important please rebase it and post it for review again.
2016-11-08 22:55 PST, Jer Noble
2016-11-08 23:58 PST, Build Bot
2016-11-08 23:58 PST, Build Bot
2016-11-09 00:13 PST, Build Bot
2016-11-09 09:55 PST, Jer Noble
2016-11-09 10:56 PST, Build Bot
2016-11-09 10:58 PST, Build Bot
2016-11-09 11:11 PST, Jer Noble
2016-11-09 12:11 PST, Build Bot
2016-11-09 12:29 PST, Build Bot
2016-11-09 14:33 PST, Build Bot
2016-11-14 09:39 PST, Jer Noble
2016-11-14 10:49 PST, Build Bot
2016-11-14 10:49 PST, Build Bot
2016-11-14 10:56 PST, Build Bot
2016-11-14 13:21 PST, Jer Noble
2016-11-14 14:21 PST, Build Bot
2016-11-14 14:30 PST, Build Bot
2016-11-14 14:31 PST, Build Bot
2016-11-14 14:44 PST, Build Bot
2016-11-15 15:55 PST, Jer Noble
buildbot: commit-queue-
2016-11-15 17:02 PST, Build Bot
2016-11-15 17:31 PST, Build Bot
2016-11-15 17:36 PST, Build Bot
2016-11-15 18:05 PST, Build Bot