OSDN Git Service

SurfaceView: Fix positioning issue when toggling visibility.
authorRobert Carr <racarr@google.com>
Tue, 20 Jun 2017 21:55:21 +0000 (14:55 -0700)
committerRobert Carr <racarr@google.com>
Tue, 20 Jun 2017 21:55:21 +0000 (14:55 -0700)
There is an issue (seemingly preexisting) with getPositionInWindow
after toggling view visibility. We see it when showing a view,
hiding it, and then showing it again. At this point we end up
with this call-stack:
   SurfaceView#setVisibility->SurfaceView#updateSurface
   ->View#getPositionInWindow
and getPositionInWindow fills in the wrong values. This newly discovered
bug is tracked as 62839113.

In a second bug, introduced in the SurfaceView refactoring,
we are not appropriately clearing the last RenderThread reported
position when toggling visibility. This means that even after the
setVisibility call when getPositionInWindow begins returning
the correct values, we don't update the position. This CL fixes
that and fixes 62653411 as a result. However we still have a flicker
as we did in N as the initial position is wrong.

Test: Manual from bug, go/wm-smoke
Change-Id: I1037b8dfdb343f9ce8c8616eb9197c6d039ed133
Fixes: 62653411
Bug: 62839113

core/java/android/view/SurfaceView.java

index 34ceeb7..2da49c7 100644 (file)
@@ -838,6 +838,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
             Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
                     System.identityHashCode(this), frameNumber));
         }
+        mRTLastReportedPosition.setEmpty();
+
         if (mSurfaceControl == null) {
             return;
         }
@@ -858,7 +860,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
                     Log.e(TAG, "Exception configuring surface", ex);
                 }
             }
-            mRTLastReportedPosition.setEmpty();
         }
     }