Skip to content

Commit 5fd2ffa

Browse files
committed
[Mac] add support for Sentry breadcrumbs / warnings /actions
1 parent 7f518ad commit 5fd2ffa

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

obs-studio-server/source/nodeobs_api.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,7 @@ void OBS_API::OBS_API_initAPI(void *data, const int64_t id, const std::vector<ip
885885
before attempting to make a file there. */
886886
if (os_mkdirs(log_path.c_str()) == MKDIR_ERROR) {
887887
std::cerr << "Failed to open log file" << std::endl;
888-
#ifdef WIN32
889888
util::CrashManager::AddWarning("Error on log file, failed to create path: " + log_path);
890-
#endif
891889
}
892890

893891
/* Delete oldest file in the folder to imitate rotating */
@@ -925,7 +923,6 @@ void OBS_API::OBS_API_initAPI(void *data, const int64_t id, const std::vector<ip
925923
}
926924
}
927925

928-
#ifdef WIN32
929926
// Register the pre and post server callbacks to log the data into the crashmanager
930927
g_server->set_pre_callback(
931928
[](std::string cname, std::string fname, const std::vector<ipc::value> &args, void *data) {
@@ -941,7 +938,6 @@ void OBS_API::OBS_API_initAPI(void *data, const int64_t id, const std::vector<ip
941938
&crashManager);
942939

943940
#endif
944-
#endif
945941

946942
#ifdef WIN32
947943
// Connect the metrics provider with our crash handler process, sending our current version tag

obs-studio-server/source/nodeobs_service.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,12 @@ void OBS_service::setupRecordingAudioEncoder(void)
11751175

11761176
AdvancedRecordingAudioEncodersID[i] = "";
11771177
if (!createAudioEncoder(&(AdvancedRecordingAudioTracks[i]), AdvancedRecordingAudioEncodersID[i], id, GetAdvancedAudioBitrate(i),
1178-
nameStream.str().c_str(), i))
1178+
nameStream.str().c_str(), i)) {
1179+
std::ostringstream errorStream;
1180+
errorStream << "audio encoder failed id: " << id << nameStream.str();
1181+
util::CrashManager::AddWarning(errorStream.str());
11791182
throw std::runtime_error("Failed to create audio encoder (advanced output)");
1183+
}
11801184
obs_encoder_set_audio(AdvancedRecordingAudioTracks[i], obs_get_audio());
11811185
}
11821186
}

obs-studio-server/source/util-crashmanager.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@
6969
//////////////////////
7070
// STATIC VARIABLES //
7171
//////////////////////
72+
std::vector<nlohmann::json> breadcrumbs;
73+
std::mutex messageMutex;
74+
std::vector<std::string> warnings;
75+
std::queue<std::pair<int, std::string>> lastActions;
7276
#ifdef WIN32
7377
// Global/static variables
7478
std::vector<std::string> handledOBSCrashes;
7579
PDH_HQUERY cpuQuery;
7680
PDH_HCOUNTER cpuTotal;
77-
std::vector<nlohmann::json> breadcrumbs;
78-
std::queue<std::pair<int, std::string>> lastActions;
79-
std::vector<std::string> warnings;
80-
std::mutex messageMutex;
8181
util::MetricsProvider metricsClient;
8282
LPTOP_LEVEL_EXCEPTION_FILTER crashpadInternalExceptionFilterMethod = nullptr;
8383
HANDLE memoryDumpEvent = INVALID_HANDLE_VALUE;
@@ -998,16 +998,12 @@ nlohmann::json util::CrashManager::RequestOBSLog(OBSLogType type)
998998

999999
nlohmann::json util::CrashManager::ComputeBreadcrumbs()
10001000
{
1001-
#ifdef WIN32
10021001
nlohmann::json result = nlohmann::json::array();
10031002

10041003
for (auto &msg : breadcrumbs)
10051004
result.push_back(msg);
10061005

10071006
return result;
1008-
#else
1009-
return NULL;
1010-
#endif
10111007
}
10121008

10131009
nlohmann::json util::CrashManager::ComputeActions()
@@ -1036,16 +1032,12 @@ nlohmann::json util::CrashManager::ComputeActions()
10361032

10371033
nlohmann::json util::CrashManager::ComputeWarnings()
10381034
{
1039-
#ifdef WIN32
10401035
nlohmann::json result;
10411036

10421037
for (auto &msg : warnings)
10431038
result.push_back(msg);
10441039

10451040
return result;
1046-
#else
1047-
return NULL;
1048-
#endif
10491041
}
10501042

10511043
void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr)
@@ -1203,15 +1195,12 @@ void util::CrashManager::IPCValuesToData(const std::vector<ipc::value> &values,
12031195

12041196
void util::CrashManager::AddWarning(const std::string &warning)
12051197
{
1206-
#ifdef WIN32
12071198
std::lock_guard<std::mutex> lock(messageMutex);
12081199
warnings.push_back(warning);
1209-
#endif
12101200
}
12111201

12121202
void RegisterAction(const std::string &message)
12131203
{
1214-
#ifdef WIN32
12151204
static const int MaximumActionsRegistered = 50;
12161205
std::lock_guard<std::mutex> lock(messageMutex);
12171206

@@ -1224,34 +1213,27 @@ void RegisterAction(const std::string &message)
12241213
lastActions.pop();
12251214
}
12261215
}
1227-
#endif
12281216
}
12291217

12301218
void util::CrashManager::AddBreadcrumb(const nlohmann::json &message)
12311219
{
1232-
#ifdef WIN32
12331220
std::lock_guard<std::mutex> lock(messageMutex);
12341221
breadcrumbs.push_back(message);
1235-
#endif
12361222
}
12371223

12381224
void util::CrashManager::AddBreadcrumb(const std::string &message)
12391225
{
1240-
#ifdef WIN32
12411226
nlohmann::json j = nlohmann::json::array();
12421227
j.push_back({{message}});
12431228

12441229
std::lock_guard<std::mutex> lock(messageMutex);
12451230
breadcrumbs.push_back(j);
1246-
#endif
12471231
}
12481232

12491233
void util::CrashManager::ClearBreadcrumbs()
12501234
{
1251-
#ifdef WIN32
12521235
std::lock_guard<std::mutex> lock(messageMutex);
12531236
breadcrumbs.clear();
1254-
#endif
12551237
}
12561238

12571239
void util::CrashManager::setAppState(const std::string &newState)

0 commit comments

Comments
 (0)