Browser Plugin: PpapiCommandBufferProxy should see a lost context if the embedder has deleted the PluginInstance
In cross-process navigation we swap out PluginInstances and delete the swapped out instance.
PpapiCommandBufferProxy is sitting in WebGraphicsContext3DCommandBufferImpl, and is unaware of the destruction.
It attempts to talk to the embedder to flush over and over again and hangs the guest renderer.
With this change, the renderer's compositor will realize that the context is lost, and will drop it.
BUG=none
TEST=manually.
Review URL: https://chromiumcodereview.appspot.com/10387182
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137981 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc
index 5e0f454..56ebf65 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.cc
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc
@@ -99,9 +99,10 @@
// Send will flag state with lost context if IPC fails.
if (last_state_.error == gpu::error::kNoError) {
gpu::CommandBuffer::State state;
+ bool success = false;
if (Send(new PpapiHostMsg_PPBGraphics3D_GetState(
- ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &state))) {
- UpdateState(state);
+ ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &state, &success))) {
+ UpdateState(state, success);
}
}
@@ -132,10 +133,11 @@
// Send will flag state with lost context if IPC fails.
if (last_state_.error == gpu::error::kNoError) {
gpu::CommandBuffer::State state;
+ bool success = false;
if (Send(new PpapiHostMsg_PPBGraphics3D_Flush(
ppapi::API_ID_PPB_GRAPHICS_3D, resource_, put_offset,
- last_known_get, &state))) {
- UpdateState(state);
+ last_known_get, &state, &success))) {
+ UpdateState(state, success);
}
}
} else {
@@ -259,11 +261,17 @@
}
void PpapiCommandBufferProxy::UpdateState(
- const gpu::CommandBuffer::State& state) {
+ const gpu::CommandBuffer::State& state,
+ bool success) {
// Handle wraparound. It works as long as we don't have more than 2B state
// updates in flight across which reordering occurs.
- if (state.generation - last_state_.generation < 0x80000000U)
- last_state_ = state;
+ if (success) {
+ if (state.generation - last_state_.generation < 0x80000000U) {
+ last_state_ = state;
+ } else
+ last_state_.error = gpu::error::kLostContext;
+ ++last_state_.generation;
+ }
}
} // namespace proxy
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h
index 389ca35..015ce38 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.h
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.h
@@ -66,7 +66,7 @@
private:
bool Send(IPC::Message* msg);
- void UpdateState(const gpu::CommandBuffer::State& state);
+ void UpdateState(const gpu::CommandBuffer::State& state, bool success);
typedef base::hash_map<int32, gpu::Buffer> TransferBufferMap;
TransferBufferMap transfer_buffers_;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index b96f13d..536d702d 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -786,14 +786,16 @@
IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBGraphics3D_SetGetBuffer,
ppapi::HostResource /* context */,
int32 /* transfer_buffer_id */)
-IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBGraphics3D_GetState,
+IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBGraphics3D_GetState,
ppapi::HostResource /* context */,
- gpu::CommandBuffer::State /* state */)
-IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics3D_Flush,
+ gpu::CommandBuffer::State /* state */,
+ bool /* success */)
+IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBGraphics3D_Flush,
ppapi::HostResource /* context */,
int32 /* put_offset */,
int32 /* last_known_get */,
- gpu::CommandBuffer::State /* state */)
+ gpu::CommandBuffer::State /* state */,
+ bool /* success */)
IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBGraphics3D_AsyncFlush,
ppapi::HostResource /* context */,
int32 /* put_offset */)
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc
index 75f7d83..2a708a3 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -246,24 +246,32 @@
}
void PPB_Graphics3D_Proxy::OnMsgGetState(const HostResource& context,
- gpu::CommandBuffer::State* state) {
+ gpu::CommandBuffer::State* state,
+ bool* success) {
EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
- if (enter.failed())
+ if (enter.failed()) {
+ *success = false;
return;
+ }
PP_Graphics3DTrustedState pp_state = enter.object()->GetState();
*state = GPUStateFromPPState(pp_state);
+ *success = true;
}
void PPB_Graphics3D_Proxy::OnMsgFlush(const HostResource& context,
int32 put_offset,
int32 last_known_get,
- gpu::CommandBuffer::State* state) {
+ gpu::CommandBuffer::State* state,
+ bool* success) {
EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
- if (enter.failed())
+ if (enter.failed()) {
+ *success = false;
return;
+ }
PP_Graphics3DTrustedState pp_state = enter.object()->FlushSyncFast(
put_offset, last_known_get);
*state = GPUStateFromPPState(pp_state);
+ *success = true;
}
void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context,
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h
index 310e0c2..c6975bf 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.h
@@ -78,11 +78,13 @@
void OnMsgSetGetBuffer(const HostResource& context,
int32 id);
void OnMsgGetState(const HostResource& context,
- gpu::CommandBuffer::State* state);
+ gpu::CommandBuffer::State* state,
+ bool* success);
void OnMsgFlush(const HostResource& context,
int32 put_offset,
int32 last_known_get,
- gpu::CommandBuffer::State* state);
+ gpu::CommandBuffer::State* state,
+ bool* success);
void OnMsgAsyncFlush(const HostResource& context,
int32 put_offset);
void OnMsgCreateTransferBuffer(const HostResource& context,