Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3cd68bc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tell JVM to not wait for HWUI worker threads upon shutdown"

parents 55593a98 80dbc355
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1207,7 +1207,7 @@ static void attachRenderThreadToJvm() {

    JavaVMAttachArgs args;
    args.version = JNI_VERSION_1_4;
    args.name = (char*) "RenderThread";
    args.name = NULL;
    args.group = NULL;
    JNIEnv* env;
    mJvm->AttachCurrentThreadAsDaemon(&env, (void*) &args);
+6 −2
Original line number Diff line number Diff line
@@ -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
+4 −1
Original line number Diff line number Diff line
@@ -75,12 +75,15 @@ struct VsyncSource {

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(); }

+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "TaskManager.h"
#include "TaskProcessor.h"
#include "utils/MathUtils.h"
#include "renderthread/RenderThread.h"

namespace android {
namespace uirenderer {
@@ -84,6 +85,11 @@ bool TaskManager::addTaskBase(const sp<TaskBase>& task, const sp<TaskProcessorBa

status_t TaskManager::WorkerThread::readyToRun() {
    setpriority(PRIO_PROCESS, 0, PRIORITY_FOREGROUND);
    auto onStartHook = renderthread::RenderThread::getOnStartHook();
    if (onStartHook) {
        onStartHook();
    }

    return NO_ERROR;
}

+2 −1
Original line number Diff line number Diff line
@@ -77,7 +77,8 @@ private:

    class WorkerThread : public Thread {
    public:
        explicit WorkerThread(const String8& name) : mSignal(Condition::WAKE_UP_ONE), mName(name) {}
        explicit WorkerThread(const String8& name)
                : Thread(false), mSignal(Condition::WAKE_UP_ONE), mName(name) {}

        bool addTask(const TaskWrapper& task);
        size_t getTaskCount() const;