Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSE] Bring back some useful SourceBuffer logs #5854

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <limits>
#include <wtf/CheckedArithmetic.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/StringPrintStream.h>
#include <wtf/WeakPtr.h>

namespace WebCore {
Expand Down Expand Up @@ -492,6 +493,10 @@ ExceptionOr<void> SourceBuffer::appendBufferInternal(const unsigned char* data,
if (isRemoved() || m_updating)
return Exception { InvalidStateError };

StringPrintStream message;
message.printf("SourceBuffer::appendBufferInternal(%p) - append size = %u, buffered = %s\n", this, size, toString(m_private->buffered()->ranges()).utf8().data());
DEBUG_LOG(LOGIDENTIFIER, message.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't DEBUG_LOG take printf-like parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It takes a list of parameters that are converted to String and joined. The problem with that is that it doesn't know how to convert all the types. Specifically, it doesn't know how to convert the (SourceBuffer*)this (or any other pointer).
I wish there was something like a String::format() method that generated a String from a printf-like template, but I haven't found it. The closest I found was makeString(), which uses the same conversion and joining strategy that DEBUG_LOG() uses, and has the same problems.


// 3. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
// 3.1. Set the readyState attribute of the parent media source to "open"
// 3.2. Queue a task to fire a simple event named sourceopen at the parent media source .
Expand Down Expand Up @@ -587,7 +592,9 @@ void SourceBuffer::sourceBufferPrivateAppendComplete(AppendResult result)
m_source->monitorSourceBuffers();
m_private->reenqueueMediaIfNeeded(m_source->currentTime());

DEBUG_LOG(LOGIDENTIFIER);
StringPrintStream message;
message.printf("SourceBuffer::sourceBufferPrivateAppendComplete(%p) - buffered = %s", this, toString(m_private->buffered()->ranges()).utf8().data());
DEBUG_LOG(LOGIDENTIFIER, message.toString());
}

void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(int64_t error)
Expand Down