make sure mSurfaceLock.unlock can be executed in unlockCanvasAndPost

When the program is run to unlockCanvasAndPost method,
if mSurface.unlockCanvasAndPost throws an exception,
the mSurfaceLock.unlock() will not getting the chance to execute.

If an app executes unlockCanvasAndPost in a catch and does not handle the exception,
it will remain locked for a long time after the next execution of mSurfacelock.lock.

make sure the msurfacelock.unlock is executed after unlockCanvasAndPost

bug:245050059 in partnerissuetracker

Change-Id: Ib849c840c61ac261cfaab0daefa7ae2afdbfcba3
Signed-off-by: xiaoxin <xiaoxin@xiaomi.corp-partner.google.com>
This commit is contained in:
xiaoxin 2022-09-05 16:21:06 +08:00 committed by xiao xin
parent 10d1ebad5c
commit 71e3abfa1e

View File

@ -1626,8 +1626,11 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
*/
@Override
public void unlockCanvasAndPost(Canvas canvas) {
mSurface.unlockCanvasAndPost(canvas);
mSurfaceLock.unlock();
try {
mSurface.unlockCanvasAndPost(canvas);
} finally {
mSurfaceLock.unlock();
}
}
@Override