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

Commit 46684841 authored by John Bates's avatar John Bates Committed by Jiwen Cai
Browse files

Remove spurious composer validate call to avoid hang

Presumably during Doff transitions as the hardware composer post
thread was being interrupted, there was an edge case when
a validate command could be posted without following up with
present. That could lead to create/delete layer calls between
validate and present which are not supported by some HWC
implementations.

Bug: 70178957

Test: manually verified that create layer will fail if done
 between validate and present.

Change-Id: If8db231223b23370eb4ca5ae76ced1c9d88b473d
(cherry picked from commit e3117ed7d2c99afa6488bdbbba600030e4415d64)
parent 3f7cc71c
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -457,13 +457,6 @@ void HardwareComposer::PostLayers() {
    layer.Prepare();
  }

  HWC::Error error = Validate(composer_callback_->GetDisplayId());
  if (error != HWC::Error::None) {
    ALOGE("HardwareComposer::PostLayers: Validate failed: %s",
          error.to_string().c_str());
    return;
  }

  // Now that we have taken in a frame from the application, we have a chance
  // to drop the frame before passing the frame along to HWC.
  // If the display driver has become backed up, we detect it here and then
@@ -504,6 +497,13 @@ void HardwareComposer::PostLayers() {
  }
#endif

  HWC::Error error = Validate(composer_callback_->GetDisplayId());
  if (error != HWC::Error::None) {
    ALOGE("HardwareComposer::PostLayers: Validate failed: %s",
          error.to_string().c_str());
    return;
  }

  error = Present(composer_callback_->GetDisplayId());
  if (error != HWC::Error::None) {
    ALOGE("HardwareComposer::PostLayers: Present failed: %s",
@@ -862,17 +862,13 @@ void HardwareComposer::PostThread() {
      ATRACE_INT64("sleep_time_ns", sleep_time_ns);
      if (sleep_time_ns > 0) {
        int error = SleepUntil(wakeup_time_ns);
        ALOGE_IF(error < 0, "HardwareComposer::PostThread: Failed to sleep: %s",
        ALOGE_IF(error < 0 && error != kPostThreadInterrupted,
                 "HardwareComposer::PostThread: Failed to sleep: %s",
                 strerror(-error));
        if (error == kPostThreadInterrupted) {
          if (layer_config_changed) {
            // If the layer config changed we need to validateDisplay() even if
            // we're going to drop the frame, to flush the Composer object's
            // internal command buffer and apply our layer changes.
            Validate(composer_callback_->GetDisplayId());
          }
          continue;
        }
        // If the sleep was interrupted (error == kPostThreadInterrupted),
        // we still go through and present this frame because we may have set
        // layers earlier and we want to flush the Composer's internal command
        // buffer by continuing through to validate and present.
      }
    }