Commit 71c324a0 authored by piman@chromium.org's avatar piman@chromium.org

Fix channel lost race in GpuChannelHost

The problem this fixes is, depending on the exact timing, a context would
receive a lost context callback (task 1), and would then post a task to recreate
the context (task 2). In parallel a task would be posted to signal the
GpuChannelHost that the channel is lost (task 3).

Because task 3 is posted from the IO thread, whereas task 2 is posted from
another thread (but they both are posted to the "main" thread), the race in
posting results in a race in execution, and task 2 may try to recreate a context
using a channel that doesn't know yet that it's non-functional, resulting in
failing to send the message and failing to create the context.

This patch changes the post order - task 3 is posted before task 1 - ensuring
task 2 is posted after task 3 (since task 2 is posted after task 1 executes).

BUG=129067


Review URL: https://chromiumcodereview.appspot.com/10837104

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149976 0039d316-1c4b-4281-b951-d872f2087c98
parent e4d763ea
......@@ -286,6 +286,13 @@ bool GpuChannelHost::MessageFilter::OnMessageReceived(
void GpuChannelHost::MessageFilter::OnChannelError() {
DCHECK(parent_->factory_->IsIOThread());
// Post the task to signal the GpuChannelHost before the proxies. That way, if
// they themselves post a task to recreate the context, they will not try to
// re-use this channel host before it has a chance to mark itself lost.
MessageLoop* main_loop = parent_->factory_->GetMainLoop();
main_loop->PostTask(FROM_HERE,
base::Bind(&GpuChannelHost::OnChannelError, parent_));
// Inform all the proxies that an error has occurred. This will be reported
// via OpenGL as a lost context.
for (ListenerMap::iterator it = listeners_.begin();
......@@ -298,10 +305,6 @@ void GpuChannelHost::MessageFilter::OnChannelError() {
}
listeners_.clear();
MessageLoop* main_loop = parent_->factory_->GetMainLoop();
main_loop->PostTask(FROM_HERE,
base::Bind(&GpuChannelHost::OnChannelError, parent_));
}
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