Skip to content

Commit c3f1963

Browse files
authored
Merge pull request #1402 from asarium/fix/profilingAssert
Discard non-main thread events for the frame profiler
2 parents ca9eff3 + 06e9248 commit c3f1963

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

code/tracing/FrameProfiler.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ void FrameProfiler::processEvent(const trace_event* event) {
136136
return;
137137
}
138138

139+
if (_mainThreadID == -1) {
140+
// We need the ID of the main thread to filter out multi threaded events. We just assume that the first event
141+
// of the main process we see is from the main thread. That should be a safe assumption.
142+
_mainThreadID = event->tid;
143+
}
144+
145+
if (event->tid != _mainThreadID) {
146+
// Multithreaded events don't have a deterministic sequence and that confuses the old profiling system
147+
return;
148+
}
149+
139150
if (event->duration == 0) {
140151
// Discard events with no duration
141152
return;

code/tracing/FrameProfiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class FrameProfiler {
4141

4242
SCP_vector<profile_sample_history> history;
4343

44+
std::int64_t _mainThreadID = -1;
45+
4446
SCP_string content;
4547

4648
/**

0 commit comments

Comments
 (0)