BetterDiscord / BetterDiscord

Better Discord enhances Discord desktop app with new features.
https://betterdiscord.app
Apache License 2.0
8.02k stars 987 forks source link

[Feature] Ability to detect and automatically disable a plugin that causes a crash #907

Closed logoffon closed 8 months ago

logoffon commented 3 years ago

Is your feature request related to a problem? Please describe. Sort of. It's related to library plugins that recently caused a crash like #904, but BD doesn't give any idea on which plugin caused a crash.

Describe the feature you'd like Instead of disabling all plugins and directing users to remove all plugins and then test them one-by-one, BD should be able to detect, list, and automatically disable all the plugins that caused the crash to the user. After which they can remove them and/or contact the dev for those plugins to provide a fix.

Additional context Currently, this is what BD does after restarting Discord in an event of plugin-induced crash: Discord_2021-05-04_10-45-09

KingFishy492 commented 3 years ago

Try the following,

Why is my BetterDiscord crashing? BDFDB is causing crashes following the last discord update. To fix it, remove 0BDFDB.plugin.js (this file https://gyazo.com/2a3f88a597dc33fc4a3d95ac6bdc4a7d ) from your plugins folder and download it again from the link below, and install it: https://mwittrien.github.io/downloader/?library Plugins Folder path:

thanks Qb for writing an actually good version of this tutorial and Bep for providing an actually up-to-date download of the lib

logoffon commented 3 years ago

@KingFishy492 I already got my crashing issue fixed, which I forgot to include.

PowerOfCreation commented 3 years ago

Try the following,

Why is my BetterDiscord crashing? BDFDB is causing crashes following the last discord update. To fix it, remove 0BDFDB.plugin.js (this file https://gyazo.com/2a3f88a597dc33fc4a3d95ac6bdc4a7d ) from your plugins folder and download it again from the link below, and install it: https://mwittrien.github.io/downloader/?library Plugins Folder path:

  • Windows: %appdata%/betterdiscord/plugins (Win+R and paste this path in there)
  • Mac: ~/Library/Application Support/betterdiscord/plugins
  • Linux: ~/.config/BetterDiscord/plugins

thanks Qb for writing an actually good version of this tutorial and Bep for providing an actually up-to-date download of the lib

You totally missed the point. Nobody should be required to manually search for all their plugins each time a crash occurs and manually perform steps to fix it. BetterDiscord should handle this itself and just disable the corresponding plugins and the ones depending on it. I have been using BetterDiscord for a few months now and I had this a couple of times already. Reinstalling, removing plugins and looking up solutions all few weeks is just annoying and will loose many users.

QbDesu commented 3 years ago

Even if the plugin was disabled it still would have caused the crashing because the problems also occur when loading the plugin already, and BDFDB enables itself if it was disabled. Disabling it wouldn't have helped. On the other hand it's not that easy to check which plugin caused the crash, especially not if it needs to be done programmatically.

PowerOfCreation commented 3 years ago

Wouldn't it be possible to (1) Load BetterDiscord (2) Load each plugin and write to a file "working-plugins.txt" when loading a plugin started and when it successfully loaded (3) Now either all plugins get loaded and it works fine or a crash occurs (4) In case of a crash close BetterDiscord completely and restart it, but this time only load all plugins that are in "working-plugins.txt" (5) In case it crashes again on a different plugin then do the same(write it to "working-plugins.txt"). Don't even try to load plugins which are dependent on crashed plugins. (6) Show a message which plugins got loaded, which crashed and which didn't even got attempted to load as dependencies crashed (Optional)(7) Offer automatic reinstall of crashed plugins

Be1zebub commented 3 years ago

why plugins cant be just loaded in isolated sandbox? also we dont have a crash log :( pls give

zerebos commented 3 years ago

@PowerOfCreation that would be a painful process, but that could be done as a sort of safe-mode.

@Be1zebub running it in a sandbox would mean they can't actually affect discord. It would also cause them to run in a different process context. There isn't always a crashlog available.

PowerOfCreation commented 3 years ago

I understand that this looks painful and I have to admit I don't know anything about the internal structure of BetterDiscord, but I think something like this needs to exist. When BetterDiscord wants to be viable for "actual use" and not just for toying around then it shouldn't require a reinstallation and messy research all few weeks.

Would it be possible to "catch" errors at runtime and disable the plugin at runtime instead of crashing the entire application or is this contradicting with the architecture of BetterDiscord? Otherwise I assume something like what I proposed should probably be implemented.

As a starting point maybe just output the name of the plugin which caused the crash. Restarting with this specific plugin shouldn't be too far away from this or am I mistaken?

zerebos commented 3 years ago

When BetterDiscord wants to be viable for "actual use" and not just for toying around then it shouldn't require a reinstallation and messy research all few weeks.

If BetterDiscord wasn't an unofficial mod for an app, I would agree with you.

Would it be possible to "catch" errors at runtime and disable the plugin at runtime instead of crashing the entire application or is this contradicting with the architecture of BetterDiscord?

This (more or less) used to be how BetterDiscord worked. But the recent changes in Electron/Discord have thrown that out and there is not an easy way to do this while keeping things even mostly backwards-compatible. To do things properly with the new Electron/Discord changes, all existing plugins would have to break.

Be1zebub commented 3 years ago

@Be1zebub running it in a sandbox would mean they can't actually affect discord. It would also cause them to run in a different process context. There isn't always a crashlog available.

So then bd must have his own api to interact with the discord. or just pcall all code

zerebos commented 3 years ago

Creating an API to interact with all facets of the client (and maintaining that for every update) would be more work than just creating a separate client.

PowerOfCreation commented 3 years ago

If BetterDiscord wasn't an unofficial mod for an app, I would agree with you.

And this automatically means that the entire project is not meant for actual use? There are over 7 million downloads and an entire website for this mod. The title of the website is: "The Discord Enhancement Project". The entire website presence and everything else when downloading and installing this does not downplay this as a unstable toy, but rather as a full solution to enhance Discord. I think with such claims a reasonable stability should at least be targeted.

Nobody is expecting a completely stable version, but I think the goal should at least be that the user does not have to do manual debugging all few weeks or at the very least the errors should be a bit more specific.

BetterDiscord has already done great and I really love the features it provides and I'm sure many talented people are behind this and trying to get the entire project to be more stable would surely be a great way to improve this mod even further.

This (more or less) used to be how BetterDiscord worked. But the recent changes in Electron/Discord have thrown that out and there is not an easy way to do this while keeping things even mostly backwards-compatible. To do things properly with the new Electron/Discord changes, all existing plugins would have to break.

This is very unfortunate. What about my suggested approach earlier? Wouldn't this avoid all those issues and at the same time guarantee backwards compatibility?

zerebos commented 8 months ago

This is just a piece of #1018