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

Commit 15561b08 authored by Pat Plunkett's avatar Pat Plunkett
Browse files

Clear callbacks when destroying DvrHwcClient

When a DvrHwcClient is destroyed, the VrComposer retains a reference to its
observer. Because registerObserver returns a non-OK status if an observer
is already registered, this was causing subsequent DvrHwcClients to not be
created.

This was an issue with the CompatibilityUiOverlay app on standalone
headsets. CompatibilityUiOverlay was destroying its DvrHwcClient when turning
the screen off, but upon turning the screen back on, CompatibilityUiOverlay
was unable to create another DvrHwcClient.

Bug: 63139142
Test: Turn the screen off/on for a standalone headset, observe
CompatibilityUiOverlay running.

Change-Id: Ie45e961d2bf977ab9a661e23c558354d3a96ae20
parent a36bf926
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -100,10 +100,13 @@ DvrHwcClient* dvrHwcClientCreate(DvrHwcOnFrameCallback callback, void* data) {
}

void dvrHwcClientDestroy(DvrHwcClient* client) {
  client->composer->clearObserver();

  // NOTE: Deleting DvrHwcClient* isn't enough since DvrHwcClient::callback is a
  // shared pointer that could be referenced from a binder thread. But the
  // client callback isn't valid past this calls so that needs to be reset.
  client->callback->Shutdown();

  delete client;
}

+5 −0
Original line number Diff line number Diff line
@@ -17,4 +17,9 @@ interface IVrComposer
   * Registers a callback used to receive frame notifications.
   */
  void registerObserver(in IVrComposerCallback callback);

  /**
   * Clears a previously registered frame notification callback.
   */
  void clearObserver();
}
+6 −0
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ binder::Status VrComposer::registerObserver(
  return binder::Status::ok();
}

binder::Status VrComposer::clearObserver() {
  std::lock_guard<std::mutex> guard(mutex_);
  callback_ = nullptr;
  return binder::Status::ok();
}

base::unique_fd VrComposer::OnNewFrame(const ComposerView::Frame& frame) {
  std::lock_guard<std::mutex> guard(mutex_);

+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ class VrComposer
  binder::Status registerObserver(
      const sp<IVrComposerCallback>& callback) override;

  binder::Status clearObserver() override;

  // ComposerView::Observer:
  base::unique_fd OnNewFrame(const ComposerView::Frame& frame) override;