summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderProxy.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2017-02-02 14:11:53 -0500
committerStan Iliev <stani@google.com>2017-02-07 09:18:17 -0500
commit6983bc40d72acbf06cd04818877cb3f5fea22886 (patch)
tree5d434aa1bf61004cbe4f80aeafd130b2a77b0fae /libs/hwui/renderthread/RenderProxy.cpp
parentf6387d8a51ca7279b0573477293d3835acf42195 (diff)
Fix deadlock in render thread when Bitmap.prepareToDraw is invoked
Fix a deadlock with Skia pipelines, caused by calling Bitmap::getSkBitmap from render thread. Test: built and booted an image. Ran recent apps activity. bug: 35060578 bug: 34926691 Change-Id: Iaf7957b955d938b722b153d72ad832ae5d50e86f
Diffstat (limited to 'libs/hwui/renderthread/RenderProxy.cpp')
-rw-r--r--libs/hwui/renderthread/RenderProxy.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index fb79272e18af..11614fa144e3 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -667,11 +667,17 @@ CREATE_BRIDGE3(copyGraphicBufferInto, RenderThread* thread, GraphicBuffer* buffe
}
int RenderProxy::copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap) {
- SETUP_TASK(copyGraphicBufferInto);
- args->thread = &RenderThread::getInstance();
- args->bitmap = bitmap;
- args->buffer = buffer;
- return static_cast<int>(reinterpret_cast<intptr_t>(staticPostAndWait(task)));
+ RenderThread& thread = RenderThread::getInstance();
+ if (Properties::isSkiaEnabled() && gettid() == thread.getTid()) {
+ //TODO: fix everything that hits this. We should never be triggering a readback ourselves.
+ return (int) thread.readback().copyGraphicBufferInto(buffer, bitmap);
+ } else {
+ SETUP_TASK(copyGraphicBufferInto);
+ args->thread = &thread;
+ args->bitmap = bitmap;
+ args->buffer = buffer;
+ return static_cast<int>(reinterpret_cast<intptr_t>(staticPostAndWait(task)));
+ }
}
void RenderProxy::post(RenderTask* task) {
@@ -690,6 +696,7 @@ void* RenderProxy::postAndWait(MethodInvokeRenderTask* task) {
void* RenderProxy::staticPostAndWait(MethodInvokeRenderTask* task) {
RenderThread& thread = RenderThread::getInstance();
+ LOG_ALWAYS_FATAL_IF(gettid() == thread.getTid());
void* retval;
task->setReturnPtr(&retval);
thread.queueAndWait(task);