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

Commit 06e2e9cf authored by Chris Craik's avatar Chris Craik
Browse files

Wait on frame work fences when frames are dropped

bug:30895941

Prevents a race where frame work could interleave between frames,
causing SurfaceView position updates to be delivered out of order.

Change-Id: I01e4cc557b69dcf33e877a0e16c0d115ec95e4cc
parent c6c45d22
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -633,6 +633,9 @@ void CanvasContext::prepareAndDraw(RenderNode* node) {
    prepareTree(info, frameInfo, systemTime(CLOCK_MONOTONIC), node);
    prepareTree(info, frameInfo, systemTime(CLOCK_MONOTONIC), node);
    if (info.out.canDrawThisFrame) {
    if (info.out.canDrawThisFrame) {
        draw();
        draw();
    } else {
        // wait on fences so tasks don't overlap next frame
        waitOnFences();
    }
    }
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -168,6 +168,8 @@ public:


    ANDROID_API int64_t getFrameNumber();
    ANDROID_API int64_t getFrameNumber();


    void waitOnFences();

private:
private:
    friend class RegisterFrameCallbackTask;
    friend class RegisterFrameCallbackTask;
    // TODO: Replace with something better for layer & other GL object
    // TODO: Replace with something better for layer & other GL object
@@ -178,8 +180,6 @@ private:


    void freePrefetchedLayers(TreeObserver* observer);
    void freePrefetchedLayers(TreeObserver* observer);


    void waitOnFences();

    bool isSwapChainStuffed();
    bool isSwapChainStuffed();


    EGLint mLastFrameWidth = 0;
    EGLint mLastFrameWidth = 0;
+3 −0
Original line number Original line Diff line number Diff line
@@ -104,6 +104,9 @@ void DrawFrameTask::run() {


    if (CC_LIKELY(canDrawThisFrame)) {
    if (CC_LIKELY(canDrawThisFrame)) {
        context->draw();
        context->draw();
    } else {
        // wait on fences so tasks don't overlap next frame
        context->waitOnFences();
    }
    }


    if (!canUnblockUiThread) {
    if (!canUnblockUiThread) {