Commit 076f5379 authored by acolwell's avatar acolwell Committed by Commit bot

Remove the lies WebMediaPlayerImpl is telling V8.

Removing hacky code that sends made up data to V8 to trick it into running
GC more often. This was added a long time ago and it is unlikely it is
actually helping things anymore. Removing this code also eliminates
WebMediaPlayerImpl's dependency on V8 which helps with moving this code
to media/blink.

BUG=408338

Review URL: https://codereview.chromium.org/512033002

Cr-Commit-Position: refs/heads/master@{#292303}
parent ebcee6ac
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h" #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebView.h" #include "third_party/WebKit/public/web/WebView.h"
#include "v8/include/v8.h"
using blink::WebCanvas; using blink::WebCanvas;
using blink::WebMediaPlayer; using blink::WebMediaPlayer;
...@@ -76,16 +75,6 @@ using media::PipelineStatus; ...@@ -76,16 +75,6 @@ using media::PipelineStatus;
namespace { namespace {
// Amount of extra memory used by each player instance reported to V8.
// It is not exact number -- first, it differs on different platforms,
// and second, it is very hard to calculate. Instead, use some arbitrary
// value that will cause garbage collection from time to time. We don't want
// it to happen on every allocation, but don't want 5k players to sit in memory
// either. Looks that chosen constant achieves both goals, at least for audio
// objects. (Do not worry about video objects yet, JS programs do not create
// thousands of them...)
const int kPlayerExtraMemory = 1024 * 1024;
// Limits the range of playback rate. // Limits the range of playback rate.
// //
// TODO(kylep): Revisit these. // TODO(kylep): Revisit these.
...@@ -175,7 +164,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( ...@@ -175,7 +164,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
client_(client), client_(client),
delegate_(delegate), delegate_(delegate),
defer_load_cb_(params.defer_load_cb()), defer_load_cb_(params.defer_load_cb()),
incremented_externally_allocated_memory_(false),
gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()),
supports_save_(true), supports_save_(true),
chunk_demuxer_(NULL), chunk_demuxer_(NULL),
...@@ -200,17 +188,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( ...@@ -200,17 +188,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
DCHECK(!gpu_factories_.get() || DCHECK(!gpu_factories_.get() ||
(gpu_factories_->GetTaskRunner() == media_loop_.get())); (gpu_factories_->GetTaskRunner() == media_loop_.get()));
// Let V8 know we started new thread if we did not do it yet.
// Made separate task to avoid deletion of player currently being created.
// Also, delaying GC until after player starts gets rid of starting lag --
// collection happens in parallel with playing.
//
// TODO(enal): remove when we get rid of per-audio-stream thread.
main_loop_->PostTask(
FROM_HERE,
base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory,
AsWeakPtr()));
// Use the null sink if no sink was provided. // Use the null sink if no sink was provided.
audio_source_provider_ = new WebAudioSourceProviderImpl( audio_source_provider_ = new WebAudioSourceProviderImpl(
params.audio_renderer_sink().get() params.audio_renderer_sink().get()
...@@ -246,13 +223,6 @@ WebMediaPlayerImpl::~WebMediaPlayerImpl() { ...@@ -246,13 +223,6 @@ WebMediaPlayerImpl::~WebMediaPlayerImpl() {
waiter.Wait(); waiter.Wait();
compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_);
// Let V8 know we are not using extra resources anymore.
if (incremented_externally_allocated_memory_) {
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
-kPlayerExtraMemory);
incremented_externally_allocated_memory_ = false;
}
} }
void WebMediaPlayerImpl::load(LoadType load_type, const blink::WebURL& url, void WebMediaPlayerImpl::load(LoadType load_type, const blink::WebURL& url,
...@@ -988,13 +958,6 @@ blink::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { ...@@ -988,13 +958,6 @@ blink::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() {
return audio_source_provider_.get(); return audio_source_provider_.get();
} }
void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
DCHECK(main_loop_->BelongsToCurrentThread());
incremented_externally_allocated_memory_ = true;
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
kPlayerExtraMemory);
}
double WebMediaPlayerImpl::GetPipelineDuration() const { double WebMediaPlayerImpl::GetPipelineDuration() const {
base::TimeDelta duration = pipeline_.GetMediaDuration(); base::TimeDelta duration = pipeline_.GetMediaDuration();
......
...@@ -199,9 +199,6 @@ class WebMediaPlayerImpl ...@@ -199,9 +199,6 @@ class WebMediaPlayerImpl
void SetNetworkState(blink::WebMediaPlayer::NetworkState state); void SetNetworkState(blink::WebMediaPlayer::NetworkState state);
void SetReadyState(blink::WebMediaPlayer::ReadyState state); void SetReadyState(blink::WebMediaPlayer::ReadyState state);
// Lets V8 know that player uses extra resources not managed by V8.
void IncrementExternallyAllocatedMemory();
// Gets the duration value reported by the pipeline. // Gets the duration value reported by the pipeline.
double GetPipelineDuration() const; double GetPipelineDuration() const;
...@@ -282,8 +279,6 @@ class WebMediaPlayerImpl ...@@ -282,8 +279,6 @@ class WebMediaPlayerImpl
base::Callback<void(const base::Closure&)> defer_load_cb_; base::Callback<void(const base::Closure&)> defer_load_cb_;
bool incremented_externally_allocated_memory_;
// Factories for supporting video accelerators. May be null. // Factories for supporting video accelerators. May be null.
scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_; scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment