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

Commit eb30074f authored by Kean Mariotti's avatar Kean Mariotti
Browse files

Revert "viewcapture: guarantee happens-before relationship"

This reverts commit 762ac978.

Turns out the issue was concurrent onDraw calls from multiple
UI threads instead. Mitigation in follow up CL.

Bug: 375005884
Flag: EXEMPT minor revert
Test: n/a
Change-Id: Ida113470ddfb27bce7f41ec9e6614a254ff9ca1c
parent 8bc864a4
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -311,12 +311,8 @@ public abstract class ViewCapture {
            captureViewTree(mRoot, mViewPropertyRef);
            ViewPropertyRef captured = mViewPropertyRef.next;
            if (captured != null) {
                captured.callback = mCaptureCallback;
                captured.elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();

                // Main thread writes volatile field:
                // guarantee that variable changes prior the field write are visible to bg thread
                captured.volatileCallback = mCaptureCallback;

                mBgExecutor.execute(captured);
            }
            mIsFirstFrame = false;
@@ -556,11 +552,9 @@ public abstract class ViewCapture {

        public ViewPropertyRef next;

        public Consumer<ViewPropertyRef> callback = null;
        public long elapsedRealtimeNanos = 0;

        // Volatile field to establish happens-before relationship between main and bg threads
        // (see JSR-133: Java Memory Model and Thread Specification)
        public volatile Consumer<ViewPropertyRef> volatileCallback = null;

        public void transferFrom(View in) {
            view = in;
@@ -657,10 +651,8 @@ public abstract class ViewCapture {

        @Override
        public void run() {
            // Bg thread reads volatile field:
            // guarantee that variable changes in main thread prior the field write are visible
            Consumer<ViewPropertyRef> oldCallback = volatileCallback;
            volatileCallback = null;
            Consumer<ViewPropertyRef> oldCallback = callback;
            callback = null;
            if (oldCallback != null) {
                oldCallback.accept(this);
            }