Chromium Code Reviews| 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 |