haikuwebkit/PerformanceTests/Media/StandardCanPlayThrough.html

65 lines
1.6 KiB
HTML
Raw Permalink Normal View History

Add some performance tests for various aspects of media loading and playback. https://bugs.webkit.org/show_bug.cgi?id=164977 Reviewed by Darin Adler. PerformanceTests: Add new tests for a few aspects of media playback; namely: how quickly media elements fire the "canplaythrough" event when all data is immediately available, how quickly HLS playback switches resolutions, and at what playback rate MSE-backed video can play without dropping frames. Skip these tests by default, as they're not runnable on all ports, and they require a webserver (run-webkit-httpd) to complete on macOS. * Media/HLSCanPlayThrough.html: Added. * Media/HLSGearChange.html: Added. * Media/MSECanPlayThrough.html: Added. * Media/MSEPlaybackRate.html: Added. * Media/StandardCanPlayThrough.html: Added. * Media/hls/1080p/iframe_index.m3u8: Added. * Media/hls/1080p/prog_index.m3u8: Added. * Media/hls/1080p/test.ts: Added. * Media/hls/480p/iframe_index.m3u8: Added. * Media/hls/480p/prog_index.m3u8: Added. * Media/hls/480p/test.ts: Added. * Media/hls/720p/iframe_index.m3u8: Added. * Media/hls/720p/prog_index.m3u8: Added. * Media/hls/720p/test.ts: Added. * Media/hls/720p/test.ts.back: Added. * Media/hls/index.m3u8: Added. * Media/media-source-loader.js: Added. (MediaSourceLoader): (MediaSourceLoader.prototype.loadManifest): (MediaSourceLoader.prototype.loadManifestSucceeded): (MediaSourceLoader.prototype.loadManifestFailed): (MediaSourceLoader.prototype.loadMediaData): (MediaSourceLoader.prototype.loadMediaDataSucceeded): (MediaSourceLoader.prototype.loadMediaDataFailed): (MediaSourceLoader.prototype.get type): (MediaSourceLoader.prototype.get duration): (MediaSourceLoader.prototype.get initSegment): (MediaSourceLoader.prototype.get mediaSegmentsLength): (MediaSourceLoader.prototype.mediaSegments): (MediaSourceLoader.prototype.get everyMediaSegment): * Media/test-fragmented-video.json: Added. * Media/test-fragmented-video.mp4: Added. * Media/test.mp4: Added. * Skipped: Tools: Allow callers to pass in extra alias/directory pairs to run-webkit-httpd. * Scripts/run-webkit-httpd: (parse_args): (main): Canonical link: https://commits.webkit.org/182707@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208999 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-28 17:22:30 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../resources/runner.js"></script>
<script>
var video;
var url;
window.addEventListener('load', () => {
PerfTestRunner.prepareToMeasureValuesAsync({
unit: 'ms',
done: function () {
if (video) {
video.src = null;
video.load();
}
}
});
loadMediaData('test.mp4').then((blob) => {
url = URL.createObjectURL(blob);
runTest();
});
});
function loadMediaData(url) {
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.responseType = 'blob';
request.addEventListener('load', (event) => {
resolve(event.target.response);
});
request.addEventListener('error', (event) => {
reject(event.error);
});
request.send();
})
}
function runTest() {
video = document.createElement('video');
if (navigator.userAgent.match(/iPod|iPhone|iPad/) && !window.MSStream) {
video.setAttribute('muted', 'true');
video.setAttribute('autoplay', 'allowed');
}
Add some performance tests for various aspects of media loading and playback. https://bugs.webkit.org/show_bug.cgi?id=164977 Reviewed by Darin Adler. PerformanceTests: Add new tests for a few aspects of media playback; namely: how quickly media elements fire the "canplaythrough" event when all data is immediately available, how quickly HLS playback switches resolutions, and at what playback rate MSE-backed video can play without dropping frames. Skip these tests by default, as they're not runnable on all ports, and they require a webserver (run-webkit-httpd) to complete on macOS. * Media/HLSCanPlayThrough.html: Added. * Media/HLSGearChange.html: Added. * Media/MSECanPlayThrough.html: Added. * Media/MSEPlaybackRate.html: Added. * Media/StandardCanPlayThrough.html: Added. * Media/hls/1080p/iframe_index.m3u8: Added. * Media/hls/1080p/prog_index.m3u8: Added. * Media/hls/1080p/test.ts: Added. * Media/hls/480p/iframe_index.m3u8: Added. * Media/hls/480p/prog_index.m3u8: Added. * Media/hls/480p/test.ts: Added. * Media/hls/720p/iframe_index.m3u8: Added. * Media/hls/720p/prog_index.m3u8: Added. * Media/hls/720p/test.ts: Added. * Media/hls/720p/test.ts.back: Added. * Media/hls/index.m3u8: Added. * Media/media-source-loader.js: Added. (MediaSourceLoader): (MediaSourceLoader.prototype.loadManifest): (MediaSourceLoader.prototype.loadManifestSucceeded): (MediaSourceLoader.prototype.loadManifestFailed): (MediaSourceLoader.prototype.loadMediaData): (MediaSourceLoader.prototype.loadMediaDataSucceeded): (MediaSourceLoader.prototype.loadMediaDataFailed): (MediaSourceLoader.prototype.get type): (MediaSourceLoader.prototype.get duration): (MediaSourceLoader.prototype.get initSegment): (MediaSourceLoader.prototype.get mediaSegmentsLength): (MediaSourceLoader.prototype.mediaSegments): (MediaSourceLoader.prototype.get everyMediaSegment): * Media/test-fragmented-video.json: Added. * Media/test-fragmented-video.mp4: Added. * Media/test.mp4: Added. * Skipped: Tools: Allow callers to pass in extra alias/directory pairs to run-webkit-httpd. * Scripts/run-webkit-httpd: (parse_args): (main): Canonical link: https://commits.webkit.org/182707@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208999 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-28 17:22:30 +00:00
var startTime = PerfTestRunner.now();
video.src = url;
video.addEventListener('canplaythrough', () => {
if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
return;
PerfTestRunner.gc();
setTimeout(runTest, 0);
});
}
</script>
</head>
<body>
<button onclick="pauseAll()">pause</button><button onclick="playAll()">play</button><br>
</body>
</html>