Skip to content

Commit

Permalink
Bug 1675409 - Migrated TextMarkerPayload to Markers 2.0 API - r=gregt…
Browse files Browse the repository at this point in the history
  • Loading branch information
squelart committed Nov 17, 2020
1 parent e645cc8 commit 0a555dd
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 176 deletions.
22 changes: 14 additions & 8 deletions dom/base/TimeoutManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,13 @@ void TimeoutManager::MoveIdleToActive() {
int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()),
int(delta.ToMilliseconds()));
// don't have end before start...
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"setTimeout deferred release", DOM, TextMarkerPayload,
(marker, delta.ToMilliseconds() >= 0 ? timeout->When() : now, now,
Some(mWindow.WindowID())));
PROFILER_MARKER_TEXT(
"setTimeout deferred release", DOM,
MarkerOptions(
MarkerTiming::Interval(
delta.ToMilliseconds() >= 0 ? timeout->When() : now, now),
MarkerInnerWindowId(mWindow.WindowID())),
marker);
}
#endif
num++;
Expand Down Expand Up @@ -905,10 +908,13 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow,
int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()),
int(delta.ToMilliseconds()), int(runtime.ToMilliseconds()));
// don't have end before start...
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"setTimeout", DOM, TextMarkerPayload,
(marker, delta.ToMilliseconds() >= 0 ? timeout->When() : now, now,
Some(mWindow.WindowID())));
PROFILER_MARKER_TEXT(
"setTimeout", DOM,
MarkerOptions(
MarkerTiming::Interval(
delta.ToMilliseconds() >= 0 ? timeout->When() : now, now),
MarkerInnerWindowId(mWindow.WindowID())),
marker);
}
#endif

Expand Down
55 changes: 35 additions & 20 deletions dom/base/nsDOMNavigationTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ void nsDOMNavigationTiming::NotifyLoadEventEnd() {
"Document %s loaded after %dms, load event duration %dms", spec.get(),
int(elapsed.ToMilliseconds()), int(duration.ToMilliseconds()));
PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"DocumentLoad", DOM, TextMarkerPayload,
(marker, mNavigationStart, mLoadEventEnd,
profiler_get_inner_window_id_from_docshell(mDocShell)));
PROFILER_MARKER_TEXT(
"DocumentLoad", DOM,
MarkerOptions(
MarkerTiming::Interval(mNavigationStart, mLoadEventEnd),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
}
#endif
TimeStamp loadEventEnd = TimeStamp::Now();
Expand Down Expand Up @@ -377,10 +380,13 @@ void nsDOMNavigationTiming::TTITimeout(nsITimer* aTimer) {
int(elapsed.ToMilliseconds()),
int(elapsedLongTask.ToMilliseconds()), spec.get());

PROFILER_ADD_MARKER_WITH_PAYLOAD(
"TimeToFirstInteractive (TTFI)", DOM, TextMarkerPayload,
(marker, mNavigationStart, mTTFI,
profiler_get_inner_window_id_from_docshell(mDocShell)));
PROFILER_MARKER_TEXT(
"TimeToFirstInteractive (TTFI)", DOM,
MarkerOptions(
MarkerTiming::Interval(mNavigationStart, mTTFI),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
}
#endif
}
Expand Down Expand Up @@ -410,10 +416,13 @@ void nsDOMNavigationTiming::NotifyNonBlankPaintForRootContentDocument() {
: "this tab was inactive some of the time between navigation start "
"and first non-blank paint");
PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"FirstNonBlankPaint", DOM, TextMarkerPayload,
(marker, mNavigationStart, mNonBlankPaint,
profiler_get_inner_window_id_from_docshell(mDocShell)));
PROFILER_MARKER_TEXT(
"FirstNonBlankPaint", DOM,
MarkerOptions(
MarkerTiming::Interval(mNavigationStart, mNonBlankPaint),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
}
#endif

Expand Down Expand Up @@ -459,10 +468,13 @@ void nsDOMNavigationTiming::NotifyContentfulPaintForRootContentDocument(
: "this tab was inactive some of the time between navigation start "
"and first non-blank paint");
PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"FirstContentfulPaint", DOM, TextMarkerPayload,
(marker, mNavigationStart, mContentfulPaint,
profiler_get_inner_window_id_from_docshell(mDocShell)));
PROFILER_MARKER_TEXT(
"FirstContentfulPaint", DOM,
MarkerOptions(
MarkerTiming::Interval(mNavigationStart, mContentfulPaint),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
}
#endif

Expand Down Expand Up @@ -508,10 +520,13 @@ void nsDOMNavigationTiming::NotifyDOMContentFlushedForRootContentDocument() {
: "this tab was inactive some of the time between navigation start "
"and DOMContentFlushed");
PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"DOMContentFlushed", DOM, TextMarkerPayload,
(marker, mNavigationStart, mDOMContentFlushed,
profiler_get_inner_window_id_from_docshell(mDocShell)));
PROFILER_MARKER_TEXT(
"DOMContentFlushed", DOM,
MarkerOptions(
MarkerTiming::Interval(mNavigationStart, mDOMContentFlushed),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
}
#endif
}
Expand Down
19 changes: 7 additions & 12 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
if (profiler_thread_is_being_profiled()) {
nsPrintfCString marker("Reused process %u",
(unsigned int)retval->ChildID());
TimeStamp now = TimeStamp::Now();
PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload,
(marker, now, now));
PROFILER_MARKER_TEXT("Process", DOM, {}, marker);
}
#endif
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
Expand Down Expand Up @@ -959,9 +957,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
if (profiler_thread_is_being_profiled()) {
nsPrintfCString marker("Recycled process %u (%p)",
(unsigned int)recycled->ChildID(), recycled.get());
TimeStamp now = TimeStamp::Now();
PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload,
(marker, now, now));
PROFILER_MARKER_TEXT("Process", DOM, {}, marker);
}
#endif
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
Expand All @@ -984,9 +980,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
if (profiler_thread_is_being_profiled()) {
nsPrintfCString marker("Assigned preallocated process %u",
(unsigned int)preallocated->ChildID());
TimeStamp now = TimeStamp::Now();
PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload,
(marker, now, now));
PROFILER_MARKER_TEXT("Process", DOM, {}, marker);
}
#endif
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
Expand Down Expand Up @@ -2423,9 +2417,10 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync,
nsPrintfCString marker("Process start%s for %u",
mIsAPreallocBlocker ? " (immediate)" : "",
(unsigned int)ChildID());
PROFILER_ADD_MARKER_WITH_PAYLOAD(
mIsAPreallocBlocker ? "Process Immediate Launch" : "Process Launch",
DOM, TextMarkerPayload, (marker, mLaunchTS, launchResumeTS));
PROFILER_MARKER_TEXT(
mIsAPreallocBlocker ? ProfilerString8View("Process Immediate Launch")
: ProfilerString8View("Process Launch"),
DOM, MarkerTiming::Interval(mLaunchTS, launchResumeTS), marker);
}
#endif

Expand Down
15 changes: 5 additions & 10 deletions dom/media/MediaDecoderStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "mozilla/Logging.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/NotNull.h"
#include "mozilla/ProfilerMarkerTypes.h"
#include "mozilla/SharedThreadPool.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_media.h"
Expand All @@ -28,6 +27,7 @@
#include "AudioSegment.h"
#include "DOMMediaStream.h"
#include "ImageContainer.h"
#include "GeckoProfiler.h"
#include "MediaDecoder.h"
#include "MediaDecoderStateMachine.h"
#include "MediaShutdownManager.h"
Expand All @@ -39,13 +39,8 @@
#include "VideoUtils.h"

#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define MDSM_ERROR_MARKER(tag, error, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(error, markerTime))
#else
# define MDSM_ERROR_MARKER(tag, error, markerTime)
#endif
# include "mozilla/ProfilerMarkerTypes.h"
#endif // MOZ_GECKO_PROFILER

namespace mozilla {

Expand Down Expand Up @@ -3468,8 +3463,8 @@ bool MediaDecoderStateMachine::HasLowBufferedData(const TimeUnit& aThreshold) {
void MediaDecoderStateMachine::DecodeError(const MediaResult& aError) {
MOZ_ASSERT(OnTaskQueue());
LOGE("Decode error: %s", aError.Description().get());
MDSM_ERROR_MARKER("MDSM::DecodeError", aError.Description(),
TimeStamp::NowUnfuzzed());
PROFILER_MARKER_TEXT("MDSM::DecodeError", MEDIA_PLAYBACK, {},
aError.Description());
// Notify the decode error and MediaDecoder will shut down MDSM.
mOnPlaybackErrorEvent.Notify(aError);
}
Expand Down
13 changes: 1 addition & 12 deletions dom/media/MediaFormatReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ mozilla::LazyLogModule gMediaDemuxerLog("MediaDemuxer");
DDMOZ_LOG(sFormatDecoderLog, mozilla::LogLevel::Verbose, "::%s: " arg, \
__func__, ##__VA_ARGS__)

#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define MEDIA_FORMAT_READER_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define MEDIA_FORMAT_READER_STATUS_MARKER(tag, text, markerTime)
#endif

#define NS_DispatchToMainThread(...) CompileError_UseAbstractMainThreadInstead

namespace mozilla {
Expand Down Expand Up @@ -1933,8 +1924,7 @@ void MediaFormatReader::HandleDemuxedSamples(
nsPrintfCString markerString(
"%s stream id changed from:%" PRIu32 " to:%" PRIu32,
TrackTypeToStr(aTrack), decoder.mLastStreamSourceID, info->GetID());
MEDIA_FORMAT_READER_STATUS_MARKER("StreamID Change", markerString,
TimeStamp::NowUnfuzzed());
PROFILER_MARKER_TEXT("StreamID Change", MEDIA_PLAYBACK, {}, markerString);
LOG("%s", markerString.get());

if (aTrack == TrackInfo::kVideoTrack) {
Expand Down Expand Up @@ -3152,6 +3142,5 @@ void MediaFormatReader::OnFirstDemuxFailed(TrackInfo::TrackType aType,
} // namespace mozilla

#undef NS_DispatchToMainThread
#undef MEDIA_FORMAT_READER_STATUS_MARKER
#undef LOGV
#undef LOG
16 changes: 4 additions & 12 deletions dom/media/platforms/wmf/WMFDecoderModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "mozilla/WindowsVersion.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/mscom/EnsureMTA.h"
#include "mozilla/ProfilerMarkers.h"
#include "nsComponentManagerUtils.h"
#include "nsIXULRuntime.h"
#include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart
Expand All @@ -36,28 +37,19 @@

#define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))

#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define WFM_DECODER_MODULE_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define WFM_DECODER_MODULE_STATUS_MARKER(tag, text, markerTime)
#endif

extern const GUID CLSID_WebmMfVpxDec;

namespace mozilla {

// Helper function to add a profile marker and log at the same time.
static void MOZ_FORMAT_PRINTF(2, 3)
WmfDeocderModuleMarkerAndLog(const char* aTag, const char* aFormat, ...) {
WmfDeocderModuleMarkerAndLog(const ProfilerString8View& aMarkerTag,
const char* aFormat, ...) {
va_list ap;
va_start(ap, aFormat);
const nsVprintfCString markerString(aFormat, ap);
va_end(ap);
WFM_DECODER_MODULE_STATUS_MARKER(aTag, markerString,
TimeStamp::NowUnfuzzed());
PROFILER_MARKER_TEXT(aMarkerTag, MEDIA_PLAYBACK, {}, markerString);
LOG("%s", markerString.get());
}

Expand Down
13 changes: 2 additions & 11 deletions dom/media/platforms/wmf/WMFMediaDataDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@
#include "VideoUtils.h"
#include "WMFUtils.h"
#include "mozilla/Logging.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/Telemetry.h"
#include "nsTArray.h"

#define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))

#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define WFM_MEDIA_DATA_DECODER_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define WFM_MEDIA_DATA_DECODER_STATUS_MARKER(tag, text, markerTime)
#endif

namespace mozilla {

WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager)
Expand Down Expand Up @@ -102,8 +94,7 @@ RefPtr<MediaDataDecoder::DecodePromise> WMFMediaDataDecoder::ProcessError(
"reason: %s",
GetDescriptionName().get(), aReason);
LOG(markerString.get());
WFM_MEDIA_DATA_DECODER_STATUS_MARKER("WMFDecoder Error", markerString,
TimeStamp::NowUnfuzzed());
PROFILER_MARKER_TEXT("WMFDecoder Error", MEDIA_PLAYBACK, {}, markerString);

// TODO: For the error DXGI_ERROR_DEVICE_RESET, we could return
// NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER to get the latest device. Maybe retry
Expand Down
27 changes: 7 additions & 20 deletions dom/media/platforms/wrappers/MediaChangeMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,10 @@
#include "MediaInfo.h"
#include "PDMFactory.h"
#include "VPXDecoder.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/TaskQueue.h"

#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define MEDIA_CHANGE_MONITOR_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define MEDIA_CHANGE_MONITOR_STATUS_MARKER(tag, text, markerTime)
#endif

namespace mozilla {

// H264ChangeMonitor is used to ensure that only AVCC or AnnexB is fed to the
Expand Down Expand Up @@ -98,11 +90,9 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
mPreviousExtraData = aSample->mExtraData;
UpdateConfigFromExtraData(extra_data);

MEDIA_CHANGE_MONITOR_STATUS_MARKER(
"H264 Stream Change",
"H264ChangeMonitor::CheckForChange has detected a change in the "
"stream and will request a new decoder"_ns,
TimeStamp::NowUnfuzzed());
PROFILER_MARKER_TEXT("H264 Stream Change", MEDIA_PLAYBACK, {},
"H264ChangeMonitor::CheckForChange has detected a "
"change in the stream and will request a new decoder");
return NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER;
}

Expand Down Expand Up @@ -204,11 +194,10 @@ class VPXChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
mCurrentConfig.SetImageRect(
gfx::IntRect(0, 0, info.mImage.width, info.mImage.height));

MEDIA_CHANGE_MONITOR_STATUS_MARKER(
"VPX Stream Change",
PROFILER_MARKER_TEXT(
"VPX Stream Change", MEDIA_PLAYBACK, {},
"VPXChangeMonitor::CheckForChange has detected a change in the "
"stream and will request a new decoder"_ns,
TimeStamp::NowUnfuzzed());
"stream and will request a new decoder");
rv = NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER;
}
mInfo = Some(info);
Expand Down Expand Up @@ -755,5 +744,3 @@ void MediaChangeMonitor::FlushThenShutdownDecoder(
}

} // namespace mozilla

#undef MEDIA_CHANGE_MONITOR_STATUS_MARKER
Loading

0 comments on commit 0a555dd

Please sign in to comment.