How to Diagnose and Fix Electron Crash Issues in Taobao Live
This article walks through the entire crash‑handling workflow for an Electron‑based Taobao Live client, covering why crashes occur, how to capture minidumps with Crashpad, report them to monitoring platforms, and analyze the dumps using Visual Studio or WinDbg.
01 Background
After months of development, the new Electron‑based Taobao Live streaming software was released, and users began reporting crashes. When an uncaught exception occurs, the application terminates, so this article explains the client‑side crash handling process.
02 How Application Crashes Occur
Windows separates kernel mode and user mode; user‑mode applications like the Taobao Live client run in user mode. When CreateProcess or CreateThread starts a thread, the thread runs the following code (excerpt from “Windows Core Programming”):
// Main thread start function
VOID BaseProcessStart(PPROCESS_START_ROUTINE pfnSatrtAddr)
{
__try {
ExitThread((pfnSatrtAddr)());
}
__except(UnHandledExceptionFilter(GetExceptionInformation())) {
ExitProcess(GetExceptionCode());
}
}
// Thread start function
VOID BaseThreadStart(PTHREAD_START_ROUTINE pfnSatrtAddr, PVOID pvParam)
{
__try {
ExitThread((pfnSatrtAddr)());
}
__except(UnHandledExceptionFilter(GetExceptionInformation())) {
ExitProcess(GetExceptionCode());
}
}If an uncaught exception propagates, UnHandledExceptionFilter generates a dump file. Windows dump files come in two categories: kernel‑mode dumps (e.g., blue‑screen) and user‑mode dumps, which can be full dumps or minidumps. Minidumps are small and easy to transmit.
The following function creates a minidump when a crash is detected:
LONG WINAPI pExceptionFilter(struct _EXCEPTION_POINTERS* pExceptionInfo){
// create dumpfile
HANDLE hFile = ::CreateFile(m_dumpFilePathFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
// set exception info
_MINIDUMP_EXCEPTION_INFORMATION info;
info.ThreadId = ::GetCurrentThreadId();
info.ExceptionPointers = pExceptionInfo;
info.ClientPointers = true;
// generate mini dump contents
::MiniDumpWriteDump(
::GetCurrentProcess(),
::GetCurrentProcessId(),
hFile,
MiniDumpNormal,
&info, NULL, NULL
);
// close file
::CloseHandle(hFile);
return EXCEPTION_EXECUTE_HANDLER;
}03 Capturing and Reporting Crashes
Google’s Breakpad and its successor Crashpad generate minidumps on various platforms. Electron integrates Crashpad, so when the main or renderer process crashes, a minidump is automatically created. Developers can start the built‑in crashReporter with a few lines of JavaScript:
import { crashReporter } from 'electron';
crashReporter.start({
productName: 'YourName',
companyName: 'YourCompany',
submitURL: 'https://your-domain.com/url-to-submit',
uploadToServer: true
});CrashReporter uploads the dump via HTTP/HTTPS. The uploaded binary can be inspected with tools like Wireshark.
04 Monitoring Crashes
Two internal platforms are used: the “Yuyan” real‑time monitoring platform (based on Alipay Mini‑Program IDE best‑practice) and the “Qianniao” platform for desktop clients. Both rely on Electron’s crashReporter to collect minidumps and forward them to the monitoring service.
Yuyan Platform
Provides detailed crash records, stack traces, user environment, and raw payloads. Integration requires only a few lines of JavaScript similar to the previous example.
Qianniao Platform
Offers a wrapper around Crashpad with its own upload endpoint.
05 Analyzing Crashes
After dumps are collected, they can be analyzed online on Yuyan (using electron‑minidump) or locally with Visual Studio or WinDbg Preview. Symbol files (.pdb) from Microsoft, Electron, and the application are needed to resolve function names and source lines.
06 Summary and Outlook
The client‑side crash handling workflow includes understanding why crashes happen, using Crashpad‑based crashReporter to capture and upload minidumps, monitoring them on Yuyan or Qianniao, and finally analyzing dumps with appropriate symbols. Future work may involve a separate watchdog process to automatically restart the Electron app after a crash.
Alipay Experience Technology
Exploring ultimate user experience and best engineering practices
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
