summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderThread.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2019-02-05 15:31:28 -0500
committerStan Iliev <stani@google.com>2019-02-05 16:26:58 -0500
commit80dbc35555d21f65fcfe4ede5d7b406cc4190a97 (patch)
tree7987c3c94fce4914026bd2b9cbd42674c19b2a21 /libs/hwui/renderthread/RenderThread.cpp
parent912ca4023c22c53d3526ce89fd6e7e1a90fe8e58 (diff)
Tell JVM to not wait for HWUI worker threads upon shutdown
RenderThread is setup as a daemon thread, which allows JVM to exit without waiting on it. This CL does same setup for HWUI worker threads, which offload work from the RenderThread. This fixes an issue exposed by Vulkan pipeline, which is pushing different loads to the worker threads and causing some java tests to hang on exit. This is not a Vulkan specific issue, because GL also hangs if worker thread is started. Bug: 123374538 Test: Ran DismissDialogsInstrumentation test Change-Id: Ie4ee94737ced975323a0792f57f8426c958e8056
Diffstat (limited to 'libs/hwui/renderthread/RenderThread.cpp')
-rw-r--r--libs/hwui/renderthread/RenderThread.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index 8bef35915c4d..caad80651395 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -56,7 +56,7 @@ static const nsecs_t DISPATCH_FRAME_CALLBACKS_DELAY = milliseconds_to_nanosecond
static bool gHasRenderThreadInstance = false;
-static void (*gOnStartHook)() = nullptr;
+static JVMAttachHook gOnStartHook = nullptr;
class DisplayEventReceiverWrapper : public VsyncSource {
public:
@@ -111,11 +111,15 @@ bool RenderThread::hasInstance() {
return gHasRenderThreadInstance;
}
-void RenderThread::setOnStartHook(void (*onStartHook)()) {
+void RenderThread::setOnStartHook(JVMAttachHook onStartHook) {
LOG_ALWAYS_FATAL_IF(hasInstance(), "can't set an onStartHook after we've started...");
gOnStartHook = onStartHook;
}
+JVMAttachHook RenderThread::getOnStartHook() {
+ return gOnStartHook;
+}
+
RenderThread& RenderThread::getInstance() {
// This is a pointer because otherwise __cxa_finalize
// will try to delete it like a Good Citizen but that causes us to crash