mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-18 00:27:06 +02:00
Players reported the game hanging for about a second while skating. A profile showed the memory line in the log walking every heap (HeapSummary) on the client thread, 0.5 to 2 s every two minutes. An audit of everything that runs on the game's update and render threads found more of the same, and Sentry's top crashes had causes of ours. Freezes: - Memory log line: no heap walk or thread snapshot; the GPU part and the write happen on a thread of their own. - Profile database: synchronous=NORMAL in WAL mode. A save is still kept when the game crashes; every play event no longer waits for the disk inside the game's hooks. - ReSkate's own preferences and values (menu clicks, session sliders, Discord) are saved by a background writer in order; reads see a value until it is saved. - Input: the foreground window and the keyboard are sampled on a thread of their own (GetAncestor and GetAsyncKeyState stalled the client tick 40-50 ms when another program held Windows' lock); flight input uses the sample; ClipCursor at most twice a second while a menu has the pointer. - Hooks installed while the game runs go in one transaction per place (HookBatch): throwdowns, remote players, the party, Hall of Meat. - Off the update thread: the host's map package lookup (one table read in the background, not the Mods folder per offer), the trainer's map file and settings save, Board Break's settings save, mod music playlists and their covers, the Spotify station covers. - Off the render thread: the Modding page's and the deck card's Mods folder reads. The overlay's three startup waits share five seconds. - Less work per frame: Steam names reused while one a frame is asked again, 2 friends a tick, steam_api64.dll checked once per process, cosmetic names read in place rather than a system call per character, an outfit load no longer copies the inventory per slot, the throwdown type scan runs at background priority over resident memory, the Board Break deck label is kept a minute. Crashes: - Render-resource pool: the metadata fields are written to the state owner only. The other renderer is 0x2daa00 bytes, and +0x11aae28 is far past its end (store_field crash; heap corruption in every release). - Other players' skateboard effects: a stale skateboard component is no longer followed, and the joint lookup is walked with a bound first (an endless loop in reused memory ended in GameStall). - Launcher: Oodle decodes into the buffer it asks for with corrupt data possible, and its assertions no longer stop the process (heap corruption in the store-copy scan; a breakpoint in oo2core). Timings (Send performance timings): - A frame of half a second or more in a level is sent as game.freeze: where the time went (ReSkate's tick, the game's frame, or outside it), whether the renderer kept presenting, and ReSkate's busiest zones. - Closing the game sends the level session it was in. Music after a connection drop: - Spotify device: an account Spotify could not be reached with is kept and tried again (3 s doubling to a minute); a session that drops is taken up again. Only an account Spotify refuses is asked for anew. - YouTube playlist pictures that could not be fetched are tried again, from 30 s to 10 minutes apart.
68 lines
3.0 KiB
C++
68 lines
3.0 KiB
C++
#pragma once
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <exception>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace dingosdk::trace {
|
|
using Tags = std::vector<std::pair<std::string, std::string>>;
|
|
using Clock = std::chrono::system_clock;
|
|
// A number carried by a transaction, such as an average frame rate.
|
|
struct Measurement { std::string name; double value{}; std::string unit{"none"}; };
|
|
using Measurements = std::vector<Measurement>;
|
|
// Called once logging is up: true when this launch sends timings. Until then,
|
|
// and in programs that never call it, record() does nothing. Timings are off
|
|
// unless RESKATE_TRACING=1 (the launcher's "Send performance timings" setting),
|
|
// and off whenever crash reporting is (RESKATE_CRASH_REPORTING=0).
|
|
bool start() noexcept;
|
|
// Whether this launch sends timings (start() succeeded).
|
|
bool active() noexcept;
|
|
// Queues one finished operation as a Sentry transaction. Never waits on the
|
|
// network and never throws. A launch's launcher and game share one trace.
|
|
void record(std::string_view name, std::string_view operation, std::chrono::milliseconds duration,
|
|
bool ok = true, Tags tags = {}, Measurements measurements = {}) noexcept;
|
|
// Frame pacing between two takes: the game's frame hook feeds it, and the end
|
|
// of a level session takes it. A hitch is a frame of 50 ms or longer.
|
|
struct FramePacing { std::uint64_t frames{}, total_ns{}, hitches{}, worst_ns{}; };
|
|
void frame(std::uint64_t now_ns) noexcept;
|
|
FramePacing take_frame_pacing() noexcept;
|
|
// Gives queued operations a moment to reach the server before the process exits.
|
|
void flush(std::chrono::milliseconds timeout) noexcept;
|
|
|
|
// Times its own lifetime. An exception passing through marks the operation failed.
|
|
class Scope {
|
|
public:
|
|
Scope(std::string name, std::string operation)
|
|
: name_(std::move(name)), operation_(std::move(operation)) {}
|
|
~Scope() {
|
|
record(name_, operation_, std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
std::chrono::steady_clock::now() - started_), ok_ && std::uncaught_exceptions() == exceptions_, std::move(tags_));
|
|
}
|
|
Scope(const Scope&) = delete;
|
|
Scope& operator=(const Scope&) = delete;
|
|
void tag(std::string key, std::string value) { tags_.emplace_back(std::move(key), std::move(value)); }
|
|
void fail() noexcept { ok_ = false; }
|
|
private:
|
|
std::string name_, operation_;
|
|
Tags tags_;
|
|
std::chrono::steady_clock::time_point started_{std::chrono::steady_clock::now()};
|
|
int exceptions_{std::uncaught_exceptions()};
|
|
bool ok_{true};
|
|
};
|
|
|
|
struct Transaction {
|
|
std::string name, operation, trace_id, release, process;
|
|
Clock::time_point started, finished;
|
|
bool ok{true};
|
|
Tags tags;
|
|
Measurements measurements;
|
|
};
|
|
// The Sentry envelope for one transaction: envelope header, item header, payload.
|
|
std::string envelope(const Transaction& transaction);
|
|
// The envelope endpoint beside a minidump endpoint, or empty when the URL is not one.
|
|
std::wstring envelope_url(std::wstring_view minidump_url);
|
|
}
|