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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 10695133: Improve GPU process URL crash reporting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: using net hash function instead of messing with hash_tables.h Created 8 years, 5 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 | Annotate | Revision Log
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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/common/gpu/gpu_channel.h" 14 #include "content/common/gpu/gpu_channel.h"
15 #include "content/common/gpu/gpu_channel_manager.h" 15 #include "content/common/gpu/gpu_channel_manager.h"
16 #include "content/common/gpu/gpu_command_buffer_stub.h" 16 #include "content/common/gpu/gpu_command_buffer_stub.h"
17 #include "content/common/gpu/gpu_memory_manager.h" 17 #include "content/common/gpu/gpu_memory_manager.h"
18 #include "content/common/gpu/gpu_messages.h" 18 #include "content/common/gpu/gpu_messages.h"
19 #include "content/common/gpu/gpu_watchdog.h" 19 #include "content/common/gpu/gpu_watchdog.h"
20 #include "content/common/gpu/image_transport_surface.h" 20 #include "content/common/gpu/image_transport_surface.h"
21 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 21 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
22 #include "content/common/gpu/sync_point_manager.h" 22 #include "content/common/gpu/sync_point_manager.h"
23 #include "content/public/common/content_client.h"
23 #include "gpu/command_buffer/common/constants.h" 24 #include "gpu/command_buffer/common/constants.h"
24 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
26 #include "net/disk_cache/hash.h"
25 #include "ui/gl/gl_bindings.h" 27 #include "ui/gl/gl_bindings.h"
26 #include "ui/gl/gl_switches.h" 28 #include "ui/gl/gl_switches.h"
27 29
28 #if defined(OS_WIN) 30 #if defined(OS_WIN)
29 #include "content/public/common/sandbox_init.h" 31 #include "content/public/common/sandbox_init.h"
30 #endif 32 #endif
31 33
32 namespace { 34 namespace {
35
36 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the
37 // url_hash matches.
38 void FastSetActiveURL(const GURL& url, size_t url_hash) {
39 // Leave the previously set URL in the empty case -- empty URLs are given by
40 // WebKitPlatformSupportImpl::createOffscreenGraphicsContext3D. Hopefully the
41 // onscreen context URL was set previously and will show up even when a crash
42 // occurs during offscreen command processing.
43 if (url.is_empty())
44 return;
45 static size_t g_last_url_hash = 0;
46 if (url_hash != g_last_url_hash) {
47 g_last_url_hash = url_hash;
48 content::GetContentClient()->SetActiveURL(url);
49 }
50 }
51
33 // The first time polling a fence, delay some extra time to allow other 52 // The first time polling a fence, delay some extra time to allow other
34 // stubs to process some work, or else the timing of the fences could 53 // stubs to process some work, or else the timing of the fences could
35 // allow a pattern of alternating fast and slow frames to occur. 54 // allow a pattern of alternating fast and slow frames to occur.
36 const int64 kHandleMoreWorkPeriodMs = 2; 55 const int64 kHandleMoreWorkPeriodMs = 2;
37 const int64 kHandleMoreWorkPeriodBusyMs = 1; 56 const int64 kHandleMoreWorkPeriodBusyMs = 1;
38 } 57
58 } // namespace
39 59
40 GpuCommandBufferStub::SurfaceState::SurfaceState(int32 surface_id, 60 GpuCommandBufferStub::SurfaceState::SurfaceState(int32 surface_id,
41 bool visible, 61 bool visible,
42 base::TimeTicks last_used_time) 62 base::TimeTicks last_used_time)
43 : surface_id(surface_id), 63 : surface_id(surface_id),
44 visible(visible), 64 visible(visible),
45 last_used_time(last_used_time) { 65 last_used_time(last_used_time) {
46 } 66 }
47 67
48 GpuCommandBufferStub::GpuCommandBufferStub( 68 GpuCommandBufferStub::GpuCommandBufferStub(
49 GpuChannel* channel, 69 GpuChannel* channel,
50 GpuCommandBufferStub* share_group, 70 GpuCommandBufferStub* share_group,
51 const gfx::GLSurfaceHandle& handle, 71 const gfx::GLSurfaceHandle& handle,
52 gpu::gles2::MailboxManager* mailbox_manager, 72 gpu::gles2::MailboxManager* mailbox_manager,
53 const gfx::Size& size, 73 const gfx::Size& size,
54 const gpu::gles2::DisallowedFeatures& disallowed_features, 74 const gpu::gles2::DisallowedFeatures& disallowed_features,
55 const std::string& allowed_extensions, 75 const std::string& allowed_extensions,
56 const std::vector<int32>& attribs, 76 const std::vector<int32>& attribs,
57 gfx::GpuPreference gpu_preference, 77 gfx::GpuPreference gpu_preference,
58 int32 route_id, 78 int32 route_id,
59 int32 surface_id, 79 int32 surface_id,
60 GpuWatchdog* watchdog, 80 GpuWatchdog* watchdog,
61 bool software) 81 bool software,
82 const GURL& active_url)
62 : channel_(channel), 83 : channel_(channel),
63 handle_(handle), 84 handle_(handle),
64 initial_size_(size), 85 initial_size_(size),
65 disallowed_features_(disallowed_features), 86 disallowed_features_(disallowed_features),
66 allowed_extensions_(allowed_extensions), 87 allowed_extensions_(allowed_extensions),
67 requested_attribs_(attribs), 88 requested_attribs_(attribs),
68 gpu_preference_(gpu_preference), 89 gpu_preference_(gpu_preference),
69 route_id_(route_id), 90 route_id_(route_id),
70 software_(software), 91 software_(software),
71 client_has_memory_allocation_changed_callback_(false), 92 client_has_memory_allocation_changed_callback_(false),
72 last_flush_count_(0), 93 last_flush_count_(0),
73 parent_stub_for_initialization_(), 94 parent_stub_for_initialization_(),
74 parent_texture_for_initialization_(0), 95 parent_texture_for_initialization_(0),
75 watchdog_(watchdog), 96 watchdog_(watchdog),
76 sync_point_wait_count_(0), 97 sync_point_wait_count_(0),
77 delayed_work_scheduled_(false) { 98 delayed_work_scheduled_(false),
99 active_url_(active_url) {
100 active_url_hash_ =
101 disk_cache::Hash(active_url.possibly_invalid_spec());
102 FastSetActiveURL(active_url_, active_url_hash_);
78 if (share_group) { 103 if (share_group) {
79 context_group_ = share_group->context_group_; 104 context_group_ = share_group->context_group_;
80 } else { 105 } else {
81 context_group_ = new gpu::gles2::ContextGroup(mailbox_manager, true); 106 context_group_ = new gpu::gles2::ContextGroup(mailbox_manager, true);
82 } 107 }
83 if (surface_id != 0) 108 if (surface_id != 0)
84 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( 109 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState(
85 surface_id, true, base::TimeTicks::Now())); 110 surface_id, true, base::TimeTicks::Now()));
86 if (handle_.sync_point) 111 if (handle_.sync_point)
87 OnWaitSyncPoint(handle_.sync_point); 112 OnWaitSyncPoint(handle_.sync_point);
88 } 113 }
89 114
90 GpuCommandBufferStub::~GpuCommandBufferStub() { 115 GpuCommandBufferStub::~GpuCommandBufferStub() {
91 Destroy(); 116 Destroy();
92 117
93 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 118 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
94 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id())); 119 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id()));
95 } 120 }
96 121
97 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { 122 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
123 FastSetActiveURL(active_url_, active_url_hash_);
124
98 // Ensure the appropriate GL context is current before handling any IPC 125 // Ensure the appropriate GL context is current before handling any IPC
99 // messages directed at the command buffer. This ensures that the message 126 // messages directed at the command buffer. This ensures that the message
100 // handler can assume that the context is current (not necessary for 127 // handler can assume that the context is current (not necessary for
101 // Echo, RetireSyncPoint, or WaitSyncPoint). 128 // Echo, RetireSyncPoint, or WaitSyncPoint).
102 if (decoder_.get() && 129 if (decoder_.get() &&
103 message.type() != GpuCommandBufferMsg_Echo::ID && 130 message.type() != GpuCommandBufferMsg_Echo::ID &&
104 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && 131 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID &&
105 message.type() != GpuCommandBufferMsg_WaitSyncPoint::ID) { 132 message.type() != GpuCommandBufferMsg_WaitSyncPoint::ID) {
106 if (!MakeCurrent()) 133 if (!MakeCurrent())
107 return false; 134 return false;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (CommandLine::ForCurrentProcess()->HasSwitch( 391 if (CommandLine::ForCurrentProcess()->HasSwitch(
365 switches::kEnableGPUServiceLogging)) { 392 switches::kEnableGPUServiceLogging)) {
366 decoder_->set_log_commands(true); 393 decoder_->set_log_commands(true);
367 } 394 }
368 395
369 decoder_->SetMsgCallback( 396 decoder_->SetMsgCallback(
370 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, 397 base::Bind(&GpuCommandBufferStub::SendConsoleMessage,
371 base::Unretained(this))); 398 base::Unretained(this)));
372 399
373 command_buffer_->SetPutOffsetChangeCallback( 400 command_buffer_->SetPutOffsetChangeCallback(
374 base::Bind(&gpu::GpuScheduler::PutChanged, 401 base::Bind(&GpuCommandBufferStub::PutChanged, base::Unretained(this)));
375 base::Unretained(scheduler_.get())));
376 command_buffer_->SetGetBufferChangeCallback( 402 command_buffer_->SetGetBufferChangeCallback(
377 base::Bind(&gpu::GpuScheduler::SetGetBuffer, 403 base::Bind(&gpu::GpuScheduler::SetGetBuffer,
378 base::Unretained(scheduler_.get()))); 404 base::Unretained(scheduler_.get())));
379 command_buffer_->SetParseErrorCallback( 405 command_buffer_->SetParseErrorCallback(
380 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); 406 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this)));
381 scheduler_->SetScheduledCallback( 407 scheduler_->SetScheduledCallback(
382 base::Bind(&GpuCommandBufferStub::OnReschedule, base::Unretained(this))); 408 base::Bind(&GpuCommandBufferStub::OnReschedule, base::Unretained(this)));
383 409
384 if (watchdog_) { 410 if (watchdog_) {
385 scheduler_->SetCommandProcessedCallback( 411 scheduler_->SetCommandProcessedCallback(
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 void GpuCommandBufferStub::ReportState() { 627 void GpuCommandBufferStub::ReportState() {
602 gpu::CommandBuffer::State state = command_buffer_->GetState(); 628 gpu::CommandBuffer::State state = command_buffer_->GetState();
603 if (state.error == gpu::error::kLostContext && 629 if (state.error == gpu::error::kLostContext &&
604 gfx::GLContext::LosesAllContextsOnContextLost()) { 630 gfx::GLContext::LosesAllContextsOnContextLost()) {
605 channel_->LoseAllContexts(); 631 channel_->LoseAllContexts();
606 } else { 632 } else {
607 command_buffer_->UpdateState(); 633 command_buffer_->UpdateState();
608 } 634 }
609 } 635 }
610 636
637 void GpuCommandBufferStub::PutChanged() {
638 FastSetActiveURL(active_url_, active_url_hash_);
639 scheduler_->PutChanged();
640 }
641
611 void GpuCommandBufferStub::OnCreateVideoDecoder( 642 void GpuCommandBufferStub::OnCreateVideoDecoder(
612 media::VideoCodecProfile profile, 643 media::VideoCodecProfile profile,
613 IPC::Message* reply_message) { 644 IPC::Message* reply_message) {
614 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateVideoDecoder"); 645 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateVideoDecoder");
615 int decoder_route_id = channel_->GenerateRouteID(); 646 int decoder_route_id = channel_->GenerateRouteID();
616 GpuVideoDecodeAccelerator* decoder = 647 GpuVideoDecodeAccelerator* decoder =
617 new GpuVideoDecodeAccelerator(this, decoder_route_id, this); 648 new GpuVideoDecodeAccelerator(this, decoder_route_id, this);
618 video_decoders_.AddWithID(decoder, decoder_route_id); 649 video_decoders_.AddWithID(decoder, decoder_route_id);
619 channel_->AddRoute(decoder_route_id, decoder); 650 channel_->AddRoute(decoder_route_id, decoder);
620 decoder->Initialize(profile, reply_message); 651 decoder->Initialize(profile, reply_message);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 const GpuMemoryAllocation& allocation) { 796 const GpuMemoryAllocation& allocation) {
766 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); 797 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation));
767 // This can be called outside of OnMessageReceived, so the context needs to be 798 // This can be called outside of OnMessageReceived, so the context needs to be
768 // made current before calling methods on the surface. 799 // made current before calling methods on the surface.
769 if (!surface_ || !MakeCurrent()) 800 if (!surface_ || !MakeCurrent())
770 return; 801 return;
771 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); 802 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer);
772 } 803 }
773 804
774 #endif // defined(ENABLE_GPU) 805 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/webkitplatformsupport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698