Skip to content

Commit fe00528

Browse files
committed
fix UI freezes
In some situations SF would mark a window as "has a pending update" but would never process that update because the window is not visible (fully transparent, hidden by another window, etc...), this window would then be "stuck" until some other window updated. Change-Id: Ifa18a9aef3a53f2593b473556702688ae62d9503
1 parent cea2c39 commit fe00528

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what)
419419
// post surfaces (if needed)
420420
handlePageFlip();
421421

422-
if (!mDirtyRegion.isEmpty()) {
423-
signalRefresh();
424-
}
422+
signalRefresh();
425423
} break;
426424

427425
case MessageQueue::REFRESH: {
@@ -430,33 +428,32 @@ void SurfaceFlinger::onMessageReceived(int32_t what)
430428
const DisplayHardware& hw(graphicPlane(0).displayHardware());
431429
handleRefresh();
432430

433-
if (!mDirtyRegion.isEmpty()) {
434-
if (CC_UNLIKELY(mHwWorkListDirty)) {
435-
// build the h/w work list
436-
handleWorkList();
437-
}
438-
if (CC_LIKELY(hw.canDraw())) {
439-
// repaint the framebuffer (if needed)
440-
handleRepaint();
441-
// inform the h/w that we're done compositing
442-
hw.compositionComplete();
443-
postFramebuffer();
444-
} else {
445-
// pretend we did the post
446-
hw.compositionComplete();
447-
}
431+
if (CC_UNLIKELY(mHwWorkListDirty)) {
432+
// build the h/w work list
433+
handleWorkList();
434+
}
435+
if (CC_LIKELY(hw.canDraw())) {
436+
// repaint the framebuffer (if needed)
437+
handleRepaint();
438+
// inform the h/w that we're done compositing
439+
hw.compositionComplete();
440+
postFramebuffer();
448441
} else {
442+
// pretend we did the post
449443
hw.compositionComplete();
450444
}
445+
451446
} break;
452447
}
453448
}
454449

455450
void SurfaceFlinger::postFramebuffer()
456451
{
457-
// this should never happen. we do the flip anyways so we don't
458-
// risk to cause a deadlock with hwc
459-
ALOGW_IF(mSwapRegion.isEmpty(), "mSwapRegion is empty");
452+
// mSwapRegion can be empty here is some cases, for instance if a hidden
453+
// or fully transparent window is updating.
454+
// in that case, we need to flip anyways to not risk a deadlock with
455+
// h/w composer.
456+
460457
const DisplayHardware& hw(graphicPlane(0).displayHardware());
461458
const nsecs_t now = systemTime();
462459
mDebugInSwapBuffers = now;

0 commit comments

Comments
 (0)