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

Commit 7db39980 authored by Rachel Lee's avatar Rachel Lee
Browse files

Use ScopedLocalRef in DisplayEventReceiver JNI

Fix forward for memory regression.

Bug: 272536386
Test: ABTD run with ATP from bug and check metric
Change-Id: I15b597694a86a3d61e77bfef0c2c95e71207c23e
parent 3d2226d2
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -169,21 +169,25 @@ void NativeDisplayEventReceiver::dispatchVsync(nsecs_t timestamp, PhysicalDispla
                          gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.frameInterval,
                          vsyncEventData.frameInterval);

        jobjectArray frameTimelinesObj = reinterpret_cast<jobjectArray>(
        ScopedLocalRef<jobjectArray>
                frameTimelinesObj(env,
                                  reinterpret_cast<jobjectArray>(
                                          env->GetObjectField(vsyncEventDataObj.get(),
                                    gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo
                                            .frameTimelines));
                                                              gDisplayEventReceiverClassInfo
                                                                      .vsyncEventDataClassInfo
                                                                      .frameTimelines)));
        for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
            VsyncEventData::FrameTimeline& frameTimeline = vsyncEventData.frameTimelines[i];
            jobject frameTimelineObj = env->GetObjectArrayElement(frameTimelinesObj, i);
            env->SetLongField(frameTimelineObj,
            ScopedLocalRef<jobject>
                    frameTimelineObj(env, env->GetObjectArrayElement(frameTimelinesObj.get(), i));
            env->SetLongField(frameTimelineObj.get(),
                              gDisplayEventReceiverClassInfo.frameTimelineClassInfo.vsyncId,
                              frameTimeline.vsyncId);
            env->SetLongField(frameTimelineObj,
            env->SetLongField(frameTimelineObj.get(),
                              gDisplayEventReceiverClassInfo.frameTimelineClassInfo
                                      .expectedPresentationTime,
                              frameTimeline.expectedPresentationTime);
            env->SetLongField(frameTimelineObj,
            env->SetLongField(frameTimelineObj.get(),
                              gDisplayEventReceiverClassInfo.frameTimelineClassInfo.deadline,
                              frameTimeline.deadlineTimestamp);
        }