Commit 571b35e8 authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

Browser Plugin: PpapiCommandBufferProxy should see a lost context if the...

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
parent 0ab08e54
......@@ -99,9 +99,10 @@ gpu::CommandBuffer::State PpapiCommandBufferProxy::GetState() {
// 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 @@ gpu::CommandBuffer::State PpapiCommandBufferProxy::FlushSync(int32 put_offset,
// 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 @@ bool PpapiCommandBufferProxy::Send(IPC::Message* msg) {
}
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
......
......@@ -66,7 +66,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public CommandBufferProxy {
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_;
......
......@@ -786,14 +786,16 @@ IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer,
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 */)
......
......@@ -246,24 +246,32 @@ void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer(
}
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,
......
......@@ -78,11 +78,13 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy {
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,
......
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