OSDN Git Service

Fix ANR & Crash on Ryu
authorJohn Reck <jreck@google.com>
Thu, 1 Jun 2017 19:44:58 +0000 (12:44 -0700)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Fri, 2 Jun 2017 00:54:09 +0000 (00:54 +0000)
Fixes impossible dequeue crash as the wrong
start point of the frame was used. We need
to use the start point for RT, not the start
point for the frame.

Workaround for sysui ANR caused by what appears
to be a driver bug. Drivers with the bug
will have transiently higher memory usage.
Drivers without the bug will be unaffected.

Bug: 62213889
Bug: 62250550
Test: Manual

Change-Id: I9992b224f84bc1c40834bafff7e0013b38270ae0
(cherry picked from commit a67b62e15e20bac6a9664e6e6be923cf82ad4138)

core/jni/android_view_ThreadedRenderer.cpp
libs/hwui/renderthread/CanvasContext.cpp

index 192e3bb..8c28cc9 100644 (file)
@@ -877,7 +877,8 @@ static jobject android_view_ThreadedRenderer_createHardwareBitmapFromRenderNode(
     sp<IGraphicBufferProducer> producer;
     sp<IGraphicBufferConsumer> rawConsumer;
     BufferQueue::createBufferQueue(&producer, &rawConsumer);
-    rawConsumer->setMaxBufferCount(1);
+    // We only need 1 buffer but some drivers have bugs so workaround it by setting max count to 2
+    rawConsumer->setMaxBufferCount(2);
     sp<BufferItemConsumer> consumer = new BufferItemConsumer(rawConsumer,
             GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_NEVER);
     consumer->setDefaultBufferSize(width, height);
index cbc5163..9c80ab3 100644 (file)
@@ -437,8 +437,8 @@ void CanvasContext::draw() {
         if (mNativeSurface.get()) {
             int durationUs;
             nsecs_t dequeueStart = mNativeSurface->getLastDequeueStartTime();
-            if (dequeueStart < mCurrentFrameInfo->get(FrameInfoIndex::Vsync)) {
-                // Ignoring dequeue duration as it happened prior to vsync
+            if (dequeueStart < mCurrentFrameInfo->get(FrameInfoIndex::SyncStart)) {
+                // Ignoring dequeue duration as it happened prior to frame render start
                 // and thus is not part of the frame.
                 swap.dequeueDuration = 0;
             } else {