Adding more detail to MessageQueue::Dispatch logging.

Every message will now be traced with the location from which it was
posted, including function name, file and line number.

This CL also writes a normal LOG message when the dispatch took more
than a certain amount of time (currently 50ms).

This logging should help us identify messages that are taking
longer than expected to be dispatched.

R=pthatcher@webrtc.org, tommi@webrtc.org

Review URL: https://codereview.webrtc.org/2019423006 .

Cr-Commit-Position: refs/heads/master@{#13104}
This commit is contained in:
Taylor Brandstetter
2016-06-10 14:17:27 -07:00
parent 51e60305e6
commit 5d97a9a05b
90 changed files with 766 additions and 487 deletions

View File

@ -307,6 +307,7 @@ int32_t MediaCodecVideoDecoder::InitDecode(const VideoCodec* inst,
// Call Java init.
return codec_thread_->Invoke<int32_t>(
RTC_FROM_HERE,
Bind(&MediaCodecVideoDecoder::InitDecodeOnCodecThread, this));
}
@ -399,7 +400,7 @@ int32_t MediaCodecVideoDecoder::InitDecodeOnCodecThread() {
}
}
codec_thread_->PostDelayed(kMediaCodecPollMs, this);
codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
return WEBRTC_VIDEO_CODEC_OK;
}
@ -430,7 +431,7 @@ int32_t MediaCodecVideoDecoder::ResetDecodeOnCodecThread() {
}
inited_ = true;
codec_thread_->PostDelayed(kMediaCodecPollMs, this);
codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
return WEBRTC_VIDEO_CODEC_OK;
}
@ -438,7 +439,7 @@ int32_t MediaCodecVideoDecoder::ResetDecodeOnCodecThread() {
int32_t MediaCodecVideoDecoder::Release() {
ALOGD << "DecoderRelease request";
return codec_thread_->Invoke<int32_t>(
Bind(&MediaCodecVideoDecoder::ReleaseOnCodecThread, this));
RTC_FROM_HERE, Bind(&MediaCodecVideoDecoder::ReleaseOnCodecThread, this));
}
int32_t MediaCodecVideoDecoder::ReleaseOnCodecThread() {
@ -539,8 +540,9 @@ int32_t MediaCodecVideoDecoder::Decode(
if (use_surface_ &&
(codecType_ == kVideoCodecVP8 || codecType_ == kVideoCodecH264)) {
// Soft codec reset - only for surface decoding.
ret = codec_thread_->Invoke<int32_t>(Bind(
&MediaCodecVideoDecoder::ResetDecodeOnCodecThread, this));
ret = codec_thread_->Invoke<int32_t>(
RTC_FROM_HERE,
Bind(&MediaCodecVideoDecoder::ResetDecodeOnCodecThread, this));
} else {
// Hard codec reset.
ret = InitDecode(&codec_, 1);
@ -568,8 +570,9 @@ int32_t MediaCodecVideoDecoder::Decode(
return WEBRTC_VIDEO_CODEC_ERROR;
}
return codec_thread_->Invoke<int32_t>(Bind(
&MediaCodecVideoDecoder::DecodeOnCodecThread, this, inputImage));
return codec_thread_->Invoke<int32_t>(
RTC_FROM_HERE,
Bind(&MediaCodecVideoDecoder::DecodeOnCodecThread, this, inputImage));
}
int32_t MediaCodecVideoDecoder::DecodeOnCodecThread(
@ -896,7 +899,7 @@ void MediaCodecVideoDecoder::OnMessage(rtc::Message* msg) {
ProcessHWErrorOnCodecThread();
return;
}
codec_thread_->PostDelayed(kMediaCodecPollMs, this);
codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
}
MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory()

View File

@ -413,35 +413,33 @@ int32_t MediaCodecVideoEncoder::InitEncode(
}
return codec_thread_->Invoke<int32_t>(
Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread,
this,
init_width,
init_height,
codec_settings->startBitrate,
codec_settings->maxFramerate,
false /* use_surface */));
RTC_FROM_HERE,
Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, this, init_width,
init_height, codec_settings->startBitrate,
codec_settings->maxFramerate, false /* use_surface */));
}
int32_t MediaCodecVideoEncoder::Encode(
const webrtc::VideoFrame& frame,
const webrtc::CodecSpecificInfo* /* codec_specific_info */,
const std::vector<webrtc::FrameType>* frame_types) {
return codec_thread_->Invoke<int32_t>(Bind(
&MediaCodecVideoEncoder::EncodeOnCodecThread, this, frame, frame_types));
return codec_thread_->Invoke<int32_t>(
RTC_FROM_HERE, Bind(&MediaCodecVideoEncoder::EncodeOnCodecThread, this,
frame, frame_types));
}
int32_t MediaCodecVideoEncoder::RegisterEncodeCompleteCallback(
webrtc::EncodedImageCallback* callback) {
return codec_thread_->Invoke<int32_t>(
RTC_FROM_HERE,
Bind(&MediaCodecVideoEncoder::RegisterEncodeCompleteCallbackOnCodecThread,
this,
callback));
this, callback));
}
int32_t MediaCodecVideoEncoder::Release() {
ALOGD << "EncoderRelease request";
return codec_thread_->Invoke<int32_t>(
Bind(&MediaCodecVideoEncoder::ReleaseOnCodecThread, this));
RTC_FROM_HERE, Bind(&MediaCodecVideoEncoder::ReleaseOnCodecThread, this));
}
int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */,
@ -452,10 +450,8 @@ int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */,
int32_t MediaCodecVideoEncoder::SetRates(uint32_t new_bit_rate,
uint32_t frame_rate) {
return codec_thread_->Invoke<int32_t>(
Bind(&MediaCodecVideoEncoder::SetRatesOnCodecThread,
this,
new_bit_rate,
frame_rate));
RTC_FROM_HERE, Bind(&MediaCodecVideoEncoder::SetRatesOnCodecThread, this,
new_bit_rate, frame_rate));
}
void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) {
@ -478,7 +474,7 @@ void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) {
// If there aren't more frames to deliver, we can stop the loop
if (!input_frame_infos_.empty()) {
codec_thread_->PostDelayed(kMediaCodecPollMs, this);
codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
} else {
output_delivery_loop_running_ = false;
}
@ -742,7 +738,7 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread(
if (!output_delivery_loop_running_) {
output_delivery_loop_running_ = true;
codec_thread_->PostDelayed(kMediaCodecPollMs, this);
codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
}
if (!DeliverPendingOutputs(jni)) {
@ -1178,6 +1174,7 @@ void MediaCodecVideoEncoder::OnDroppedFrame() {
// directly.
RTC_DCHECK(!codec_thread_checker_.CalledOnValidThread());
codec_thread_->Invoke<void>(
RTC_FROM_HERE,
Bind(&MediaCodecVideoEncoder::OnDroppedFrameOnCodecThread, this));
}

View File

@ -268,8 +268,9 @@ int AndroidNetworkMonitor::BindSocketToNetwork(int socket_fd,
void AndroidNetworkMonitor::OnNetworkConnected(
const NetworkInformation& network_info) {
worker_thread()->Invoke<void>(rtc::Bind(
&AndroidNetworkMonitor::OnNetworkConnected_w, this, network_info));
worker_thread()->Invoke<void>(
RTC_FROM_HERE, rtc::Bind(&AndroidNetworkMonitor::OnNetworkConnected_w,
this, network_info));
// Fire SignalNetworksChanged to update the list of networks.
OnNetworksChanged();
}
@ -288,6 +289,7 @@ void AndroidNetworkMonitor::OnNetworkConnected_w(
void AndroidNetworkMonitor::OnNetworkDisconnected(NetworkHandle handle) {
LOG(LS_INFO) << "Network disconnected for handle " << handle;
worker_thread()->Invoke<void>(
RTC_FROM_HERE,
rtc::Bind(&AndroidNetworkMonitor::OnNetworkDisconnected_w, this, handle));
}

View File

@ -107,15 +107,17 @@ void AndroidVideoCapturerJni::Stop() {
template <typename... Args>
void AndroidVideoCapturerJni::AsyncCapturerInvoke(
const char* method_name,
const rtc::Location& posted_from,
void (webrtc::AndroidVideoCapturer::*method)(Args...),
typename Identity<Args>::type... args) {
rtc::CritScope cs(&capturer_lock_);
if (!invoker_) {
LOG(LS_WARNING) << method_name << "() called for closed capturer.";
LOG(LS_WARNING) << posted_from.function_name()
<< "() called for closed capturer.";
return;
}
invoker_->AsyncInvoke<void>(rtc::Bind(method, capturer_, args...));
invoker_->AsyncInvoke<void>(posted_from,
rtc::Bind(method, capturer_, args...));
}
std::vector<cricket::VideoFormat>
@ -162,9 +164,8 @@ AndroidVideoCapturerJni::GetSupportedFormats() {
void AndroidVideoCapturerJni::OnCapturerStarted(bool success) {
LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success;
AsyncCapturerInvoke("OnCapturerStarted",
&webrtc::AndroidVideoCapturer::OnCapturerStarted,
success);
AsyncCapturerInvoke(
RTC_FROM_HERE, &webrtc::AndroidVideoCapturer::OnCapturerStarted, success);
}
void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame,
@ -308,7 +309,7 @@ void AndroidVideoCapturerJni::OnTextureFrame(int width,
void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
int height,
int fps) {
AsyncCapturerInvoke("OnOutputFormatRequest",
AsyncCapturerInvoke(RTC_FROM_HERE,
&webrtc::AndroidVideoCapturer::OnOutputFormatRequest,
width, height, fps);
}

View File

@ -68,7 +68,7 @@ class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate {
// are not guaranteed to be delivered.
template <typename... Args>
void AsyncCapturerInvoke(
const char* method_name,
const rtc::Location& posted_from,
void (webrtc::AndroidVideoCapturer::*method)(Args...),
typename Identity<Args>::type... args);

View File

@ -1119,9 +1119,12 @@ void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() {
void OwnedFactoryAndThreads::InvokeJavaCallbacksOnFactoryThreads() {
LOG(LS_INFO) << "InvokeJavaCallbacksOnFactoryThreads.";
network_thread_->Invoke<void>([this] { JavaCallbackOnFactoryThreads(); });
worker_thread_->Invoke<void>([this] { JavaCallbackOnFactoryThreads(); });
signaling_thread_->Invoke<void>([this] { JavaCallbackOnFactoryThreads(); });
network_thread_->Invoke<void>(RTC_FROM_HERE,
[this] { JavaCallbackOnFactoryThreads(); });
worker_thread_->Invoke<void>(RTC_FROM_HERE,
[this] { JavaCallbackOnFactoryThreads(); });
signaling_thread_->Invoke<void>(RTC_FROM_HERE,
[this] { JavaCallbackOnFactoryThreads(); });
}
PeerConnectionFactoryInterface::Options ParseOptionsFromJava(JNIEnv* jni,