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
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index 1ef83fb..d062dba 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -75,12 +75,15 @@
class DummyVsyncSource;
+typedef void (*JVMAttachHook)();
+
class RenderThread : private ThreadBase {
PREVENT_COPY_AND_ASSIGN(RenderThread);
public:
// Sets a callback that fires before any RenderThread setup has occurred.
- ANDROID_API static void setOnStartHook(void (*onStartHook)());
+ ANDROID_API static void setOnStartHook(JVMAttachHook onStartHook);
+ static JVMAttachHook getOnStartHook();
WorkQueue& queue() { return ThreadBase::queue(); }