Expand description
Crash reports (ADR-0079): a panic hook that writes a
shuyi_platform::crash::CrashReport through the game’s storage, which
run installs before its first frame
(AppConfig::crash).
The hook takes the one before it and calls it after writing, so the
standard library’s message in a terminal and miniquad’s console line on
the web stay. It reads the frame and the top screen run
set (set_frame) and the last lines of the log (note_log), from
statics, so a panic on another thread (the music’s worker) gets them too.
A panic caught on purpose runs in quiet and writes nothing.
A report is fatal when the panic is on the
thread that runs the game, the one run installs the hook from: on
native run catches it and ends the process, or it is outside that
catch and ends it itself; on the web every panic aborts. A panic on
another thread (quad-snd’s own, on a machine with no sound device) is
kept, and not offered to the game as a crash.
On native, run catches a panic of the game’s frame: it stops the sound,
adds the game’s record of its play to the report (add_record) and
ends the process with exit code 101, as an uncaught panic does, without
calling the game’s system hook, so a game in a broken state never saves
over a good save. On the web a panic aborts, so a web report has no
record.
SHUYI_PANIC_AT_FRAME=<n>, read once by run on native in any build,
panics at frame n on purpose (PANIC_ON_PURPOSE), for the tests.
Structs§
- Crash
Reports - Whether
runwrites crash reports, and with what version of the game. Build it withCrashReports::neworCrashReports::off; a game setsAppConfig::crashto it.
Constants§
- PANIC_
ON_ PURPOSE - The message of the panic
SHUYI_PANIC_AT_FRAMEasks for.
Functions§
- add_
record - Adds the game’s record of its play to the report the hook wrote last,
and writes it again under the same key. A record over
shuyi_platform::crash::RECORD_BYTESis left out, and the report’s log says so. Does nothing if no report was written. - install
- Writes reports of every panic from now on, as
reportssays, each through a new storage fromstorage, then calls the hook that was there before. The thread it is called on is the game’s: a panic there isfatal, and one on any other thread isn’t. Installs nothing ifreportskeeps none. Called again, it changes what the hook does, and installs no second hook. - note_
log - Keeps
lineof the log among the lastLOG_LINES, for a report. - quiet
- Runs
fwith reports off on this thread: a panic it catches on purpose is not a crash. - set_
frame - The frame about to run (
App::frame_number() + 1) and the screen on top as it starts, for a report.