Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better stack traces #38

Merged
merged 2 commits into from
Mar 24, 2024
Merged

Better stack traces #38

merged 2 commits into from
Mar 24, 2024

Conversation

WilsontheWolf
Copy link
Member

This PR implements better stack traces into the game, for when it crashes. This uses a modified version of StackTracePlus, that I modified so it would show the name and id for mods (compared to just [string "--- STEAMODDED HEADER..."]), and also shows some more info for internal Love2D unctions.

It also adds a function injectStackTrace which loads stack trace plus, and overwrites the game's crash handler to, debug print the message and stack trace and show the custom stack trace on the screen.

I made this originally as a mod, because I found often times people were having a hard time figuring out what mod was involved with a crash (even with debug mode giving stack traces). This was meant to resolve that, by giving more useful info on these crashes.
However, I have decided to make this PR to add it as a core Steamodded feature. This is mostly because a couple people suggested it on the discord, but also because I realized that the mod is unable to show crash info for mods that crash before the mod is initialized, which is less than optimal. I also figured this features would be useful for most people.

There are some design decisions I am not sure about, and would like if I could get a review on.
First off is the init. injectStackTrace is currently called in initSteamodded, which I figured would be decent as it is something that is being initialized, and it then is properly loaded before mods. However, I could call the function right under its definition, which might make more sense, as it could catch errors sooner (not sure how much logic is actually ran sooner), and is also entirely self contained.

Another decision I made is to kind of hack the built in error handler, to always show a stack trace. The code is fine, but I could probably re-implement the entire handler, making it a bit nicer to work with, as well as do things like disable the sending of crash reports to localthunk, a bit more consistency with the stack if debug mode is on or not, and also would let us add additional functionality to the error screen in the future easier (maybe the ability to copy the error to the clipboard, or restart with mods disabled, for example).

I was also unsure if I should keep the core StackTracePlus code and my inject code in the same or different files. I kept them in the same for now, as I figured they are tightly related, and there's no reason to separate them, but maybe you have a different way of designing things.

Otherwise, thank you very much for the review.

@Aurelius7309 Aurelius7309 merged commit dc14dab into Steamodded:main Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants