summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/VulkanSurface.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2019-03-26 15:14:34 -0400
committerStan Iliev <stani@google.com>2019-03-26 15:14:34 -0400
commitbc5f06bdaa95da7e2a94d8827fffbadad7bc813d (patch)
treef1504301fc81b3680363f719e8d3903b27740181 /libs/hwui/renderthread/VulkanSurface.cpp
parentdece92b28744012f6db87f5100b511cd459218a1 (diff)
Fix crash after dequeueNativeBuffer fails
Anytime dequeueNativeBuffer fails, it sets mDequeuedIndex to -1. This is causing a crash latter, when getCurrentSkSurface tries to index mNativeBuffers[mDequeuedIndex]. This CL removes mDequeuedIndex and improves Vulkan swapchain error handling. Test: Ran Camera app Bug: 129024275 Change-Id: Ieeb685c3a1b33f23ce2334d286199a44ace53165
Diffstat (limited to 'libs/hwui/renderthread/VulkanSurface.cpp')
-rw-r--r--libs/hwui/renderthread/VulkanSurface.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp
index a98eb322cfc7..1708d3c0e093 100644
--- a/libs/hwui/renderthread/VulkanSurface.cpp
+++ b/libs/hwui/renderthread/VulkanSurface.cpp
@@ -420,9 +420,10 @@ void VulkanSurface::releaseBuffers() {
}
VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() {
- // Set the dequeue index to invalid in case of error and only reset it to the correct
+ // Set the mCurrentBufferInfo to invalid in case of error and only reset it to the correct
// value at the end of the function if everything dequeued correctly.
- mDequeuedIndex = -1;
+ mCurrentBufferInfo = nullptr;
+
//check if the native window has been resized or rotated and update accordingly
SkISize newSize = SkISize::MakeEmpty();
@@ -511,7 +512,7 @@ VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() {
}
}
- mDequeuedIndex = idx;
+ mCurrentBufferInfo = bufferInfo;
return bufferInfo;
}
@@ -535,7 +536,8 @@ bool VulkanSurface::presentCurrentBuffer(const SkRect& dirtyRect, int semaphoreF
ALOGE_IF(err != 0, "native_window_set_surface_damage failed: %s (%d)", strerror(-err), err);
}
- VulkanSurface::NativeBufferInfo& currentBuffer = mNativeBuffers[mDequeuedIndex];
+ LOG_ALWAYS_FATAL_IF(!mCurrentBufferInfo);
+ VulkanSurface::NativeBufferInfo& currentBuffer = *mCurrentBufferInfo;
int queuedFd = (semaphoreFd != -1) ? semaphoreFd : currentBuffer.dequeue_fence;
int err = mNativeWindow->queueBuffer(mNativeWindow.get(), currentBuffer.buffer.get(), queuedFd);
@@ -560,7 +562,8 @@ bool VulkanSurface::presentCurrentBuffer(const SkRect& dirtyRect, int semaphoreF
}
int VulkanSurface::getCurrentBuffersAge() {
- VulkanSurface::NativeBufferInfo& currentBuffer = mNativeBuffers[mDequeuedIndex];
+ LOG_ALWAYS_FATAL_IF(!mCurrentBufferInfo);
+ VulkanSurface::NativeBufferInfo& currentBuffer = *mCurrentBufferInfo;
return currentBuffer.hasValidContents ? (mPresentCount - currentBuffer.lastPresentedCount) : 0;
}