Skip to content

Commit

Permalink
[Remoting Android] Fix Painting After Rotation Bug
Browse files Browse the repository at this point in the history
Previous CL 2132883002 removed the attachRedrawCallback() call in
Desktop.onStart() since it will be called in DesktopView.surfaceChanged().
This introduces a bug that if requestRepaint() is called before
surfaceChanged(), then mRepaintPending will be set to true and
mDisplay.redrawGraphics() will do nothing. paint() will not be called since
the redraw callback is not set, and mRepaintPending will not be set back to
false, making it skip all future render requests until paint() is triggered
by JniVideoRenderer in C++.

This CL fixes this problem by moving attachRedrawCallback() to the ctor
of DesktopView. paint() already has checks to prevent rendering happens if
the DesktopView is not ready yet.

BUG=627191

Review-Url: https://codereview.chromium.org/2136233002
Cr-Commit-Position: refs/heads/master@{#404732}
  • Loading branch information
ywh233 authored and Commit bot committed Jul 11, 2016
1 parent 932a937 commit 856d9fb
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public DesktopView(Context context, Display display) {
mRepaintPending = false;

getHolder().addCallback(this);

attachRedrawCallback();
}

@Override
Expand Down Expand Up @@ -140,6 +142,9 @@ public void paint() {
}

Bitmap image = mDisplay.getVideoFrame();
synchronized (mRenderData) {
mRepaintPending = false;
}
if (image == null) {
// This can happen if the client is connected, but a complete video frame has not yet
// been decoded.
Expand Down Expand Up @@ -167,7 +172,6 @@ public void paint() {
Point cursorPosition;
boolean drawCursor;
synchronized (mRenderData) {
mRepaintPending = false;
// Don't try to lock the canvas before it is ready, as the implementation of
// lockCanvas() may throttle these calls to a slow rate in order to avoid consuming CPU.
// Note that a successful call to lockCanvas() will prevent the framework from
Expand Down Expand Up @@ -240,7 +244,6 @@ public void surfaceChanged(SurfaceHolder holder, int format, int width, int heig
mRenderData.screenHeight = height;
}

attachRedrawCallback();
mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height));
requestRepaint();
}
Expand Down

0 comments on commit 856d9fb

Please sign in to comment.