Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (221444 => 221445)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-08-31 21:26:24 UTC (rev 221444)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-08-31 21:41:01 UTC (rev 221445)
@@ -88,6 +88,7 @@
#include "UserContentController.h"
#include "UserGestureIndicator.h"
#include <limits>
+#include <pal/Logger.h>
#include <pal/SessionID.h>
#include <pal/system/SleepDisabler.h>
#include <runtime/Uint8Array.h>
@@ -164,10 +165,34 @@
#include "VideoFullscreenModel.h"
#endif
-#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(document().page() && document().page()->isAlwaysOnLoggingAllowed(), Media, "%p - HTMLMediaElement::" fmt, this, ##__VA_ARGS__)
+namespace PAL {
+template <>
+struct LogArgument<WebCore::URL> {
+ static String toString(const WebCore::URL& url)
+ {
+#if !LOG_DISABLED
+ static const unsigned maximumURLLengthForLogging = 512;
+ if (url.string().length() < maximumURLLengthForLogging)
+ return url.string();
+ return url.string().substring(0, maximumURLLengthForLogging) + "...";
+#else
+ UNUSED_PARAM(url);
+ return "[url]";
+#endif
+ }
+};
+}
+
+using namespace PAL;
+
namespace WebCore {
+#if LOG_DISABLED && !RELEASE_LOG_DISABLED
+// FIXME: Unify with debug build logging.
+static WTFLogChannel LogMedia = { WTFLogChannelOff, "Media", WTFLogLevelError, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
+#endif
+
static const Seconds SeekRepeatDelay { 100_ms };
static const double SeekTime = 0.2;
static const Seconds ScanRepeatDelay { 1.5_s };
@@ -186,21 +211,7 @@
value &= ~flags;
}
-#if !LOG_DISABLED
-static String urlForLoggingMedia(const URL& url)
-{
- static const unsigned maximumURLLengthForLogging = 128;
-
- if (url.string().length() < maximumURLLengthForLogging)
- return url.string();
- return url.string().substring(0, maximumURLLengthForLogging) + "...";
-}
-
-static const char* boolString(bool val)
-{
- return val ? "true" : "false";
-}
-
+#if !RELEASE_LOG_DISABLED
static String actionName(HTMLMediaElementEnums::DelayedActionType action)
{
StringBuilder actionBuilder;
@@ -212,6 +223,7 @@
actionBuilder.append(#_actionType); \
} \
+ ACTION(LoadMediaResource);
ACTION(ConfigureTextTracks);
ACTION(TextTrackChangesNotification);
ACTION(ConfigureTextTrackDisplay);
@@ -218,20 +230,16 @@
ACTION(CheckPlaybackTargetCompatablity);
ACTION(CheckMediaState);
ACTION(MediaEngineUpdated);
+ ACTION(UpdatePlayState);
- return actionBuilder.toString();
+#undef ACTION
-#undef ACTION
+ String name = actionBuilder.toString();
+ ASSERT(!name.isEmpty());
+ return name;
}
-
#endif
-#ifndef LOG_MEDIA_EVENTS
-// Default to not logging events because so many are generated they can overwhelm the rest of
-// the logging.
-#define LOG_MEDIA_EVENTS 0
-#endif
-
#ifndef LOG_CACHED_TIME_WARNINGS
// Default to not logging warnings about excessive drift in the cached media time because it adds a
// fair amount of overhead and logging.
@@ -447,10 +455,14 @@
, m_processingPreferenceChange(false)
#endif
, m_mediaSession(std::make_unique<MediaElementSession>(*this))
+#if !RELEASE_LOG_DISABLED
+ , m_logger(&document.logger())
+#endif
{
allMediaElements().add(this);
- LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this);
+ ALWAYS_LOG(THIS);
+
setHasCustomStyleResolveCallbacks();
m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForFullscreen);
@@ -526,7 +538,7 @@
HTMLMediaElement::~HTMLMediaElement()
{
- LOG(Media, "HTMLMediaElement::~HTMLMediaElement(%p)", this);
+ ALWAYS_LOG(THIS);
beginIgnoringTrackDisplayUpdateRequests();
allMediaElements().remove(this);
@@ -858,7 +870,7 @@
Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode& insertionPoint)
{
- LOG(Media, "HTMLMediaElement::insertedInto(%p)", this);
+ NOTICE_LOG(THIS);
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint.isConnected()) {
@@ -917,7 +929,7 @@
void HTMLMediaElement::removedFrom(ContainerNode& insertionPoint)
{
- LOG(Media, "HTMLMediaElement::removedFrom(%p)", this);
+ NOTICE_LOG(THIS);
m_inActiveDocument = false;
if (insertionPoint.isConnected()) {
@@ -967,7 +979,8 @@
void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType)
{
- LOG(Media, "HTMLMediaElement::scheduleDelayedAction(%p) - setting %s flag", this, actionName(actionType).utf8().data());
+ if (actionType ^ m_pendingActionFlags)
+ ALWAYS_LOG(THIS, "setting ", actionName(actionType), " flag");
#if ENABLE(VIDEO_TRACK)
if (actionType & ConfigureTextTracks)
@@ -1007,9 +1020,6 @@
void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
{
-#if LOG_MEDIA_EVENTS
- LOG(Media, "HTMLMediaElement::scheduleEvent(%p) - scheduling '%s'", this, eventName.string().ascii().data());
-#endif
RefPtr<Event> event = Event::create(eventName, false, true);
// Don't set the event target, the event queue will set it in GenericEventQueue::timerFired and setting it here
@@ -1066,6 +1076,11 @@
PendingActionFlags pendingActions = m_pendingActionFlags;
m_pendingActionFlags = 0;
+ if (!pendingActions)
+ return;
+
+ ALWAYS_LOG(THIS, "setting ", actionName(static_cast<DelayedActionType>(pendingActions)), " flag");
+
#if ENABLE(VIDEO_TRACK)
if (pendingActions & ConfigureTextTracks)
configureTextTracks();
@@ -1073,7 +1088,7 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
if (pendingActions & CheckPlaybackTargetCompatablity && m_isPlayingToWirelessTarget && !m_player->canPlayToWirelessPlaybackTarget()) {
- LOG(Media, "HTMLMediaElement::pendingActionTimerFired(%p) - calling setShouldPlayToPlaybackTarget(false)", this);
+ NOTICE_LOG(THIS, "calling setShouldPlayToPlaybackTarget(false)");
m_failedToPlayToWirelessTarget = true;
m_player->setShouldPlayToPlaybackTarget(false);
}
@@ -1150,7 +1165,7 @@
break;
}
- LOG(Media, "HTMLMediaElement::canPlayType(%p) - [%s] -> %s", this, mimeType.utf8().data(), canPlay.utf8().data());
+ DEBUG_LOG(THIS, "[", mimeType, "] -> ", canPlay);
return canPlay;
}
@@ -1166,7 +1181,7 @@
{
Ref<HTMLMediaElement> protectedThis(*this); // prepareForLoad may result in a 'beforeload' event, which can make arbitrary DOM mutations.
- LOG(Media, "HTMLMediaElement::load(%p)", this);
+ NOTICE_LOG(THIS);
if (!m_mediaSession->dataLoadingPermitted(*this))
return;
@@ -1185,7 +1200,7 @@
// The Media Element Load Algorithm
// 12 February 2017
- LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this);
+ NOTICE_LOG(THIS);
// 1 - Abort any already-running instance of the resource selection algorithm for this element.
// Perform the cleanup required for the resource load algorithm to run.
@@ -1304,7 +1319,7 @@
return;
if (!m_mediaSession->pageAllowsDataLoading(*this)) {
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - not allowed to load in background, waiting", this);
+ ALWAYS_LOG(THIS, "not allowed to load in background, waiting");
setShouldDelayLoadEvent(false);
if (m_isWaitingUntilMediaCanStart)
return;
@@ -1349,7 +1364,7 @@
mode = Attribute;
ASSERT(m_player);
if (!m_player) {
- RELEASE_LOG_ERROR(Media, "HTMLMediaElement::selectMediaResource(%p) - has srcAttr but m_player is not created", this);
+ ERROR_LOG(THIS, " - has srcAttr but m_player is not created");
return;
}
} else if (auto firstSource = childrenOfType<HTMLSourceElement>(*this).first()) {
@@ -1366,7 +1381,7 @@
setShouldDelayLoadEvent(false);
m_networkState = NETWORK_EMPTY;
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - nothing to load", this);
+ ALWAYS_LOG(THIS, "nothing to load");
return;
}
@@ -1396,7 +1411,7 @@
ContentType contentType;
loadResource(URL(), contentType, String());
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - using 'srcObject' property", this);
+ ALWAYS_LOG(THIS, "using 'srcObject' property");
// If that algorithm returns without aborting this one, then the load failed.
// 4. Failed with media provider: Reaching this step indicates that the media resource
@@ -1419,7 +1434,7 @@
URL absoluteURL = getNonEmptyURLAttribute(srcAttr);
if (absoluteURL.isEmpty()) {
mediaLoadingFailed(MediaPlayer::FormatError);
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - empty 'src'", this);
+ ALWAYS_LOG(THIS, "empty 'src'");
return;
}
@@ -1440,7 +1455,7 @@
// will have to pick a media engine based on the file extension.
ContentType contentType;
loadResource(absoluteURL, contentType, String());
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - using 'src' attribute url", this);
+ ALWAYS_LOG(THIS, "using 'src' attribute url");
// 6. Failed with attribute: Reaching this step indicates that the media resource failed to load
// or that the given URL could not be resolved. Queue a task to run the dedicated media source failure steps.
@@ -1476,7 +1491,7 @@
{
ASSERT(initialURL.isEmpty() || isSafeToLoadURL(initialURL, Complain));
- LOG(Media, "HTMLMediaElement::loadResource(%p) - %s, %s, %s", this, urlForLoggingMedia(initialURL).utf8().data(), contentType.raw().utf8().data(), keySystem.utf8().data());
+ NOTICE_LOG(THIS, initialURL, contentType.raw(), keySystem);
Frame* frame = document().frame();
if (!frame) {
@@ -1530,10 +1545,10 @@
if (resource) {
url = ""
- LOG(Media, "HTMLMediaElement::loadResource(%p) - will load from app cache -> %s", this, urlForLoggingMedia(url).utf8().data());
+ NOTICE_LOG(THIS, "will load ", url, " from app cache");
}
- LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", this, urlForLoggingMedia(m_currentSrc).utf8().data());
+ NOTICE_LOG(THIS, "m_currentSrc is ", m_currentSrc);
startProgressEventTimer();
@@ -1641,7 +1656,7 @@
if (ignoreTrackDisplayUpdateRequests())
return;
- LOG(Media, "HTMLMediaElement::updateActiveTextTrackCues(%p)", this);
+ DEBUG_LOG(THIS);
// 1 - Let current cues be a list of cues, initialized to contain all the
// cues of all the hidden, showing, or showing by default text tracks of the
@@ -2041,7 +2056,7 @@
bool HTMLMediaElement::isSafeToLoadURL(const URL& url, InvalidURLAction actionIfInvalid)
{
if (!url.isValid()) {
- LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p) - %s -> FALSE because url is invalid", this, urlForLoggingMedia(url).utf8().data());
+ ERROR_LOG(THIS, url, " is invalid");
return false;
}
@@ -2049,12 +2064,12 @@
if (!frame || !document().securityOrigin().canDisplay(url)) {
if (actionIfInvalid == Complain)
FrameLoader::reportLocalLoadFailed(frame, url.stringCenterEllipsizedToLength());
- LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p) - %s -> FALSE rejected by SecurityOrigin", this, urlForLoggingMedia(url).utf8().data());
+ ERROR_LOG(THIS, url , " was rejected by SecurityOrigin");
return false;
}
if (!isAllowedToLoadMediaURL(*this, url, isInUserAgentShadowTree())) {
- LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p) - %s -> rejected by Content Security Policy", this, urlForLoggingMedia(url).utf8().data());
+ ERROR_LOG(THIS, url, " was rejected by Content Security Policy");
return false;
}
@@ -2073,7 +2088,7 @@
void HTMLMediaElement::waitForSourceChange()
{
- LOG(Media, "HTMLMediaElement::waitForSourceChange(%p)", this);
+ NOTICE_LOG(THIS);
stopPeriodicTimers();
m_loadState = WaitingForSource;
@@ -2090,7 +2105,7 @@
void HTMLMediaElement::noneSupported()
{
- LOG(Media, "HTMLMediaElement::noneSupported(%p)", this);
+ NOTICE_LOG(THIS);
stopPeriodicTimers();
m_loadState = WaitingForSource;
@@ -2131,8 +2146,6 @@
void HTMLMediaElement::mediaLoadingFailedFatally(MediaPlayer::NetworkState error)
{
- LOG(Media, "HTMLMediaElement::mediaLoadingFailedFatally(%p) - error = %d", this, static_cast<int>(error));
-
// 1 - The user agent should cancel the fetching process.
stopPeriodicTimers();
m_loadState = WaitingForSource;
@@ -2172,7 +2185,7 @@
void HTMLMediaElement::cancelPendingEventsAndCallbacks()
{
- LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this);
+ NOTICE_LOG(THIS);
m_asyncEventQueue.cancelAllEvents();
for (auto& source : childrenOfType<HTMLSourceElement>(*this))
@@ -2237,7 +2250,7 @@
if (m_currentSourceNode)
m_currentSourceNode->scheduleErrorEvent();
else
- LOG(Media, "HTMLMediaElement::setNetworkState(%p) - error event not sent, <source> was removed", this);
+ NOTICE_LOG(THIS, "error event not sent, <source> was removed");
// 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended.
@@ -2245,10 +2258,10 @@
forgetResourceSpecificTracks();
if (havePotentialSourceChild()) {
- LOG(Media, "HTMLMediaElement::setNetworkState(%p) - scheduling next <source>", this);
+ NOTICE_LOG(THIS, "scheduling next <source>");
scheduleNextSourceChild();
} else {
- LOG(Media, "HTMLMediaElement::setNetworkState(%p) - no more <source> elements, waiting", this);
+ NOTICE_LOG(THIS, "no more <source> elements, waiting");
waitForSourceChange();
}
@@ -2266,6 +2279,8 @@
mediaControls()->reportedError();
}
+ ERROR_LOG(THIS, "error = ", static_cast<int>(error));
+
logMediaLoadRequest(document().page(), String(), stringForNetworkState(error), false);
m_mediaSession->clientCharacteristicsChanged();
@@ -2273,7 +2288,8 @@
void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
{
- LOG(Media, "HTMLMediaElement::setNetworkState(%p) - new state = %d, current state = %d", this, static_cast<int>(state), static_cast<int>(m_networkState));
+ if (static_cast<int>(state) != static_cast<int>(m_networkState))
+ ALWAYS_LOG(THIS, "new state = ", static_cast<int>(state), ", current state = ", static_cast<int>(m_networkState));
if (state == MediaPlayer::Empty) {
// Just update the cached state and leave, we can't do anything.
@@ -2344,7 +2360,7 @@
&& m_readyState == HAVE_ENOUGH_DATA)
return mediaSession().playbackPermitted(*this);
- RELEASE_LOG(Media, "HTMLMediaElement::canTransitionFromAutoplayToPlay - page consent required");
+ ALWAYS_LOG(THIS, "page consent required");
return MediaPlaybackDenialReason::PageConsentRequired;
}
@@ -2360,8 +2376,6 @@
void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
{
- LOG(Media, "HTMLMediaElement::setReadyState(%p) - new state = %d, current state = %d,", this, static_cast<int>(state), static_cast<int>(m_readyState));
-
// Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlaying() uses it
bool wasPotentiallyPlaying = potentiallyPlaying();
@@ -2381,6 +2395,8 @@
bool tracksAreReady = true;
#endif
+ ALWAYS_LOG(THIS, "new state = ", static_cast<int>(state), ", current state = ", static_cast<int>(m_readyState));
+
if (tracksAreReady)
m_readyState = newState;
else {
@@ -2760,19 +2776,17 @@
void HTMLMediaElement::rewind(double timeDelta)
{
- LOG(Media, "HTMLMediaElement::rewind(%p) - %f", this, timeDelta);
setCurrentTime(std::max(currentMediaTime() - MediaTime::createWithDouble(timeDelta), minTimeSeekable()));
}
void HTMLMediaElement::returnToRealtime()
{
- LOG(Media, "HTMLMediaElement::returnToRealtime(%p)", this);
setCurrentTime(maxTimeSeekable());
}
void HTMLMediaElement::addPlayedRange(const MediaTime& start, const MediaTime& end)
{
- LOG(Media, "HTMLMediaElement::addPlayedRange(%p) - [%s, %s]", this, toString(start).utf8().data(), toString(end).utf8().data());
+ DEBUG_LOG(THIS, "[", start, ", ", end, "]");
if (!m_playedTimeRanges)
m_playedTimeRanges = TimeRanges::create();
m_playedTimeRanges->ranges().add(start, end);
@@ -2785,7 +2799,7 @@
void HTMLMediaElement::prepareToPlay()
{
- LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this);
+ NOTICE_LOG(THIS);
if (m_havePreparedToPlay)
return;
m_havePreparedToPlay = true;
@@ -2800,7 +2814,7 @@
void HTMLMediaElement::fastSeek(const MediaTime& time)
{
- LOG(Media, "HTMLMediaElement::fastSeek(%p) - %s", this, toString(time).utf8().data());
+ NOTICE_LOG(THIS, time);
// 4.7.10.9 Seeking
// 9. If the approximate-for-speed flag is set, adjust the new playback position to a value that will
// allow for playback to resume promptly. If new playback position before this step is before current
@@ -2816,13 +2830,13 @@
void HTMLMediaElement::seek(const MediaTime& time)
{
- LOG(Media, "HTMLMediaElement::seek(%p) - %s", this, toString(time).utf8().data());
+ NOTICE_LOG(THIS, time);
seekWithTolerance(time, MediaTime::zeroTime(), MediaTime::zeroTime(), true);
}
void HTMLMediaElement::seekInternal(const MediaTime& time)
{
- LOG(Media, "HTMLMediaElement::seekInternal(%p) - %s", this, toString(time).utf8().data());
+ NOTICE_LOG(THIS, time);
seekWithTolerance(time, MediaTime::zeroTime(), MediaTime::zeroTime(), false);
}
@@ -2850,7 +2864,7 @@
// already running. Abort that other instance of the algorithm without waiting for the step that
// it is running to complete.
if (m_seekTaskQueue.hasPendingTasks()) {
- LOG(Media, "HTMLMediaElement::seekWithTolerance(%p) - cancelling pending seeks", this);
+ NOTICE_LOG(THIS, "cancelling pending seeks");
m_seekTaskQueue.cancelAllTasks();
if (m_pendingSeek) {
now = m_pendingSeek->now;
@@ -2872,7 +2886,7 @@
// the script. The remainder of these steps must be run asynchronously.
m_pendingSeek = std::make_unique<PendingSeek>(now, time, negativeTolerance, positiveTolerance);
if (fromDOM) {
- LOG(Media, "HTMLMediaElement::seekWithTolerance(%p) - enqueuing seek from %s to %s", this, toString(now).utf8().data(), toString(time).utf8().data());
+ NOTICE_LOG(THIS, "enqueuing seek from ", now, " to ", time);
m_seekTaskQueue.enqueueTask(std::bind(&HTMLMediaElement::seekTask, this));
} else
seekTask();
@@ -2883,7 +2897,7 @@
void HTMLMediaElement::seekTask()
{
- LOG(Media, "HTMLMediaElement::seekTask(%p)", this);
+ NOTICE_LOG(THIS);
if (!m_player) {
clearSeeking();
@@ -2912,11 +2926,12 @@
// time scale, we will ask the media engine to "seek" to the current movie time, which may be a noop and
// not generate a timechanged callback. This means m_seeking will never be cleared and we will never
// fire a 'seeked' event.
-#if !LOG_DISABLED
- MediaTime mediaTime = m_player->mediaTimeForTimeValue(time);
- if (time != mediaTime)
- LOG(Media, "HTMLMediaElement::seekTask(%p) - %s - media timeline equivalent is %s", this, toString(time).utf8().data(), toString(mediaTime).utf8().data());
-#endif
+ if (willLog(WTFLogLevelDebug)) {
+ MediaTime mediaTime = m_player->mediaTimeForTimeValue(time);
+ if (time != mediaTime)
+ DEBUG_LOG(THIS, time, " media timeline equivalent is ", mediaTime);
+ }
+
time = m_player->mediaTimeForTimeValue(time);
// 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the
@@ -2941,7 +2956,7 @@
#endif
if (noSeekRequired) {
- LOG(Media, "HTMLMediaElement::seekTask(%p) - seek to %s ignored", this, toString(time).utf8().data());
+ NOTICE_LOG(THIS, "seek to ", time, " ignored");
if (time == now) {
scheduleEvent(eventNames().seekingEvent);
scheduleTimeupdateEvent(false);
@@ -2983,7 +2998,7 @@
// 14 - Set the seeking IDL attribute to false.
clearSeeking();
- LOG(Media, "HTMLMediaElement::finishSeek(%p) - current time = %s", this, toString(currentMediaTime()).utf8().data());
+ NOTICE_LOG(THIS, "current time = ", currentMediaTime());
// 15 - Run the time maches on steps.
// Handled by mediaPlayerTimeChanged().
@@ -3042,11 +3057,6 @@
if (!m_player || !m_player->maximumDurationToCacheMediaTime())
return;
-#if !LOG_DISABLED
- if (m_cachedTime.isValid())
- LOG(Media, "HTMLMediaElement::invalidateCachedTime(%p)", this);
-#endif
-
// Don't try to cache movie time when playback first starts as the time reported by the engine
// sometimes fluctuates for a short amount of time, so the cached time will be off if we take it
// too early.
@@ -3071,7 +3081,7 @@
return MediaTime::zeroTime();
if (m_seeking) {
- LOG(Media, "HTMLMediaElement::currentTime(%p) - seeking, returning %s", this, toString(m_lastSeekTime).utf8().data());
+ NOTICE_LOG(THIS, "seeking, returning", m_lastSeekTime);
return m_lastSeekTime;
}
@@ -3079,7 +3089,7 @@
#if LOG_CACHED_TIME_WARNINGS
MediaTime delta = m_cachedTime - m_player->currentTime();
if (delta > minCachedDeltaForWarning)
- LOG(Media, "HTMLMediaElement::currentTime(%p) - WARNING, cached time is %s seconds off of media time when paused", this, toString(delta).utf8().data());
+ WARNING_LOG(THIS, "cached time is ", delta, " seconds off of media time when paused");
#endif
return m_cachedTime;
}
@@ -3098,7 +3108,7 @@
#if LOG_CACHED_TIME_WARNINGS
MediaTime delta = adjustedCacheTime - m_player->currentTime();
if (delta > minCachedDeltaForWarning)
- LOG(Media, "HTMLMediaElement::currentTime(%p) - WARNING, cached time is %f seconds off of media time when playing", this, delta);
+ WARNING_LOG(THIS, "cached time is ", delta, " seconds off of media time when playing");
#endif
return adjustedCacheTime;
}
@@ -3108,7 +3118,7 @@
if (maximumDurationToCacheMediaTime && now > m_minimumClockTimeToUpdateCachedTime && m_cachedTime != MediaPlayer::invalidTime()) {
double clockDelta = now - m_clockTimeAtLastCachedTimeUpdate;
MediaTime delta = m_cachedTime + MediaTime::createWithDouble(effectivePlaybackRate() * clockDelta) - m_player->currentTime();
- LOG(Media, "HTMLMediaElement::currentTime(%p) - cached time was %s seconds off of media time when it expired", this, toString(delta).utf8().data());
+ WARNING_LOG(THIS, "cached time was ", delta, " seconds off of media time when it expired");
}
#endif
@@ -3193,11 +3203,12 @@
return;
#endif
- if (m_defaultPlaybackRate != rate) {
- LOG(Media, "HTMLMediaElement::setDefaultPlaybackRate(%p) - %f", this, rate);
- m_defaultPlaybackRate = rate;
- scheduleEvent(eventNames().ratechangeEvent);
- }
+ if (m_defaultPlaybackRate == rate)
+ return;
+
+ ALWAYS_LOG(THIS, rate);
+ m_defaultPlaybackRate = rate;
+ scheduleEvent(eventNames().ratechangeEvent);
}
double HTMLMediaElement::effectivePlaybackRate() const
@@ -3226,7 +3237,7 @@
void HTMLMediaElement::setPlaybackRate(double rate)
{
- LOG(Media, "HTMLMediaElement::setPlaybackRate(%p) - %f", this, rate);
+ ALWAYS_LOG(THIS, rate);
#if ENABLE(MEDIA_STREAM)
// http://w3c.github.io/mediacapture-main/#mediastreams-in-media-elements
@@ -3261,7 +3272,7 @@
void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch)
{
- LOG(Media, "HTMLMediaElement::setWebkitPreservesPitch(%p) - %s", this, boolString(preservesPitch));
+ NOTICE_LOG(THIS, preservesPitch);
m_webkitPreservesPitch = preservesPitch;
@@ -3316,7 +3327,7 @@
void HTMLMediaElement::setPreload(const String& preload)
{
- LOG(Media, "HTMLMediaElement::setPreload(%p) - %s", this, preload.utf8().data());
+ NOTICE_LOG(THIS, preload);
#if ENABLE(MEDIA_STREAM)
// http://w3c.github.io/mediacapture-main/#mediastreams-in-media-elements
// "preload" - On getting: none. On setting: ignored.
@@ -3329,7 +3340,7 @@
void HTMLMediaElement::play(DOMPromiseDeferred<void>&& promise)
{
- LOG(Media, "HTMLMediaElement::play(%p)", this);
+ ALWAYS_LOG(THIS);
auto success = m_mediaSession->playbackPermitted(*this);
if (!success) {
@@ -3357,7 +3368,7 @@
void HTMLMediaElement::play()
{
- LOG(Media, "HTMLMediaElement::play(%p)", this);
+ ALWAYS_LOG(THIS);
auto success = m_mediaSession->playbackPermitted(*this);
if (!success) {
@@ -3373,10 +3384,10 @@
bool HTMLMediaElement::playInternal()
{
- LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
+ ALWAYS_LOG(THIS);
if (!m_mediaSession->clientWillBeginPlayback()) {
- LOG(Media, " returning because of interruption");
+ ALWAYS_LOG(THIS, " returning because of interruption");
return true; // Treat as success because we will begin playback on cessation of the interruption.
}
@@ -3445,7 +3456,7 @@
void HTMLMediaElement::pause()
{
- LOG(Media, "HTMLMediaElement::pause(%p)", this);
+ ALWAYS_LOG(THIS);
m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
@@ -3461,10 +3472,10 @@
void HTMLMediaElement::pauseInternal()
{
- LOG(Media, "HTMLMediaElement::pauseInternal(%p)", this);
+ ALWAYS_LOG(THIS);
if (!m_mediaSession->clientWillPausePlayback()) {
- LOG(Media, " returning because of interruption");
+ ALWAYS_LOG(THIS, " returning because of interruption");
return;
}
@@ -3518,7 +3529,7 @@
void HTMLMediaElement::setLoop(bool b)
{
- LOG(Media, "HTMLMediaElement::setLoop(%p) - %s", this, boolString(b));
+ NOTICE_LOG(THIS, b);
setBooleanAttribute(loopAttr, b);
}
@@ -3535,7 +3546,7 @@
void HTMLMediaElement::setControls(bool b)
{
- LOG(Media, "HTMLMediaElement::setControls(%p) - %s", this, boolString(b));
+ NOTICE_LOG(THIS, b);
setBooleanAttribute(controlsAttr, b);
}
@@ -3546,7 +3557,7 @@
ExceptionOr<void> HTMLMediaElement::setVolume(double volume)
{
- LOG(Media, "HTMLMediaElement::setVolume(%p) - %f", this, volume);
+ NOTICE_LOG(THIS, volume);
if (!(volume >= 0 && volume <= 1))
return Exception { IndexSizeError };
@@ -3570,7 +3581,7 @@
void HTMLMediaElement::setMuted(bool muted)
{
- LOG(Media, "HTMLMediaElement::setMuted(%p) - %s", this, boolString(muted));
+ NOTICE_LOG(THIS, muted);
bool mutedStateChanged = m_muted != muted;
if (mutedStateChanged || !m_explicitlyMuted) {
@@ -3631,7 +3642,7 @@
void HTMLMediaElement::togglePlayState()
{
- LOG(Media, "HTMLMediaElement::togglePlayState(%p) - canPlay() is %s", this, boolString(canPlay()));
+ NOTICE_LOG(THIS, "canPlay() is ", canPlay());
// We can safely call the internal play/pause methods, which don't check restrictions, because
// this method is only called from the built-in media controller
@@ -3644,7 +3655,7 @@
void HTMLMediaElement::beginScrubbing()
{
- LOG(Media, "HTMLMediaElement::beginScrubbing(%p) - paused() is %s", this, boolString(paused()));
+ NOTICE_LOG(THIS, "paused() is ", paused());
if (!paused()) {
if (ended()) {
@@ -3665,7 +3676,7 @@
void HTMLMediaElement::endScrubbing()
{
- LOG(Media, "HTMLMediaElement::endScrubbing(%p) - m_pausedInternal is %s", this, boolString(m_pausedInternal));
+ NOTICE_LOG(THIS, "m_pausedInternal is", m_pausedInternal);
if (m_pausedInternal)
setPausedInternal(false);
@@ -4034,13 +4045,6 @@
{
ASSERT(trackElement.hasTagName(trackTag));
-#if !LOG_DISABLED
- if (trackElement.hasTagName(trackTag)) {
- URL url = ""
- LOG(Media, "HTMLMediaElement::didRemoveTrack(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
- }
-#endif
-
auto& textTrack = trackElement.track();
textTrack.setHasBeenConfigured(false);
@@ -4061,8 +4065,6 @@
{
ASSERT(group.tracks.size());
- LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%p)", this);
-
Page* page = document().page();
CaptionUserPreferences* captionPreferences = page ? &page->group().captionPreferences() : 0;
CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences ? captionPreferences->captionDisplayMode() : CaptionUserPreferences::Automatic;
@@ -4091,7 +4093,7 @@
currentlyEnabledTracks.append(textTrack);
int trackScore = captionPreferences ? captionPreferences->textTrackSelectionScore(textTrack.get(), this) : 0;
- LOG(Media, "HTMLMediaElement::configureTextTrackGroup(%p) - '%s' track with language '%s' and BCP 47 language '%s' has score %d", this, textTrack->kindKeyword().string().utf8().data(), textTrack->language().string().utf8().data(), textTrack->validBCP47Language().string().utf8().data(), trackScore);
+ NOTICE_LOG(THIS, "'", textTrack->kindKeyword(), "' track with language '", textTrack->language(), "' and BCP 47 language '", textTrack->validBCP47Language(), "' has score ", trackScore);
if (trackScore) {
@@ -4208,7 +4210,6 @@
void HTMLMediaElement::updateCaptionContainer()
{
- LOG(Media, "HTMLMediaElement::updateCaptionContainer(%p)", this);
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
if (m_haveSetUpCaptionContainer)
return;
@@ -4421,18 +4422,15 @@
URL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* keySystem, InvalidURLAction actionIfInvalid)
{
UNUSED_PARAM(keySystem);
-#if !LOG_DISABLED
+
// Don't log if this was just called to find out if there are any valid <source> elements.
- bool shouldLog = actionIfInvalid != DoNothing;
+ bool shouldLog = willLog(WTFLogLevelDebug) && actionIfInvalid != DoNothing;
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p)", this);
-#endif
+ NOTICE_LOG(THIS);
if (!m_nextChildNodeToConsider) {
-#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - end of list, stopping", this);
-#endif
+ NOTICE_LOG(THIS, "end of list, stopping");
return URL();
}
@@ -4451,18 +4449,14 @@
// If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below
auto mediaURL = source->getNonEmptyURLAttribute(srcAttr);
String type;
-#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'src' is %s", this, urlForLoggingMedia(mediaURL).utf8().data());
-#endif
+ NOTICE_LOG(THIS, "'src' is ", mediaURL);
if (mediaURL.isEmpty())
goto CheckAgain;
if (auto* media = source->parsedMediaAttribute()) {
-#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'media' is %s", this, source->attributeWithoutSynchronization(mediaAttr).string().utf8().data());
-#endif
+ NOTICE_LOG(THIS, "'media' is ", source->attributeWithoutSynchronization(mediaAttr));
auto* renderer = this->renderer();
LOG(MediaQueries, "HTMLMediaElement %p selectNextSourceChild evaluating media queries", this);
if (!MediaQueryEvaluator { "screen", document(), renderer ? &renderer->style() : nullptr }.evaluate(*media))
@@ -4473,10 +4467,8 @@
if (type.isEmpty() && mediaURL.protocolIsData())
type = mimeTypeFromDataURL(mediaURL);
if (!type.isEmpty()) {
-#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'type' is '%s'", this, type.utf8().data());
-#endif
+ NOTICE_LOG(THIS, "'type' is ", type);
MediaEngineSupportParameters parameters;
parameters.type = ContentType(type);
parameters.url = ""
@@ -4499,7 +4491,7 @@
// A 'beforeload' event handler can mutate the DOM, so check to see if the source element is still a child node.
if (source->parentNode() != this) {
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'beforeload' removed current element", this);
+ NOTICE_LOG(THIS, "'beforeload' removed current element");
continue;
}
@@ -4509,10 +4501,8 @@
m_nextChildNodeToConsider = Traversal<HTMLSourceElement>::nextSkippingChildren(source);
m_currentSourceNode = WTFMove(source);
-#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, %s", this, m_currentSourceNode.get(), urlForLoggingMedia(mediaURL).utf8().data());
-#endif
+ NOTICE_LOG(THIS, " = ", mediaURL);
return mediaURL;
@@ -4526,7 +4516,7 @@
#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, failed", this, m_currentSourceNode.get());
+ NOTICE_LOG(THIS, "failed");
#endif
return URL();
}
@@ -4533,14 +4523,10 @@
void HTMLMediaElement::sourceWasAdded(HTMLSourceElement& source)
{
- LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - %p", this, &source);
-
-#if !LOG_DISABLED
- if (source.hasTagName(sourceTag)) {
+ if (willLog(WTFLogLevelNotice) && source.hasTagName(sourceTag)) {
URL url = ""
- LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
+ NOTICE_LOG(THIS, "'src' is ", url);
}
-#endif
// We should only consider a <source> element when there is not src attribute at all.
if (hasAttributeWithoutSynchronization(srcAttr))
@@ -4559,7 +4545,7 @@
}
if (m_currentSourceNode && &source == Traversal<HTMLSourceElement>::nextSibling(*m_currentSourceNode)) {
- LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this);
+ NOTICE_LOG(THIS, "<source> inserted immediately after current source");
m_nextChildNodeToConsider = &source;
return;
}
@@ -4584,14 +4570,10 @@
void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement& source)
{
- LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p) - %p", this, &source);
-
-#if !LOG_DISABLED
- if (source.hasTagName(sourceTag)) {
+ if (willLog(WTFLogLevelNotice) && source.hasTagName(sourceTag)) {
URL url = ""
- LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
+ NOTICE_LOG(THIS, "'src' is ", url);
}
-#endif
if (&source != m_currentSourceNode && &source != m_nextChildNodeToConsider)
return;
@@ -4598,19 +4580,19 @@
if (&source == m_nextChildNodeToConsider) {
m_nextChildNodeToConsider = m_currentSourceNode ? Traversal<HTMLSourceElement>::nextSibling(*m_currentSourceNode) : nullptr;
- LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToConsider set to %p", this, m_nextChildNodeToConsider.get());
+ NOTICE_LOG(THIS);
} else if (&source == m_currentSourceNode) {
// Clear the current source node pointer, but don't change the movie as the spec says:
// 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
// inserted in a video or audio element will have no effect.
m_currentSourceNode = nullptr;
- LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNode set to 0", this);
+ NOTICE_LOG(THIS, "m_currentSourceNode set to 0");
}
}
void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
+ NOTICE_LOG(THIS);
#if ENABLE(VIDEO_TRACK)
updateActiveTextTrackCues(currentMediaTime());
@@ -4738,7 +4720,7 @@
void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerVolumeChanged(%p)", this);
+ NOTICE_LOG(THIS);
beginProcessingMediaPlayerCallback();
if (m_player) {
@@ -4754,7 +4736,7 @@
void HTMLMediaElement::mediaPlayerMuteChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerMuteChanged(%p)", this);
+ NOTICE_LOG(THIS);
beginProcessingMediaPlayerCallback();
if (m_player)
@@ -4764,7 +4746,7 @@
void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer* player)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this);
+ NOTICE_LOG(THIS);
beginProcessingMediaPlayerCallback();
@@ -4787,7 +4769,7 @@
// using (eg. it can't handle the rate we set)
m_reportedPlaybackRate = m_player->rate();
- LOG(Media, "HTMLMediaElement::mediaPlayerRateChanged(%p) - rate: %lf", this, m_reportedPlaybackRate);
+ NOTICE_LOG(THIS, "rate: ", m_reportedPlaybackRate);
if (m_playing)
invalidateCachedTime();
@@ -4799,7 +4781,7 @@
void HTMLMediaElement::mediaPlayerPlaybackStateChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this);
+ NOTICE_LOG(THIS);
if (!m_player || m_pausedInternal)
return;
@@ -4814,7 +4796,7 @@
void HTMLMediaElement::mediaPlayerSawUnsupportedTracks(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerSawUnsupportedTracks(%p)", this);
+ NOTICE_LOG(THIS);
// The MediaPlayer came across content it cannot completely handle.
// This is normally acceptable except when we are in a standalone
@@ -4825,7 +4807,7 @@
void HTMLMediaElement::mediaPlayerResourceNotSupported(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerResourceNotSupported(%p)", this);
+ NOTICE_LOG(THIS);
// The MediaPlayer came across content which no installed engine supports.
mediaLoadingFailed(MediaPlayer::FormatError);
@@ -4843,7 +4825,7 @@
void HTMLMediaElement::mediaPlayerSizeChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
+ NOTICE_LOG(THIS);
if (is<MediaDocument>(document()) && m_player)
downcast<MediaDocument>(document()).mediaElementNaturalSizeChanged(expandedIntSize(m_player->naturalSize()));
@@ -4864,7 +4846,7 @@
void HTMLMediaElement::mediaPlayerRenderingModeChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerRenderingModeChanged(%p)", this);
+ NOTICE_LOG(THIS);
// Kick off a fake recalcStyle that will update the compositing tree.
invalidateStyleAndLayerComposition();
@@ -4889,7 +4871,7 @@
void HTMLMediaElement::mediaEngineWasUpdated()
{
- LOG(Media, "HTMLMediaElement::mediaEngineWasUpdated(%p)", this);
+ NOTICE_LOG(THIS);
beginProcessingMediaPlayerCallback();
updateRenderer();
endProcessingMediaPlayerCallback();
@@ -4919,7 +4901,7 @@
void HTMLMediaElement::mediaPlayerEngineUpdated(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerEngineUpdated(%p)", this);
+ NOTICE_LOG(THIS);
#if ENABLE(MEDIA_SOURCE)
m_droppedVideoFrames = 0;
@@ -4932,7 +4914,7 @@
void HTMLMediaElement::mediaPlayerFirstVideoFrameAvailable(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerFirstVideoFrameAvailable(%p) - current display mode = %i", this, (int)displayMode());
+ NOTICE_LOG(THIS, "current display mode = ", (int)displayMode());
beginProcessingMediaPlayerCallback();
if (displayMode() == PosterWaitingForVideo) {
@@ -4944,7 +4926,7 @@
void HTMLMediaElement::mediaPlayerCharacteristicChanged(MediaPlayer*)
{
- LOG(Media, "HTMLMediaElement::mediaPlayerCharacteristicChanged(%p)", this);
+ NOTICE_LOG(THIS);
beginProcessingMediaPlayerCallback();
@@ -5194,7 +5176,7 @@
bool shouldBePlaying = potentiallyPlaying();
bool playerPaused = m_player->paused();
- LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s, playerPaused = %s", this, boolString(shouldBePlaying), boolString(playerPaused));
+ NOTICE_LOG(THIS, "shouldBePlaying = ", shouldBePlaying, " playerPaused = ", playerPaused);
if (shouldBePlaying) {
scheduleUpdatePlaybackControlsManager();
@@ -5290,7 +5272,7 @@
void HTMLMediaElement::userCancelledLoad()
{
- LOG(Media, "HTMLMediaElement::userCancelledLoad(%p)", this);
+ NOTICE_LOG(THIS);
// FIXME: We should look to reconcile the iOS and non-iOS code (below).
#if PLATFORM(IOS)
@@ -5343,7 +5325,7 @@
void HTMLMediaElement::clearMediaPlayer(DelayedActionType flags)
{
- LOG(Media, "HTMLMediaElement::clearMediaPlayer(%p) - flags = %s", this, actionName(flags).utf8().data());
+ NOTICE_LOG(THIS, "flags = ", actionName(flags));
#if ENABLE(MEDIA_STREAM)
if (!m_settingMediaStreamSrcObject)
@@ -5418,7 +5400,7 @@
void HTMLMediaElement::stopWithoutDestroyingMediaPlayer()
{
- LOG(Media, "HTMLMediaElement::stopWithoutDestroyingMediaPlayer(%p)", this);
+ NOTICE_LOG(THIS);
if (m_videoFullscreenMode != VideoFullscreenModeNone)
exitFullscreen();
@@ -5462,7 +5444,7 @@
void HTMLMediaElement::stop()
{
- LOG(Media, "HTMLMediaElement::stop(%p)", this);
+ NOTICE_LOG(THIS);
Ref<HTMLMediaElement> protectedThis(*this);
stopWithoutDestroyingMediaPlayer();
@@ -5482,7 +5464,7 @@
void HTMLMediaElement::suspend(ReasonForSuspension why)
{
- LOG(Media, "HTMLMediaElement::suspend(%p)", this);
+ NOTICE_LOG(THIS);
Ref<HTMLMediaElement> protectedThis(*this);
switch (why)
@@ -5503,7 +5485,7 @@
void HTMLMediaElement::resume()
{
- LOG(Media, "HTMLMediaElement::resume(%p)", this);
+ NOTICE_LOG(THIS);
m_inActiveDocument = true;
@@ -5537,7 +5519,7 @@
void HTMLMediaElement::mediaVolumeDidChange()
{
- LOG(Media, "HTMLMediaElement::mediaVolumeDidChange(%p)", this);
+ NOTICE_LOG(THIS);
updateVolume();
}
@@ -5544,7 +5526,7 @@
void HTMLMediaElement::visibilityStateChanged()
{
m_elementIsHidden = document().hidden() && m_videoFullscreenMode != VideoFullscreenModePictureInPicture;
- LOG(Media, "HTMLMediaElement::visibilityStateChanged(%p) - visible = %s", this, boolString(!m_elementIsHidden));
+ NOTICE_LOG(THIS, "visible = ", !m_elementIsHidden);
updateSleepDisabling();
m_mediaSession->visibilityChanged();
if (m_player)
@@ -5553,10 +5535,10 @@
bool isPlayingAudio = isPlaying() && hasAudio() && !muted() && volume();
if (!isPlayingAudio) {
if (m_elementIsHidden) {
- RELEASE_LOG_IF_ALLOWED("visibilityStateChanged() Suspending playback after going to the background");
+ ALWAYS_LOG(THIS, "visibilityStateChanged() Suspending playback after going to the background");
m_mediaSession->beginInterruption(PlatformMediaSession::EnteringBackground);
} else {
- RELEASE_LOG_IF_ALLOWED("visibilityStateChanged() Resuming playback after entering foreground");
+ ALWAYS_LOG(THIS, "visibilityStateChanged() Resuming playback after entering foreground");
m_mediaSession->endInterruption(PlatformMediaSession::MayResumePlaying);
}
}
@@ -5584,7 +5566,7 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
void HTMLMediaElement::webkitShowPlaybackTargetPicker()
{
- LOG(Media, "HTMLMediaElement::webkitShowPlaybackTargetPicker(%p)", this);
+ NOTICE_LOG(THIS);
if (processingUserGestureForMedia())
removeBehaviorsRestrictionsAfterFirstUserGesture();
m_mediaSession->showPlaybackTargetPicker(*this);
@@ -5604,7 +5586,7 @@
{
m_isPlayingToWirelessTarget = m_player && m_player->isCurrentPlaybackTargetWireless();
- LOG(Media, "HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged(%p) - webkitCurrentPlaybackTargetIsWireless = %s", this, boolString(m_isPlayingToWirelessTarget));
+ NOTICE_LOG(THIS, "webkitCurrentPlaybackTargetIsWireless = ", m_isPlayingToWirelessTarget);
ASSERT(m_player);
configureMediaControls();
scheduleEvent(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent);
@@ -5620,6 +5602,9 @@
m_failedToPlayToWirelessTarget = false;
scheduleDelayedAction(CheckPlaybackTargetCompatablity);
}
+
+ DEBUG_LOG(THIS, "dispatching '", event.type(), "'");
+
return HTMLElement::dispatchEvent(event);
}
@@ -5637,7 +5622,7 @@
m_mediaSession->setHasPlaybackTargetAvailabilityListeners(*this, true);
}
- LOG(Media, "HTMLMediaElement::addEventListener(%p) - 'webkitplaybacktargetavailabilitychanged'", this);
+ NOTICE_LOG(THIS, "'webkitplaybacktargetavailabilitychanged'");
enqueuePlaybackTargetAvailabilityChangedEvent(); // Ensure the event listener gets at least one event.
return true;
@@ -5652,7 +5637,7 @@
return false;
bool didRemoveLastAvailabilityChangedListener = !hasEventListeners(eventNames().webkitplaybacktargetavailabilitychangedEvent);
- LOG(Media, "HTMLMediaElement::removeEventListener(%p) - removed last listener = %s", this, boolString(didRemoveLastAvailabilityChangedListener));
+ NOTICE_LOG(THIS, "removed last listener = ", didRemoveLastAvailabilityChangedListener);
if (didRemoveLastAvailabilityChangedListener) {
m_hasPlaybackTargetAvailabilityListeners = false;
m_mediaSession->setHasPlaybackTargetAvailabilityListeners(*this, false);
@@ -5665,7 +5650,7 @@
void HTMLMediaElement::enqueuePlaybackTargetAvailabilityChangedEvent()
{
bool hasTargets = m_mediaSession->hasWirelessPlaybackTargets(*this);
- LOG(Media, "HTMLMediaElement::enqueuePlaybackTargetAvailabilityChangedEvent(%p) - hasTargets = %s", this, boolString(hasTargets));
+ NOTICE_LOG(THIS, "hasTargets = ", hasTargets);
auto event = WebKitPlaybackTargetAvailabilityEvent::create(eventNames().webkitplaybacktargetavailabilitychangedEvent, hasTargets);
event->setTarget(this);
m_asyncEventQueue.enqueueEvent(WTFMove(event));
@@ -5674,7 +5659,7 @@
void HTMLMediaElement::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& device)
{
- LOG(Media, "HTMLMediaElement::setWirelessPlaybackTarget(%p)", this);
+ NOTICE_LOG(THIS);
if (m_player)
m_player->setWirelessPlaybackTarget(WTFMove(device));
}
@@ -5683,7 +5668,7 @@
{
bool canPlay = m_player && m_player->canPlayToWirelessPlaybackTarget();
- LOG(Media, "HTMLMediaElement::canPlayToWirelessPlaybackTarget(%p) - returning %s", this, boolString(canPlay));
+ NOTICE_LOG(THIS, "returning ", canPlay);
return canPlay;
}
@@ -5695,7 +5680,7 @@
void HTMLMediaElement::setShouldPlayToPlaybackTarget(bool shouldPlay)
{
- LOG(Media, "HTMLMediaElement::setShouldPlayToPlaybackTarget(%p) - shouldPlay = %s", this, boolString(shouldPlay));
+ NOTICE_LOG(THIS, "shouldPlay = ", shouldPlay);
if (m_player)
m_player->setShouldPlayToPlaybackTarget(shouldPlay);
@@ -5744,8 +5729,6 @@
void HTMLMediaElement::toggleStandardFullscreenState()
{
- LOG(Media, "HTMLMediaElement::toggleStandardFullscreenState(%p) - isStandardFullscreen() is %s", this, boolString(isStandardFullscreen()));
-
if (isStandardFullscreen())
exitFullscreen();
else
@@ -5754,7 +5737,7 @@
void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
{
- LOG(Media, "HTMLMediaElement::enterFullscreen(%p)", this);
+ NOTICE_LOG(THIS);
ASSERT(mode != VideoFullscreenModeNone);
if (m_videoFullscreenMode == mode)
@@ -5799,7 +5782,7 @@
void HTMLMediaElement::exitFullscreen()
{
- LOG(Media, "HTMLMediaElement::exitFullscreen(%p)", this);
+ NOTICE_LOG(THIS);
#if ENABLE(FULLSCREEN_API)
if (document().settings().fullScreenEnabled() && document().webkitCurrentFullScreenElement() == this) {
@@ -6005,7 +5988,7 @@
void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
{
- LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p) - %s", this, boolString(closedCaptionVisible));
+ NOTICE_LOG(THIS, closedCaptionVisible);
m_closedCaptionsVisible = false;
@@ -6060,8 +6043,7 @@
void HTMLMediaElement::mediaCanStart(Document& document)
{
ASSERT_UNUSED(document, &document == &this->document());
- LOG(Media, "HTMLMediaElement::mediaCanStart(%p) - m_isWaitingUntilMediaCanStart = %s, m_pausedInternal = %s",
- this, boolString(m_isWaitingUntilMediaCanStart), boolString(m_pausedInternal) );
+ NOTICE_LOG(THIS, "m_isWaitingUntilMediaCanStart = ", m_isWaitingUntilMediaCanStart, ", m_pausedInternal = ", m_pausedInternal);
ASSERT(m_isWaitingUntilMediaCanStart || m_pausedInternal);
if (m_isWaitingUntilMediaCanStart) {
@@ -6082,7 +6064,7 @@
if (m_shouldDelayLoadEvent == shouldDelay)
return;
- LOG(Media, "HTMLMediaElement::setShouldDelayLoadEvent(%p) - %s", this, boolString(shouldDelay));
+ NOTICE_LOG(THIS, shouldDelay);
m_shouldDelayLoadEvent = shouldDelay;
if (shouldDelay)
@@ -6133,7 +6115,6 @@
return;
bool privateMode = document().page() && document().page()->usesEphemeralSession();
- LOG(Media, "HTMLMediaElement::privateBrowsingStateDidChange(%p) - %s", this, boolString(privateMode));
m_player->setPrivateBrowsingMode(privateMode);
}
@@ -6315,7 +6296,7 @@
if (!m_textTracks)
return;
- LOG(Media, "HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured(%p)", this);
+ NOTICE_LOG(THIS);
// Mark all tracks as not "configured" so that configureTextTracks()
// will reconsider which tracks to display in light of new user preferences
@@ -6341,7 +6322,7 @@
void HTMLMediaElement::createMediaPlayer()
{
- LOG(Media, "HTMLMediaElement::createMediaPlayer(%p)", this);
+ NOTICE_LOG(THIS);
#if ENABLE(WEB_AUDIO)
if (m_audioSourceNode)
@@ -6947,7 +6928,7 @@
bool HTMLMediaElement::ensureMediaControlsInjectedScript()
{
- LOG(Media, "HTMLMediaElement::ensureMediaControlsInjectedScript(%p)", this);
+ DEBUG_LOG(THIS);
Page* page = document().page();
if (!page)
return false;
@@ -7024,7 +7005,7 @@
void HTMLMediaElement::didAddUserAgentShadowRoot(ShadowRoot* root)
{
- LOG(Media, "HTMLMediaElement::didAddUserAgentShadowRoot(%p)", this);
+ DEBUG_LOG(THIS);
Page* page = document().page();
if (!page)
@@ -7107,10 +7088,10 @@
void HTMLMediaElement::setMediaControlsDependOnPageScaleFactor(bool dependsOnPageScale)
{
- LOG(Media, "MediaElement::setMediaControlsDependPageScaleFactor(%p) = %s", this, boolString(dependsOnPageScale));
+ DEBUG_LOG(THIS, "MediaElement::setMediaControlsDependPageScaleFactor", dependsOnPageScale);
if (document().settings().mediaControlsScaleWithPageZoom()) {
- LOG(Media, "MediaElement::setMediaControlsDependPageScaleFactor(%p) forced to false by Settings value", this);
+ DEBUG_LOG(THIS, "MediaElement::setMediaControlsDependPageScaleFactor", "forced to false by Settings value");
m_mediaControlsDependOnPageScaleFactor = false;
return;
}
@@ -7291,7 +7272,7 @@
void HTMLMediaElement::suspendPlayback()
{
- LOG(Media, "HTMLMediaElement::suspendPlayback(%p) - paused = %s", this, boolString(paused()));
+ NOTICE_LOG(THIS, "paused = ", paused());
if (!paused())
pause();
}
@@ -7298,7 +7279,7 @@
void HTMLMediaElement::resumeAutoplaying()
{
- LOG(Media, "HTMLMediaElement::resumeAutoplaying(%p) - paused = %s", this, boolString(paused()));
+ NOTICE_LOG(THIS, "paused = ", paused());
m_autoplaying = true;
if (canTransitionFromAutoplayToPlay())
@@ -7307,7 +7288,7 @@
void HTMLMediaElement::mayResumePlayback(bool shouldResume)
{
- LOG(Media, "HTMLMediaElement::mayResumePlayback(%p) - paused = %s", this, boolString(paused()));
+ NOTICE_LOG(THIS, "paused = ", paused());
if (paused() && shouldResume)
play();
}
@@ -7322,7 +7303,7 @@
void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
{
- LOG(Media, "HTMLMediaElement::didReceiveRemoteControlCommand(%p) - %i", this, static_cast<int>(command));
+ NOTICE_LOG(THIS, static_cast<int>(command));
UserGestureIndicator remoteControlUserGesture(ProcessingUserGesture, &document());
switch (command) {
@@ -7375,7 +7356,7 @@
if (type == PlatformMediaSession::EnteringBackground) {
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
if (m_isPlayingToWirelessTarget) {
- LOG(Media, "HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(%p) - returning true because m_isPlayingToWirelessTarget is true", this);
+ NOTICE_LOG(THIS, "returning true because m_isPlayingToWirelessTarget is true");
return true;
}
#endif
@@ -7388,7 +7369,7 @@
} else if (type == PlatformMediaSession::SuspendedUnderLock) {
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
if (m_isPlayingToWirelessTarget) {
- LOG(Media, "HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(%p) - returning true because m_isPlayingToWirelessTarget is true", this);
+ NOTICE_LOG(THIS, "returning true because m_isPlayingToWirelessTarget is true");
return true;
}
#endif
@@ -7549,7 +7530,7 @@
return;
if (m_isPlayingToWirelessTarget) {
- LOG(Media, "HTMLMediaElement::purgeBufferedDataIfPossible(%p) - early return because m_isPlayingToWirelessTarget is true", this);
+ NOTICE_LOG(THIS, "early return because playing to wireless target");
return;
}
@@ -7556,6 +7537,7 @@
// This is called to relieve memory pressure. Turning off buffering causes the media playback
// daemon to release memory associated with queued-up video frames.
// We turn it back on right away, but new frames won't get loaded unless playback is resumed.
+ NOTICE_LOG(THIS, "toggling data buffering");
setShouldBufferData(false);
setShouldBufferData(true);
#endif
@@ -7755,6 +7737,23 @@
scheduleUpdatePlaybackControlsManager();
}
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& HTMLMediaElement::logChannel() const
+{
+ return LogMedia;
}
+#endif
+bool HTMLMediaElement::willLog(WTFLogLevel level) const
+{
+#if !RELEASE_LOG_DISABLED
+ return m_logger->willLog(logChannel(), level);
+#else
+ UNUSED_PARAM(level);
+ return false;
#endif
+}
+
+}
+
+#endif