Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2605993002: Experiment with more aggressive MSE GC on memory pressure (Closed)
Patch Set: typo Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/callback_helpers.h" 16 #include "base/callback_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/debug/alias.h" 18 #include "base/debug/alias.h"
19 #include "base/debug/crash_logging.h" 19 #include "base/debug/crash_logging.h"
20 #include "base/location.h" 20 #include "base/location.h"
21 #include "base/memory/ptr_util.h"
21 #include "base/metrics/histogram_macros.h" 22 #include "base/metrics/histogram_macros.h"
22 #include "base/single_thread_task_runner.h" 23 #include "base/single_thread_task_runner.h"
23 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
24 #include "base/task_runner_util.h" 25 #include "base/task_runner_util.h"
25 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
26 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
28 #include "cc/blink/web_layer_impl.h" 29 #include "cc/blink/web_layer_impl.h"
29 #include "cc/layers/video_layer.h" 30 #include "cc/layers/video_layer.h"
30 #include "media/audio/null_audio_sink.h" 31 #include "media/audio/null_audio_sink.h"
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1162
1162 UpdateBackgroundVideoOptimizationState(); 1163 UpdateBackgroundVideoOptimizationState();
1163 } 1164 }
1164 1165
1165 void WebMediaPlayerImpl::OnDemuxerOpened() { 1166 void WebMediaPlayerImpl::OnDemuxerOpened() {
1166 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1167 DCHECK(main_task_runner_->BelongsToCurrentThread());
1167 client_->mediaSourceOpened( 1168 client_->mediaSourceOpened(
1168 new WebMediaSourceImpl(chunk_demuxer_, media_log_)); 1169 new WebMediaSourceImpl(chunk_demuxer_, media_log_));
1169 } 1170 }
1170 1171
1172 void WebMediaPlayerImpl::OnMemoryPressure(
1173 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
1174 DVLOG(2) << __func__ << " memory_pressure_level=" << memory_pressure_level;
1175 DCHECK(main_task_runner_->BelongsToCurrentThread());
1176 DCHECK(base::FeatureList::IsEnabled(kReduceMSEBuffersOnMemoryPressure));
DaleCurtis 2017/01/26 19:24:50 Seems this should include both features?
servolk 2017/01/26 19:38:31 No, the kMSEInstantGCOnMemoryPressure may or may n
1177 if (chunk_demuxer_) {
1178 // base::Unretained is safe, since chunk_demuxer_ is actually owned by
1179 // |this| via this->demuxer_.
1180 media_task_runner_->PostTask(
1181 FROM_HERE, base::Bind(&ChunkDemuxer::OnMemoryPressure,
1182 base::Unretained(chunk_demuxer_),
1183 base::TimeDelta::FromSecondsD(currentTime()),
1184 memory_pressure_level));
1185 }
1186 }
1187
1171 void WebMediaPlayerImpl::OnError(PipelineStatus status) { 1188 void WebMediaPlayerImpl::OnError(PipelineStatus status) {
1172 DVLOG(1) << __func__; 1189 DVLOG(1) << __func__;
1173 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1190 DCHECK(main_task_runner_->BelongsToCurrentThread());
1174 DCHECK_NE(status, PIPELINE_OK); 1191 DCHECK_NE(status, PIPELINE_OK);
1175 1192
1176 if (suppress_destruction_errors_) 1193 if (suppress_destruction_errors_)
1177 return; 1194 return;
1178 1195
1179 ReportPipelineError(load_type_, frame_->getSecurityOrigin(), status); 1196 ReportPipelineError(load_type_, frame_->getSecurityOrigin(), status);
1180 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status)); 1197 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status));
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 return; 1727 return;
1711 #endif 1728 #endif
1712 } else { 1729 } else {
1713 DCHECK(!chunk_demuxer_); 1730 DCHECK(!chunk_demuxer_);
1714 DCHECK(!data_source_); 1731 DCHECK(!data_source_);
1715 1732
1716 chunk_demuxer_ = new ChunkDemuxer( 1733 chunk_demuxer_ = new ChunkDemuxer(
1717 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 1734 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
1718 encrypted_media_init_data_cb, media_log_); 1735 encrypted_media_init_data_cb, media_log_);
1719 demuxer_.reset(chunk_demuxer_); 1736 demuxer_.reset(chunk_demuxer_);
1737
1738 if (base::FeatureList::IsEnabled(kReduceMSEBuffersOnMemoryPressure)) {
1739 // base::Unretained is safe because |this| owns memory_pressure_listener_.
1740 memory_pressure_listener_ =
1741 base::MakeUnique<base::MemoryPressureListener>(base::Bind(
1742 &WebMediaPlayerImpl::OnMemoryPressure, base::Unretained(this)));
1743 }
1720 } 1744 }
1721 1745
1722 // TODO(sandersd): FileSystem objects may also be non-static, but due to our 1746 // TODO(sandersd): FileSystem objects may also be non-static, but due to our
1723 // caching layer such situations are broken already. http://crbug.com/593159 1747 // caching layer such situations are broken already. http://crbug.com/593159
1724 bool is_static = !chunk_demuxer_; 1748 bool is_static = !chunk_demuxer_;
1725 bool is_streaming = IsStreaming(); 1749 bool is_streaming = IsStreaming();
1726 UMA_HISTOGRAM_BOOLEAN("Media.IsStreaming", is_streaming); 1750 UMA_HISTOGRAM_BOOLEAN("Media.IsStreaming", is_streaming);
1727 1751
1728 // ... and we're ready to go! 1752 // ... and we're ready to go!
1729 // TODO(sandersd): On Android, defer Start() if the tab is not visible. 1753 // TODO(sandersd): On Android, defer Start() if the tab is not visible.
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2257 UMA_HISTOGRAM_TIMES( 2281 UMA_HISTOGRAM_TIMES(
2258 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", 2282 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack",
2259 time_to_first_frame); 2283 time_to_first_frame);
2260 } else { 2284 } else {
2261 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", 2285 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused",
2262 time_to_first_frame); 2286 time_to_first_frame);
2263 } 2287 }
2264 } 2288 }
2265 2289
2266 } // namespace media 2290 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698