[desktopCapture] add some logs into trace event

While investigating some screen-capture-track-end-in-meeting issues, the
relevant rtc error logs are not uploaded to server as other webrtc
modules do, which cause great hardness to identify the reason.
This cl is to use existing trace event methods to store error logs of
desktop capturers.

Bug: chromium:831756
Change-Id: Id0c1b439f9b63916fb9417cf4e6f2b8f3c556fcd
Reviewed-on: https://webrtc-review.googlesource.com/69783
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Commit-Queue: Brave Yao <braveyao@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22866}
This commit is contained in:
braveyao
2018-04-12 17:40:45 -07:00
committed by Commit Bot
parent c4384ea138
commit c6416fbe16
9 changed files with 52 additions and 6 deletions

View File

@ -13,6 +13,7 @@
#include "modules/desktop_capture/win/screen_capture_utils.h"
#include "modules/desktop_capture/win/window_capture_utils.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
#include "rtc_base/win32.h"
namespace webrtc {
@ -244,6 +245,8 @@ bool CroppingWindowCapturerWin::ShouldUseScreenCapturer() {
}
DesktopRect CroppingWindowCapturerWin::GetWindowRectInVirtualScreen() {
TRACE_EVENT0("webrtc",
"CroppingWindowCapturerWin::GetWindowRectInVirtualScreen");
DesktopRect window_rect;
HWND hwnd = reinterpret_cast<HWND>(selected_window());
if (!GetCroppedWindowRect(hwnd, &window_rect, /* original_rect */ nullptr)) {

View File

@ -12,6 +12,7 @@
#include "modules/desktop_capture/mac/desktop_configuration.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/event_wrapper.h"
namespace webrtc {
@ -65,6 +66,11 @@ void DesktopConfigurationMonitor::DisplaysReconfiguredCallback(
void DesktopConfigurationMonitor::DisplaysReconfigured(
CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags) {
TRACE_EVENT0("webrtc", "DesktopConfigurationMonitor::DisplaysReconfigured");
RTC_LOG(LS_INFO) << "DisplaysReconfigured: "
<< "DisplayID " << display << "; ChangeSummaryFlags "
<< flags;
if (flags & kCGDisplayBeginConfigurationFlag) {
if (reconfiguring_displays_.empty()) {
// If this is the first display to start reconfiguring then wait on

View File

@ -17,6 +17,7 @@
#include "rtc_base/constructormagic.h"
#include "rtc_base/logging.h"
#include "rtc_base/timeutils.h"
#include "rtc_base/trace_event.h"
#include "sdk/objc/Framework/Classes/Common/scoped_cftyperef.h"
namespace webrtc {
@ -232,10 +233,13 @@ ScreenCapturerMac::~ScreenCapturerMac() {
}
bool ScreenCapturerMac::Init() {
TRACE_EVENT0("webrtc", "ScreenCapturerMac::Init");
desktop_config_monitor_->Lock();
desktop_config_ = desktop_config_monitor_->desktop_configuration();
desktop_config_monitor_->Unlock();
if (!RegisterRefreshAndMoveHandlers()) {
RTC_LOG(LS_ERROR) << "Failed to register refresh and move handlers.";
return false;
}
ScreenConfigurationChanged();
@ -252,11 +256,14 @@ void ScreenCapturerMac::ReleaseBuffers() {
void ScreenCapturerMac::Start(Callback* callback) {
RTC_DCHECK(!callback_);
RTC_DCHECK(callback);
TRACE_EVENT_INSTANT1(
"webrtc", "ScreenCapturermac::Start", "target display id ", current_display_);
callback_ = callback;
}
void ScreenCapturerMac::CaptureFrame() {
TRACE_EVENT0("webrtc", "creenCapturerMac::CaptureFrame");
int64_t capture_start_time_nanos = rtc::TimeNanos();
queue_.MoveToNextFrame();

View File

@ -30,6 +30,7 @@
#include "rtc_base/constructormagic.h"
#include "rtc_base/logging.h"
#include "rtc_base/timeutils.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
@ -134,6 +135,7 @@ ScreenCapturerLinux::~ScreenCapturerLinux() {
}
bool ScreenCapturerLinux::Init(const DesktopCaptureOptions& options) {
TRACE_EVENT0("webrtc", "ScreenCapturerLinux::Init");
options_ = options;
root_window_ = RootWindow(display(), DefaultScreen(display()));
@ -225,6 +227,7 @@ void ScreenCapturerLinux::Start(Callback* callback) {
}
void ScreenCapturerLinux::CaptureFrame() {
TRACE_EVENT0("webrtc", "ScreenCapturerLinux::CaptureFrame");
int64_t capture_start_time_nanos = rtc::TimeNanos();
queue_.MoveToNextFrame();
@ -238,6 +241,7 @@ void ScreenCapturerLinux::CaptureFrame() {
// in a good shape.
if (!x_server_pixel_buffer_.is_initialized()) {
// We failed to initialize pixel buffer.
RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@ -253,6 +257,7 @@ void ScreenCapturerLinux::CaptureFrame() {
std::unique_ptr<DesktopFrame> result = CaptureScreen();
if (!result) {
RTC_LOG(LS_WARNING) << "Temporarily failed to capture screen.";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}
@ -349,6 +354,7 @@ std::unique_ptr<DesktopFrame> ScreenCapturerLinux::CaptureScreen() {
}
void ScreenCapturerLinux::ScreenConfigurationChanged() {
TRACE_EVENT0("webrtc", "ScreenCapturerLinux::ScreenConfigurationChanged");
// Make sure the frame buffers will be reallocated.
queue_.Reset();

View File

@ -21,6 +21,7 @@
#include "rtc_base/logging.h"
#include "rtc_base/ptr_util.h"
#include "rtc_base/timeutils.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
@ -117,6 +118,7 @@ void ScreenCapturerWinDirectx::SetSharedMemoryFactory(
void ScreenCapturerWinDirectx::CaptureFrame() {
RTC_DCHECK(callback_);
TRACE_EVENT0("webrtc", "ScreenCapturerWinDirectx::CaptureFrame");
int64_t capture_start_time_nanos = rtc::TimeNanos();

View File

@ -23,6 +23,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/timeutils.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
@ -70,6 +71,7 @@ void ScreenCapturerWinGdi::SetSharedMemoryFactory(
}
void ScreenCapturerWinGdi::CaptureFrame() {
TRACE_EVENT0("webrtc", "ScreenCapturerWinGdi::CaptureFrame");
int64_t capture_start_time_nanos = rtc::TimeNanos();
queue_.MoveToNextFrame();
@ -79,6 +81,7 @@ void ScreenCapturerWinGdi::CaptureFrame() {
PrepareCaptureResources();
if (!CaptureImage()) {
RTC_LOG(WARNING) << "Failed to capture screen by GDI.";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}
@ -177,8 +180,10 @@ void ScreenCapturerWinGdi::PrepareCaptureResources() {
bool ScreenCapturerWinGdi::CaptureImage() {
DesktopRect screen_rect =
GetScreenRect(current_screen_id_, current_device_key_);
if (screen_rect.is_empty())
if (screen_rect.is_empty()) {
RTC_LOG(LS_WARNING) << "Failed to get screen rect.";
return false;
}
DesktopSize size = screen_rect.size();
// If the current buffer is from an older generation then allocate a new one.
@ -191,8 +196,10 @@ bool ScreenCapturerWinGdi::CaptureImage() {
std::unique_ptr<DesktopFrame> buffer = DesktopFrameWin::Create(
size, shared_memory_factory_.get(), desktop_dc_);
if (!buffer)
if (!buffer) {
RTC_LOG(LS_WARNING) << "Failed to create frame buffer.";
return false;
}
queue_.ReplaceCurrentFrame(SharedDesktopFrame::Wrap(std::move(buffer)));
}
queue_.current_frame()->set_top_left(
@ -204,6 +211,7 @@ bool ScreenCapturerWinGdi::CaptureImage() {
queue_.current_frame()->GetUnderlyingFrame());
HGDIOBJ previous_object = SelectObject(memory_dc_, current->bitmap());
if (!previous_object || previous_object == HGDI_ERROR) {
RTC_LOG(LS_WARNING) << "Failed to select current bitmap into memery dc.";
return false;
}

View File

@ -18,15 +18,16 @@
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/window_finder_mac.h"
#include "modules/desktop_capture/mac/desktop_configuration.h"
#include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
#include "modules/desktop_capture/mac/full_screen_chrome_window_detector.h"
#include "modules/desktop_capture/mac/window_list_utils.h"
#include "modules/desktop_capture/window_finder_mac.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/logging.h"
#include "rtc_base/macutils.h"
#include "rtc_base/scoped_ref_ptr.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
@ -155,7 +156,10 @@ void WindowCapturerMac::Start(Callback* callback) {
}
void WindowCapturerMac::CaptureFrame() {
TRACE_EVENT0("webrtc", "WindowCapturerMac::CaptureFrame");
if (!IsWindowValid(window_id_)) {
RTC_LOG(LS_ERROR) << "The window is not valid any longer.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@ -174,6 +178,7 @@ void WindowCapturerMac::CaptureFrame() {
on_screen_window, kCGWindowImageBoundsIgnoreFraming);
if (!window_image) {
RTC_LOG(LS_WARNING) << "Temporarily failed to capture window.";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}

View File

@ -14,12 +14,13 @@
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame_win.h"
#include "modules/desktop_capture/window_finder_win.h"
#include "modules/desktop_capture/win/screen_capture_utils.h"
#include "modules/desktop_capture/win/window_capture_utils.h"
#include "modules/desktop_capture/window_finder_win.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
#include "rtc_base/win32.h"
namespace webrtc {
@ -208,6 +209,8 @@ void WindowCapturerWin::Start(Callback* callback) {
}
void WindowCapturerWin::CaptureFrame() {
TRACE_EVENT0("webrtc", "WindowCapturerWin::CaptureFrame");
if (!window_) {
RTC_LOG(LS_ERROR) << "Window hasn't been selected: " << GetLastError();
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
@ -216,6 +219,7 @@ void WindowCapturerWin::CaptureFrame() {
// Stop capturing if the window has been closed.
if (!IsWindow(window_)) {
RTC_LOG(LS_ERROR) << "target window has been closed";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@ -277,6 +281,7 @@ void WindowCapturerWin::CaptureFrame() {
std::unique_ptr<DesktopFrameWin> frame(
DesktopFrameWin::Create(cropped_rect.size(), nullptr, window_dc));
if (!frame.get()) {
RTC_LOG(LS_WARNING) << "Failed to create frame.";
ReleaseDC(window_, window_dc);
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;

View File

@ -28,6 +28,7 @@
#include "rtc_base/constructormagic.h"
#include "rtc_base/logging.h"
#include "rtc_base/scoped_ref_ptr.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
@ -181,8 +182,10 @@ void WindowCapturerLinux::Start(Callback* callback) {
}
void WindowCapturerLinux::CaptureFrame() {
TRACE_EVENT0("webrtc", "WindowCapturerLinux::CaptureFrame");
if (!x_server_pixel_buffer_.IsWindowValid()) {
RTC_LOG(LS_INFO) << "The window is no longer valid.";
RTC_LOG(LS_ERROR) << "The window is no longer valid.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@ -193,7 +196,7 @@ void WindowCapturerLinux::CaptureFrame() {
// Without the Xcomposite extension we capture when the whole window is
// visible on screen and not covered by any other window. This is not
// something we want so instead, just bail out.
RTC_LOG(LS_INFO) << "No Xcomposite extension detected.";
RTC_LOG(LS_ERROR) << "No Xcomposite extension detected.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@ -212,6 +215,7 @@ void WindowCapturerLinux::CaptureFrame() {
x_server_pixel_buffer_.Synchronize();
if (!x_server_pixel_buffer_.CaptureRect(DesktopRect::MakeSize(frame->size()),
frame.get())) {
RTC_LOG(LS_WARNING) << "Temporarily failed to capture winodw.";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}