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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 1969163002: Give the media context small memory limits (same as compositor). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: limitsmedia: . Created 4 years, 7 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
« no previous file with comments | « no previous file | content/renderer/render_widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 for (size_t i = 0; i < pieces.size(); ++i) { 399 for (size_t i = 0; i < pieces.size(); ++i) {
400 unsigned number = 0; 400 unsigned number = 0;
401 bool succeed = base::StringToUint(pieces[i], &number); 401 bool succeed = base::StringToUint(pieces[i], &number);
402 DCHECK(succeed); 402 DCHECK(succeed);
403 vector->push_back(number); 403 vector->push_back(number);
404 } 404 }
405 } 405 }
406 406
407 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( 407 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext(
408 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, 408 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
409 const gpu::SharedMemoryLimits& limits,
409 command_buffer_metrics::ContextType type, 410 command_buffer_metrics::ContextType type,
410 int32_t stream_id, 411 int32_t stream_id,
411 gpu::GpuStreamPriority stream_priority) { 412 gpu::GpuStreamPriority stream_priority) {
412 DCHECK(gpu_channel_host); 413 DCHECK(gpu_channel_host);
413 // This is used to create a few different offscreen contexts: 414 // This is used to create a few different offscreen contexts:
414 // - The shared main thread context (offscreen) used by blink for canvas. 415 // - The shared main thread context (offscreen) used by blink for canvas.
415 // - The worker context (offscreen) used for GPU raster and video decoding. 416 // - The worker context (offscreen) used for GPU raster and video decoding.
416 // This is for an offscreen context, so the default framebuffer doesn't need 417 // This is for an offscreen context, so the default framebuffer doesn't need
417 // alpha, depth, stencil, antialiasing. 418 // alpha, depth, stencil, antialiasing.
418 gpu::gles2::ContextCreationAttribHelper attributes; 419 gpu::gles2::ContextCreationAttribHelper attributes;
419 attributes.alpha_size = -1; 420 attributes.alpha_size = -1;
420 attributes.depth_size = 0; 421 attributes.depth_size = 0;
421 attributes.stencil_size = 0; 422 attributes.stencil_size = 0;
422 attributes.samples = 0; 423 attributes.samples = 0;
423 attributes.sample_buffers = 0; 424 attributes.sample_buffers = 0;
424 attributes.bind_generates_resource = false; 425 attributes.bind_generates_resource = false;
425 attributes.lose_context_when_out_of_memory = true; 426 attributes.lose_context_when_out_of_memory = true;
426 const bool automatic_flushes = false; 427 const bool automatic_flushes = false;
427 return make_scoped_refptr(new ContextProviderCommandBuffer( 428 return make_scoped_refptr(new ContextProviderCommandBuffer(
428 std::move(gpu_channel_host), stream_id, stream_priority, 429 std::move(gpu_channel_host), stream_id, stream_priority,
429 gpu::kNullSurfaceHandle, 430 gpu::kNullSurfaceHandle,
430 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), 431 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"),
431 gfx::PreferIntegratedGpu, automatic_flushes, gpu::SharedMemoryLimits(), 432 gfx::PreferIntegratedGpu, automatic_flushes, limits, attributes, nullptr,
432 attributes, nullptr, type)); 433 type));
433 } 434 }
434 435
435 } // namespace 436 } // namespace
436 437
437 // For measuring memory usage after each task. Behind a command line flag. 438 // For measuring memory usage after each task. Behind a command line flag.
438 class MemoryObserver : public base::MessageLoop::TaskObserver { 439 class MemoryObserver : public base::MessageLoop::TaskObserver {
439 public: 440 public:
440 MemoryObserver() {} 441 MemoryObserver() {}
441 ~MemoryObserver() override {} 442 ~MemoryObserver() override {}
442 443
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 } 1408 }
1408 } 1409 }
1409 } 1410 }
1410 1411
1411 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 1412 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
1412 1413
1413 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = 1414 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host =
1414 EstablishGpuChannelSync(CAUSE_FOR_GPU_LAUNCH_MEDIA_CONTEXT); 1415 EstablishGpuChannelSync(CAUSE_FOR_GPU_LAUNCH_MEDIA_CONTEXT);
1415 if (!gpu_channel_host) 1416 if (!gpu_channel_host)
1416 return nullptr; 1417 return nullptr;
1418 // This context is only used to create textures and mailbox them, so
1419 // use lower limits than the default.
1420 gpu::SharedMemoryLimits limits = gpu::SharedMemoryLimits::ForMailboxContext();
1417 scoped_refptr<ContextProviderCommandBuffer> media_context_provider = 1421 scoped_refptr<ContextProviderCommandBuffer> media_context_provider =
1418 CreateOffscreenContext( 1422 CreateOffscreenContext(gpu_channel_host, limits,
1419 gpu_channel_host, command_buffer_metrics::RENDER_WORKER_CONTEXT, 1423 command_buffer_metrics::RENDER_WORKER_CONTEXT,
1420 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL); 1424 gpu::GPU_STREAM_DEFAULT,
1425 gpu::GpuStreamPriority::NORMAL);
1421 if (!media_context_provider->BindToCurrentThread()) 1426 if (!media_context_provider->BindToCurrentThread())
1422 return nullptr; 1427 return nullptr;
1423 media_context_provider->SetupLock(); 1428 media_context_provider->SetupLock();
1424 1429
1425 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = 1430 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner =
1426 GetMediaThreadTaskRunner(); 1431 GetMediaThreadTaskRunner();
1427 const bool enable_video_accelerator = 1432 const bool enable_video_accelerator =
1428 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); 1433 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode);
1429 const bool enable_gpu_memory_buffer_video_frames = 1434 const bool enable_gpu_memory_buffer_video_frames =
1430 #if defined(OS_MACOSX) || defined(OS_LINUX) 1435 #if defined(OS_MACOSX) || defined(OS_LINUX)
(...skipping 24 matching lines...) Expand all
1455 return shared_main_thread_contexts_; 1460 return shared_main_thread_contexts_;
1456 1461
1457 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( 1462 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
1458 CAUSE_FOR_GPU_LAUNCH_RENDERER_SHARED_MAIN_THREAD_CONTEXT)); 1463 CAUSE_FOR_GPU_LAUNCH_RENDERER_SHARED_MAIN_THREAD_CONTEXT));
1459 if (!gpu_channel_host) { 1464 if (!gpu_channel_host) {
1460 shared_main_thread_contexts_ = nullptr; 1465 shared_main_thread_contexts_ = nullptr;
1461 return nullptr; 1466 return nullptr;
1462 } 1467 }
1463 1468
1464 shared_main_thread_contexts_ = CreateOffscreenContext( 1469 shared_main_thread_contexts_ = CreateOffscreenContext(
1465 std::move(gpu_channel_host), 1470 std::move(gpu_channel_host), gpu::SharedMemoryLimits(),
1466 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT, 1471 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT,
1467 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL); 1472 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL);
1468 if (!shared_main_thread_contexts_->BindToCurrentThread()) 1473 if (!shared_main_thread_contexts_->BindToCurrentThread())
1469 shared_main_thread_contexts_ = nullptr; 1474 shared_main_thread_contexts_ = nullptr;
1470 return shared_main_thread_contexts_; 1475 return shared_main_thread_contexts_;
1471 } 1476 }
1472 1477
1473 #if defined(OS_ANDROID) 1478 #if defined(OS_ANDROID)
1474 1479
1475 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { 1480 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() {
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 return shared_worker_context_provider_; 1966 return shared_worker_context_provider_;
1962 } 1967 }
1963 1968
1964 int32_t stream_id = gpu::GPU_STREAM_DEFAULT; 1969 int32_t stream_id = gpu::GPU_STREAM_DEFAULT;
1965 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; 1970 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
1966 if (is_async_worker_context_enabled_) { 1971 if (is_async_worker_context_enabled_) {
1967 stream_id = gpu_channel_host->GenerateStreamID(); 1972 stream_id = gpu_channel_host->GenerateStreamID();
1968 stream_priority = gpu::GpuStreamPriority::LOW; 1973 stream_priority = gpu::GpuStreamPriority::LOW;
1969 } 1974 }
1970 1975
1971 shared_worker_context_provider_ = 1976 shared_worker_context_provider_ = CreateOffscreenContext(
1972 CreateOffscreenContext(std::move(gpu_channel_host), 1977 std::move(gpu_channel_host), gpu::SharedMemoryLimits(),
1973 command_buffer_metrics::RENDER_WORKER_CONTEXT, 1978 command_buffer_metrics::RENDER_WORKER_CONTEXT, stream_id,
1974 stream_id, stream_priority); 1979 stream_priority);
1975 if (!shared_worker_context_provider_->BindToCurrentThread()) 1980 if (!shared_worker_context_provider_->BindToCurrentThread())
1976 shared_worker_context_provider_ = nullptr; 1981 shared_worker_context_provider_ = nullptr;
1977 if (shared_worker_context_provider_) 1982 if (shared_worker_context_provider_)
1978 shared_worker_context_provider_->SetupLock(); 1983 shared_worker_context_provider_->SetupLock();
1979 return shared_worker_context_provider_; 1984 return shared_worker_context_provider_;
1980 } 1985 }
1981 1986
1982 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { 1987 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) {
1983 blink_platform_impl_->sampleGamepads(*data); 1988 blink_platform_impl_->sampleGamepads(*data);
1984 } 1989 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) 2088 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical)
2084 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; 2089 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate;
2085 2090
2086 blink::mainThreadIsolate()->MemoryPressureNotification( 2091 blink::mainThreadIsolate()->MemoryPressureNotification(
2087 v8_memory_pressure_level); 2092 v8_memory_pressure_level);
2088 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2093 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2089 v8_memory_pressure_level); 2094 v8_memory_pressure_level);
2090 } 2095 }
2091 2096
2092 } // namespace content 2097 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698