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}
diff --git a/webrtc/api/java/jni/androidmediadecoder_jni.cc b/webrtc/api/java/jni/androidmediadecoder_jni.cc
index 831b68d..3793756 100644
--- a/webrtc/api/java/jni/androidmediadecoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediadecoder_jni.cc
@@ -307,6 +307,7 @@
// Call Java init.
return codec_thread_->Invoke<int32_t>(
+ RTC_FROM_HERE,
Bind(&MediaCodecVideoDecoder::InitDecodeOnCodecThread, this));
}
@@ -399,7 +400,7 @@
}
}
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
return WEBRTC_VIDEO_CODEC_OK;
}
@@ -430,7 +431,7 @@
}
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::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 @@
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 @@
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 @@
ProcessHWErrorOnCodecThread();
return;
}
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
}
MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory()
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
index 0e36aa1..a240b25 100644
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
@@ -413,35 +413,33 @@
}
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::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 @@
// 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 @@
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 @@
// directly.
RTC_DCHECK(!codec_thread_checker_.CalledOnValidThread());
codec_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&MediaCodecVideoEncoder::OnDroppedFrameOnCodecThread, this));
}
diff --git a/webrtc/api/java/jni/androidnetworkmonitor_jni.cc b/webrtc/api/java/jni/androidnetworkmonitor_jni.cc
index b7857e2..a815e27 100644
--- a/webrtc/api/java/jni/androidnetworkmonitor_jni.cc
+++ b/webrtc/api/java/jni/androidnetworkmonitor_jni.cc
@@ -268,8 +268,9 @@
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::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));
}
diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.cc b/webrtc/api/java/jni/androidvideocapturer_jni.cc
index 58f4d74..82d8c8e 100644
--- a/webrtc/api/java/jni/androidvideocapturer_jni.cc
+++ b/webrtc/api/java/jni/androidvideocapturer_jni.cc
@@ -107,15 +107,17 @@
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 @@
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::OnOutputFormatRequest(int width,
int height,
int fps) {
- AsyncCapturerInvoke("OnOutputFormatRequest",
+ AsyncCapturerInvoke(RTC_FROM_HERE,
&webrtc::AndroidVideoCapturer::OnOutputFormatRequest,
width, height, fps);
}
diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.h b/webrtc/api/java/jni/androidvideocapturer_jni.h
index 4a803d9..00c7d91 100644
--- a/webrtc/api/java/jni/androidvideocapturer_jni.h
+++ b/webrtc/api/java/jni/androidvideocapturer_jni.h
@@ -68,7 +68,7 @@
// 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);
diff --git a/webrtc/api/java/jni/peerconnection_jni.cc b/webrtc/api/java/jni/peerconnection_jni.cc
index 0dc9b5e..a5ba254 100644
--- a/webrtc/api/java/jni/peerconnection_jni.cc
+++ b/webrtc/api/java/jni/peerconnection_jni.cc
@@ -1119,9 +1119,12 @@
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,