[TTVD] Prevent overlay promotion for released decoder collections 02/317002/4
authorJakub Gajownik <j.gajownik2@samsung.com>
Wed, 28 Aug 2024 12:54:23 +0000 (14:54 +0200)
committerBot Blink <blinkbot@samsung.com>
Mon, 2 Sep 2024 10:04:26 +0000 (10:04 +0000)
When video decoder is released after widget suspension,
it's not longer possible to render previously returned
video frames using overlay system (as it requires alive
decoder). However, there was no mechanism to detect such
scenarios and prevent propoting related quads.

As we already have possibility to communicate with output
surface manager, we can notify about collection liveness.
After such change, pre-suspension video frames are no longer
promoted to overlay.

Bug: https://jira-eu.sec.samsung.net/browse/VDGAME-558
Change-Id: I6d0ace65b44c0ae1f0ffd26a6ce8ab54439499ee
Signed-off-by: Jakub Gajownik <j.gajownik2@samsung.com>
media/filters/tizen/ttvd_video_decoder_impl.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/output_surface_manager.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/output_surface_manager.h

index 3a294cf2d0f046ca4ce232af60185bb9342cfc8b..34e1f0f2b73eb14f3d8d0d0f991d1e0ec418ed2b 100644 (file)
@@ -156,9 +156,7 @@ TTvdVideoDecoderImpl::~TTvdVideoDecoderImpl() {
     event.Signal();
   }
 
-  output_surface_manager_->NotifySurfaceRelease(
-      collection_token_,
-      ui::OutputSurfaceManager::SurfaceReleaseType::kPermanent);
+  output_surface_manager_->NotifyCollectionRelease(collection_token_);
   HideOutputIfNeeded();
   event.Wait();
 
@@ -807,9 +805,7 @@ void TTvdVideoDecoderImpl::ResourceConflict(
   // Notify manager that we will no longer use output surface. It might be
   // needed by new decoded for preparing. It's important to do before resource
   // is released to ensure new client might safely reuse same scaler.
-  output_surface_manager_->NotifySurfaceRelease(
-      collection_token_,
-      ui::OutputSurfaceManager::SurfaceReleaseType::kTemporary);
+  output_surface_manager_->NotifyCollectionRelease(collection_token_);
 
   std::move(token_provider).Run(std::move(allocated_decoder_));
 
@@ -903,7 +899,7 @@ void TTvdVideoDecoderImpl::Resume() {
   decoder_state_ = DecoderState::kLazyInitializeProcess;
   // Notify this collection is renderable, because it could be blocked by
   // resource conflict before suspending this process.
-  output_surface_manager_->ClearSurfaceReleaseNotification(collection_token_);
+  output_surface_manager_->NotifyCollectionCreate(collection_token_);
   InitializeInternal();
 }
 
index 988c29367fbd0410427082c9ced07eee92e7e813..0ce4a1d56405c4821ba410571e1fc972a7405036 100644 (file)
@@ -64,7 +64,7 @@ OutputSurfaceManager::AssignSurfaces(
   // Step 1: remove all the surfaces that where already released, but player
   //         still holds video frames and tries to render them.
   for (auto it = candidates.begin(); it != candidates.end();) {
-    if (released_collections_.find(it->second) == released_collections_.end()) {
+    if (alive_collections_.find(it->second) != alive_collections_.end()) {
       ++it;
     } else {
       TIZEN_MEDIA_LOG(VERBOSE)
@@ -144,6 +144,7 @@ OutputSurfaceManager::PrepareNewSurface(
     base::UnguessableToken collection_token,
     base::RepeatingCallback<void(bool)> surface_ready_cb) {
   base::AutoLock auto_lock(lock_);
+  alive_collections_.insert(collection_token);
 
   // TODO(vdwasm) We should destinguish newly created process from the suspended
   //              one. It's highly propable that new process will be set
@@ -233,16 +234,10 @@ OutputSurfaceManager::PrepareNewSurface(
                              surface_ready_cb);
 }
 
-void OutputSurfaceManager::NotifySurfaceRelease(
-    base::UnguessableToken token,
-    SurfaceReleaseType release_type) {
+void OutputSurfaceManager::NotifyCollectionRelease(
+    base::UnguessableToken token) {
   base::AutoLock auto_lock(lock_);
-
-  if (release_type == SurfaceReleaseType::kPermanent) {
-    released_collections_.erase(token);
-  } else {
-    released_collections_.insert(token);
-  }
+  alive_collections_.erase(token);
 
   auto it = std::find_if(scalers_.begin(), scalers_.end(),
                          [&token](const OutputSurfaceState& scaler) {
@@ -266,10 +261,10 @@ void OutputSurfaceManager::NotifySurfaceRelease(
                        compositor_task_runner_);
 }
 
-void OutputSurfaceManager::ClearSurfaceReleaseNotification(
+void OutputSurfaceManager::NotifyCollectionCreate(
     base::UnguessableToken collection_token) {
   base::AutoLock auto_lock(lock_);
-  released_collections_.erase(collection_token);
+  alive_collections_.insert(collection_token);
 }
 
 size_t OutputSurfaceManager::NumAllocated() const {
index 45d210ab06ba52726774156dd054f5259e1a7785..21ebba4a92832597b7647f46d3f80359c19375d6 100644 (file)
@@ -54,23 +54,13 @@ class OutputSurfaceManager
       base::UnguessableToken,
       base::RepeatingCallback<void(bool)> surface_ready_cb);
 
-  enum class SurfaceReleaseType {
-    // Notification is temporary, is likely to reflect the resource conflict
-    // of video decoder. It might be reverted (e.g after suspend&resume cycle)
-    // using |ClearSurfaceReleaseNotification|.
-    kTemporary,
-    // Surface is about to be released by client permanently. Should be used
-    // when it's certain that collection won't try to render anything more
-    // (like decoder release).
-    kPermanent,
-  };
-
   // Should be called to notify manager that collection identified by provided
   // token will no longer use output surface, so it might be reused by other
   // clients.
-  void NotifySurfaceRelease(base::UnguessableToken collection_token,
-                            SurfaceReleaseType release_type);
-  void ClearSurfaceReleaseNotification(base::UnguessableToken collection_token);
+  void NotifyCollectionRelease(base::UnguessableToken collection_token);
+  // Similar to above method, it brings collection back, so it be used for
+  // rendering some video frame.
+  void NotifyCollectionCreate(base::UnguessableToken collection_token);
 
   // suspend_resume::SuspendResumeClient implementation.
   void OnStateChange(suspend_resume::State new_state) override;
@@ -79,7 +69,7 @@ class OutputSurfaceManager
   base::Lock lock_;
   std::array<OutputSurfaceState, 4> scalers_ GUARDED_BY(lock_);
   bool suspended_ GUARDED_BY(lock_) = true;
-  std::set<base::UnguessableToken> released_collections_ GUARDED_BY(lock_);
+  std::set<base::UnguessableToken> alive_collections_ GUARDED_BY(lock_);
 
   size_t NumAllocated() const EXCLUSIVE_LOCKS_REQUIRED(lock_);
   size_t AcquireAndReturnAvailableSurfaces(size_t overlays_wanted)