Skip to content

Commit

Permalink
Add tracepoints around WebXR frame rendering
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271474
rdar://125215811

Reviewed by Kimmo Kinnunen.

* Source/WTF/wtf/SystemTracing.h:
* Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:
(WebCore::WebXROpaqueFramebuffer::startFrame):
(WebCore::WebXROpaqueFramebuffer::endFrame):
* Source/WebCore/Modules/webxr/WebXRSession.cpp:
(WebCore::WebXRSession::onFrame):
* Source/WebKit/Resources/Signposts/SystemTracePoints.plist:

Canonical link: https://commits.webkit.org/276571@main
  • Loading branch information
achan00 committed Mar 22, 2024
1 parent 0981e0a commit 8025107
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/WTF/wtf/SystemTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ enum TracePointCode {
RenderTreeLayoutEnd,
PerformOpportunisticallyScheduledTasksStart,
PerformOpportunisticallyScheduledTasksEnd,
WebXRLayerStartFrameStart,
WebXRLayerStartFrameEnd,
WebXRLayerEndFrameStart,
WebXRLayerEndFrameEnd,
WebXRSessionFrameCallbacksStart,
WebXRSessionFrameCallbacksEnd,

WebKitRange = 10000,
WebHTMLViewPaintStart,
Expand Down Expand Up @@ -151,6 +157,12 @@ enum TracePointCode {
ProcessLaunchEnd,
InitializeSandboxStart,
InitializeSandboxEnd,
WebXRCPFrameWaitStart,
WebXRCPFrameWaitEnd,
WebXRCPFrameStartSubmissionStart,
WebXRCPFrameStartSubmissionEnd,
WebXRCPFrameEndSubmissionStart,
WebXRCPFrameEndSubmissionEnd,

GPUProcessRange = 16000,
WakeUpAndApplyDisplayListStart,
Expand Down
11 changes: 11 additions & 0 deletions Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "WebGLRenderingContextBase.h"
#include "WebGLUtilities.h"
#include <wtf/Scope.h>
#include <wtf/SystemTracing.h>

#if PLATFORM(COCOA)
#include "GraphicsContextGLCocoa.h"
Expand Down Expand Up @@ -134,6 +135,11 @@ void WebXROpaqueFramebuffer::startFrame(const PlatformXR::FrameData::LayerData&
if (!gl)
return;

tracePoint(WebXRLayerStartFrameStart);
auto scopeExit = makeScopeExit([&]() {
tracePoint(WebXRLayerStartFrameEnd);
});

auto [textureTarget, textureTargetBinding] = gl->externalImageTextureBindingPoint();

ScopedWebGLRestoreFramebuffer restoreFramebuffer { m_context };
Expand Down Expand Up @@ -206,6 +212,11 @@ void WebXROpaqueFramebuffer::endFrame()
if (!gl)
return;

tracePoint(WebXRLayerEndFrameStart);
auto scopeExit = makeScopeExit([&]() {
tracePoint(WebXRLayerEndFrameEnd);
});

if (m_multisampleColorBuffer) {
ScopedWebGLRestoreFramebuffer restoreFramebuffer { m_context };

Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/Modules/webxr/WebXRSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "XRSessionEvent.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/RefPtr.h>
#include <wtf/SystemTracing.h>

namespace WebCore {

Expand Down Expand Up @@ -600,6 +601,7 @@ void WebXRSession::onFrame(PlatformXR::FrameData&& frameData)
if (m_inputInitialized)
m_inputSources->update(now, m_frameData.inputSources);

tracePoint(WebXRSessionFrameCallbacksStart);
// 6.5.For each entry in session’s list of currently running animation frame callbacks, in order:
for (auto& callback : callbacks) {
// 6.6.If the entry’s cancelled boolean is true, continue to the next entry.
Expand All @@ -611,6 +613,8 @@ void WebXRSession::onFrame(PlatformXR::FrameData&& frameData)

// 6.8.If an exception is thrown, report the exception.
}
tracePoint(WebXRSessionFrameCallbacksEnd);

// 6.9.Set session’s list of currently running animation frame callbacks to the empty list.
m_callbacks.removeAllMatching([](auto& callback) {
return callback->isFiredOrCancelled();
Expand Down
72 changes: 72 additions & 0 deletions Source/WebKit/Resources/Signposts/SystemTracePoints.plist
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,42 @@
<string>UInt64</string>
</dict>
</dict>
<dict>
<key>Name</key>
<string>WebXR layer start frame</string>
<key>Type</key>
<string>Interval</string>
<key>Component</key>
<string>47</string>
<key>CodeBegin</key>
<string>5049</string>
<key>CodeEnd</key>
<string>5050</string>
</dict>
<dict>
<key>Name</key>
<string>WebXR layer end frame</string>
<key>Type</key>
<string>Interval</string>
<key>Component</key>
<string>47</string>
<key>CodeBegin</key>
<string>5051</string>
<key>CodeEnd</key>
<string>5052</string>
</dict>
<dict>
<key>Name</key>
<string>WebXR frame render callbacks</string>
<key>Type</key>
<string>Interval</string>
<key>Component</key>
<string>47</string>
<key>CodeBegin</key>
<string>5053</string>
<key>CodeEnd</key>
<string>5054</string>
</dict>
<dict>
<key>Name</key>
<string>Paint WebHTMLView</string>
Expand Down Expand Up @@ -811,6 +847,42 @@
<key>CodeEnd</key>
<string>14006</string>
</dict>
<dict>
<key>Name</key>
<string>WebXR Compositor wait for frame</string>
<key>Type</key>
<string>Interval</string>
<key>Component</key>
<string>47</string>
<key>CodeBegin</key>
<string>14007</string>
<key>CodeEnd</key>
<string>14008</string>
</dict>
<dict>
<key>Name</key>
<string>WebXR Compositor start submission for frame</string>
<key>Type</key>
<string>Interval</string>
<key>Component</key>
<string>47</string>
<key>CodeBegin</key>
<string>14009</string>
<key>CodeEnd</key>
<string>14010</string>
</dict>
<dict>
<key>Name</key>
<string>WebXR Compositor end submission for frame</string>
<key>Type</key>
<string>Interval</string>
<key>Component</key>
<string>47</string>
<key>CodeBegin</key>
<string>14011</string>
<key>CodeEnd</key>
<string>14012</string>
</dict>
<dict>
<key>Name</key>
<string>Wake up and apply display list</string>
Expand Down

0 comments on commit 8025107

Please sign in to comment.