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

Commit 350e6520 authored by Doris Liu's avatar Doris Liu
Browse files

End staging animators when destroy RootRenderNode

When animation happens in a dialog, it is possible for the dialog to
be dismissed and RootRenderNode to be destroyed before we create
animation handle for the staged animators. In that case, we need
to remove the staged animators so they will not run without a
animation handle.

Bug: 26975079
Change-Id: I0c2c6c1b530beaec3984c0b1c410df4fd8f25c95
parent 8b083206
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ public final class ThreadedRenderer {
    void destroy() {
        mInitialized = false;
        updateEnabledState(null);
        nDestroy(mNativeProxy);
        nDestroy(mNativeProxy, mRootNode.mNativeRenderNode);
    }

    /**
@@ -994,7 +994,7 @@ public final class ThreadedRenderer {
            float lightX, float lightY, float lightZ);
    private static native void nSetOpaque(long nativeProxy, boolean opaque);
    private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size);
    private static native void nDestroy(long nativeProxy);
    private static native void nDestroy(long nativeProxy, long rootRenderNode);
    private static native void nRegisterAnimatingRenderNode(long rootRenderNode, long animatingNode);

    private static native void nInvokeFunctor(long functor, boolean waitForCompletion);
+11 −2
Original line number Diff line number Diff line
@@ -164,6 +164,13 @@ public:
        mPendingAnimatingRenderNodes.clear();
    }

    void destroy() {
        for (auto& renderNode : mPendingAnimatingRenderNodes) {
            renderNode->animators().endAllStagingAnimators();
        }
        mPendingAnimatingRenderNodes.clear();
    }

private:
    sp<Looper> mLooper;
    JavaVM* mVm;
@@ -476,7 +483,9 @@ static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject c
}

static void android_view_ThreadedRenderer_destroy(JNIEnv* env, jobject clazz,
        jlong proxyPtr) {
        jlong proxyPtr, jlong rootNodePtr) {
    RootRenderNode* rootRenderNode = reinterpret_cast<RootRenderNode*>(rootNodePtr);
    rootRenderNode->destroy();
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->destroy();
}
@@ -698,7 +707,7 @@ static const JNINativeMethod gMethods[] = {
    { "nSetLightCenter", "(JFFF)V", (void*) android_view_ThreadedRenderer_setLightCenter },
    { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
    { "nSyncAndDrawFrame", "(J[JI)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
    { "nDestroy", "(J)V", (void*) android_view_ThreadedRenderer_destroy },
    { "nDestroy", "(JJ)V", (void*) android_view_ThreadedRenderer_destroy },
    { "nRegisterAnimatingRenderNode", "(JJ)V", (void*) android_view_ThreadedRenderer_registerAnimatingRenderNode },
    { "nInvokeFunctor", "(JZ)V", (void*) android_view_ThreadedRenderer_invokeFunctor },
    { "nCreateTextureLayer", "(J)J", (void*) android_view_ThreadedRenderer_createTextureLayer },