Skip to content

Commit f43a986

Browse files
committed
Bug 1825603 - Add more logs for RemoteMediaDataDecoder r=media-playback-reviewers,alwu
The `VideoDecoder` interface, associated with a `MediaDataDecoder`, is going to be introduced in Bug 1749045, which can be run on either the main thread or the worker thread, in the content process. While the `VideoDecoder` that `RemoteMediaDataDecoder` is associated with can run on the worker thread, the thread where `RemoteMediaDataDecoder` runs on, hosted by `RemoteDecoderManagerChild`, is created and released on the main thread only. Without extra carefulness, it's easy to have some racing issues in the code with these complex thread arrangements. It's even harder to figure out the causes of the issues without clear logs. Adding more RDD logs can be helpful to debug, especially when rr-recording couldn't capture some timing-critical intermittent racing issues. Differential Revision: https://phabricator.services.mozilla.com/D174147
1 parent 41920f2 commit f43a986

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

dom/media/ipc/RemoteDecoderManagerChild.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ StaticRefPtr<ShutdownObserver> sObserver;
9191
/* static */
9292
void RemoteDecoderManagerChild::Init() {
9393
MOZ_ASSERT(NS_IsMainThread());
94+
LOG("RemoteDecoderManagerChild Init");
9495

9596
auto remoteDecoderManagerThread = sRemoteDecoderManagerChildThread.Lock();
9697
if (!*remoteDecoderManagerThread) {
98+
LOG("RemoteDecoderManagerChild's thread is created");
9799
// We can't use a MediaThreadType::SUPERVISOR as the RemoteDecoderModule
98100
// runs on it and dispatch synchronous tasks to the manager thread, should
99101
// more than 4 concurrent videos being instantiated at the same time, we
@@ -137,6 +139,7 @@ void RemoteDecoderManagerChild::InitForGPUProcess(
137139
/* static */
138140
void RemoteDecoderManagerChild::Shutdown() {
139141
MOZ_ASSERT(NS_IsMainThread());
142+
LOG("RemoteDecoderManagerChild Shutdown");
140143

141144
if (sObserver) {
142145
nsContentUtils::UnregisterShutdownObserver(sObserver);
@@ -147,6 +150,7 @@ void RemoteDecoderManagerChild::Shutdown() {
147150
{
148151
auto remoteDecoderManagerThread = sRemoteDecoderManagerChildThread.Lock();
149152
childThread = remoteDecoderManagerThread->forget();
153+
LOG("RemoteDecoderManagerChild's thread is released");
150154
}
151155
if (childThread) {
152156
MOZ_ALWAYS_SUCCEEDS(childThread->Dispatch(NS_NewRunnableFunction(

dom/media/ipc/RemoteMediaDataDecoder.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@
1010

1111
namespace mozilla {
1212

13+
#ifdef LOG
14+
# undef LOG
15+
#endif // LOG
16+
#define LOG(arg, ...) \
17+
DDMOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, "::%s: " arg, __func__, \
18+
##__VA_ARGS__)
19+
1320
RemoteMediaDataDecoder::RemoteMediaDataDecoder(RemoteDecoderChild* aChild)
14-
: mChild(aChild) {}
21+
: mChild(aChild) {
22+
LOG("%p is created", this);
23+
}
1524

1625
RemoteMediaDataDecoder::~RemoteMediaDataDecoder() {
1726
if (mChild) {
@@ -29,6 +38,7 @@ RemoteMediaDataDecoder::~RemoteMediaDataDecoder() {
2938
});
3039
}));
3140
}
41+
LOG("%p is released", this);
3242
}
3343

3444
RefPtr<MediaDataDecoder::InitPromise> RemoteMediaDataDecoder::Init() {
@@ -51,6 +61,9 @@ RefPtr<MediaDataDecoder::InitPromise> RemoteMediaDataDecoder::Init() {
5161
mIsHardwareAccelerated =
5262
mChild->IsHardwareAccelerated(mHardwareAcceleratedReason);
5363
mConversion = mChild->NeedsConversion();
64+
LOG("%p RemoteDecoderChild has been initialized - description: %s, "
65+
"process: %s, codec: %s",
66+
this, mDescription.get(), mProcessName.get(), mCodecName.get());
5467
return InitPromise::CreateAndResolve(aTrack, __func__);
5568
},
5669
[self](const MediaResult& aError) {
@@ -145,4 +158,6 @@ nsCString RemoteMediaDataDecoder::GetProcessName() const {
145158

146159
nsCString RemoteMediaDataDecoder::GetCodecName() const { return mCodecName; }
147160

161+
#undef LOG
162+
148163
} // namespace mozilla

0 commit comments

Comments
 (0)