[WEBRTC] Fix messenger app preview fail issue 72/293672/4
authorxliang.wu <xliang.wu@samsung.com>
Mon, 16 May 2022 08:36:05 +0000 (04:36 -0400)
committerBot Blink <blinkbot@samsung.com>
Thu, 8 Jun 2023 08:45:24 +0000 (08:45 +0000)
There are many RenderFrameImpl show and hidden.
(RenderFrameImpl count is not definitely and show/hidden sequence is not definitely)
different RenderFrameImpl use the same WebVideoCaptureImplManager.
when RenderFrameImpl::WasHidden/WasShown was called, it trigger WebVideoCaptureImplManager::SuspendDevices.

the init value of is_suspending_all_ = false.
before device connect, some RenderFrameImpl WasHidden was called.
when device connect and video element created,is_suspending_all_ = true and don't trigger startpreview.
So we should keep the initial state if video element not created and device not connected yet.

Change-Id: I96e85a96ef27d9c4985372bad737f10c26169208
Signed-off-by: xliang.wu <xliang.wu@samsung.com>
third_party/blink/renderer/platform/exported/video_capture/web_video_capture_impl_manager.cc

index 949cb95f71913b6dcfdd0fd715cad1f98b14ae01..49a22fc56b12cff2e164fbe006a3a64040ca50f9 100644 (file)
@@ -293,6 +293,12 @@ void WebVideoCaptureImplManager::SuspendDevices(
   DCHECK(render_main_task_runner_->BelongsToCurrentThread());
   if (is_suspending_all_ == suspend)
     return;
+
+  if (video_devices.empty()) {
+    LOG(ERROR) << "no device yet";
+    return;
+  }
+
   is_suspending_all_ = suspend;
   for (const MediaStreamDevice& device : video_devices) {
     const media::VideoCaptureSessionId id = device.session_id();