Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: content/browser/media/android/browser_surface_view_manager.cc

Issue 1878103002: Plumb a Browser->GPU surface destruction message for Android VDAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing ifdefs Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/media/android/browser_surface_view_manager.cc
diff --git a/content/browser/media/android/browser_surface_view_manager.cc b/content/browser/media/android/browser_surface_view_manager.cc
index f171a169944d43b7795529da71801c50b004b694..75fe7f888d1ccafbd1c2648a55ff0bd903102403 100644
--- a/content/browser/media/android/browser_surface_view_manager.cc
+++ b/content/browser/media/android/browser_surface_view_manager.cc
@@ -4,8 +4,10 @@
#include "content/browser/media/android/browser_surface_view_manager.h"
+#include "base/android/build_info.h"
#include "content/browser/android/child_process_launcher_android.h"
#include "content/browser/android/content_view_core_impl.h"
+#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/media/surface_view_manager_messages_android.h"
@@ -28,6 +30,10 @@ void BrowserSurfaceViewManager::SetVideoSurface(
DCHECK_NE(surface_id_, media::SurfaceManager::kNoSurfaceID);
GpuSurfaceTracker::Get()->RemoveSurface(surface_id_);
UnregisterViewSurface(surface_id_);
+ // Only send the surface destruction message on JB, where not doing it can
+ // cause crashes.
+ if (base::android::BuildInfo::GetInstance()->sdk_int() < 18)
+ SendDestroyingVideoSurface(surface_id_);
surface_id_ = media::SurfaceManager::kNoSurfaceID;
} else {
// We mainly use the surface tracker to allocate a surface id for us. The
@@ -83,4 +89,18 @@ bool BrowserSurfaceViewManager::SendSurfaceID(int surface_id) {
render_frame_host_->GetRoutingID(), surface_id));
}
+void BrowserSurfaceViewManager::SendDestroyingVideoSurface(int surface_id) {
+ TRACE_EVENT0("media",
+ "BrowserSurfaceViewManager::SendDestroyingVideoSurface");
+ // XXX: How do we loop over all instances?
no sievers 2016/04/19 23:30:17 Can you move the thread bouncing code from GpuProc
watk 2016/04/22 02:48:55 Done. This is much better
+ GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
+ base::WaitableEvent waiter(false, false);
+ // Unretained is okay because we're waiting on the callback below.
+ shim->DestroyingVideoSurface(
+ surface_id,
+ base::Bind(&base::WaitableEvent::Signal, base::Unretained(&waiter)));
+ base::ThreadRestrictions::ScopedAllowWait allow_wait;
+ waiter.Wait();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698