HISE Crash Reporter
-
Has HISE crashed on you? Of course it has. Did it report anything to operating system? Of course not…where would the mystery be? Here to spoil all the fun is a crash reporter. So, at least you're not gaslit when you could swear HISE vanished from your screen. I'm on macOS, so no idea about other operating systems and I don't care.
Save the below as crash-handler.patch, then run git apply crash-handler.patch.
diff --git a/hi_backend/backend/BackendProcessor.cpp b/hi_backend/backend/BackendProcessor.cpp index 3b45c6d2e..95b42bc1a 100644 --- a/hi_backend/backend/BackendProcessor.cpp +++ b/hi_backend/backend/BackendProcessor.cpp @@ -49,6 +49,47 @@ void printData() namespace hise { using namespace juce; +namespace +{ +void installBackendCrashHandler() +{ + static bool installed = false; + + if (installed) + return; + + installed = true; + + SystemStats::setApplicationCrashHandler([](void*) + { + static bool handling = false; + + if (handling) + return; + + handling = true; + + auto crashDir = File::getSpecialLocation(File::userApplicationDataDirectory) + .getChildFile("HISE") + .getChildFile("CrashLogs"); + + crashDir.createDirectory(); + + auto logFile = crashDir.getChildFile("HISE_CrashBacktrace.txt"); + FileOutputStream stream(logFile); + + if (stream.openedOk()) + { + stream.setPosition(logFile.getSize()); + stream << "----\n"; + stream << Time::getCurrentTime().toString(true, true) << "\n"; + stream << SystemStats::getStackBacktrace() << "\n"; + stream.flush(); + } + }); +} +} + @@ -274,6 +315,8 @@ BackendProcessor::BackendProcessor(AudioDeviceManager *deviceManager_/*=nullptr* autosaver(this), pluginParameterRamp(this) { + installBackendCrashHandler(); + //printData();
This writes crashes to ~/Library/Application Support/HISE/CrashLogs/HISE_CrashBacktrace.txt
-
@clevername27 doesn't macOS write the crash reports already automatically?
-
@Christoph-Hart It doesn't always. I'll do a little more research, and post info on why. It's Apple's way of saying, "We're Apple, and we don't think you need to worry about this. Because we're Apple."
-
@Christoph-Hart So…macOS only reports crashes that terminate the process via an unhandled exception/signal. It might not read it's head because one (or more) of these applied:
- HISE/JUCE intercepts the crash (custom crash handler) and exits cleanly, so CrashReporter never triggers.
- Running under Xcode/LLDB suppresses the system crash dialog and routes it to the debugger.
- It wasn’t a crash (hang, forced quit, graceful shutdown) → no CrashReporter event.
Reports are silent even when generated; they live in ~/Library/Logs/DiagnosticReports (visible in Console.app) and may not show a dialog.
That’s why the custom crash logger is useful: it captures a backtrace even when macOS doesn’t show or generate a report.
-
@clevername27 but 2 of the three reasons don't require a custom crash report (no crash => nothing to report. Running under debugger => even better diagnostics) and you're deliberately introducing the first reason with your custom crash handler :)