Open tmontes opened 4 years ago
Definite +1 for me -- although without any concrete proposal to make at present. (Apart from the obvious try-except approach which you say has complications through the Qt event loop).
Just dropping in here (as part of any wider discussion): https://docs.python.org/3/library/sys.html#sys.excepthook
Could we create a "runner" program that runs Mu as a subprocess and displays a message if the exit code is non-zero? This would catch everything, even segmentation faults.
Example:
import pathlib
import subprocess
import sys
args = [
sys.executable,
str(pathlib.Path(__file__.replace('runner.py', 'main.py')).absolute()),
# TODO: append additional command line args from sys.argv
]
with open('log.txt', 'w') as log:
ret = subprocess.run(args, stderr=log)
if ret.returncode:
# TODO: Use Qt to show this in dialog box along with a button to
# automatically send log.txt somewhere or view it locally
print('Something bad happened')
sys.exit(ret.returncode)
We could still run Mu directly for development/debug, but in production, it could be run with such a wrapper.
@dlech The idea is attractive. My initial misgiving would be that any additional mechanism adds a layer of uncertainty / risk which provides yet another source of possible bugs. In other words, we'd have to be absolutely certain that the additional (support / debugging) overhead was outweighed by the benefits.
My ad-hoc exploration in a different context lead me to this project, which might be useful in this context: qcrash
@PyPI and @GitHub...
While not exactly the approach @dlech was mentioning, it may help address the majority of crashes we've observed with, hopefully, very little effort on our part.
Deferring evaluation to a later stage. Just wanted to "write it down" and share.
I dedicated some time to explore the above mentioned qcrash
library. For that, I created a minimal project I called qtcrashme
. Here are my findings.
Running qtcrashme
gets us this window:
Clicking the Click to crash
button triggers a raise BaseException(...)
here. With qcrash
it is caught and a default "something bad happend" dialog is displayed:
Clicking the Show Details...
button expands the dialog to include the traceback:
Clicking the Report
button closes that dialog and brings up a new one, again bundled within qcrash
, with a pre-filled Title and an empty Description area for the user to enter text:
As soon as some input is added to the Description, the Submit on github
and Send email
buttons become active:
Clicking the Send email
button triggers the default email client with a ready to send email message. Here's what I got in my case:
Clicking the Submit on github
button instead brings up yet another qcrash
bundled dialog, allowing the user to review what will be submitted to GitHub, including the issue text...
...and the log, which will be submitted as a linked gist:
Lastly, clicking the OK
button, brings up yet another dialog asking for the user's GitHub credentials, such that a new issue can be logged on their behalf:
No feedback is given as the GitHub API interaction progresses. It felt like ~3-5 seconds on my attempts. Once done, a final qcrash
dialog is shown:
Clicking the Yes
button, takes you to the just logged issue which, interestingly, links to the gist containing the log file contents.
Once this process is complete, the original UI is available and running -- whether it is still of any use after such failure will depend on the code, naturally. :)
qcrash
a bit).This was interesting. Like I initially wrote, I think the key thing is coming up with a good answer to:
The kind of Mu behaviour when such fatal failures are detected needs to be defined. What should happen? Which kinds of end user interaction would make sense?
From there, everything else becomes a "technical detail". :)
If the dialog is coming from the same instance as mu itself using our theme should be fairly trivial, otherwise it may require a little more investigation
Overall that UX isn't overly great but hopefully it doesn't get seen often
Ideally, the user would just hit report and then the crash log would be directly submitted to Github as an issue. Here's a Github app that receives emails and creates issues: https://fire.fundersclub.com/ - do you it could be misused for spam, or does Github do effective spam filtering?
(as suggested by @ntoll here)
Issue
Idea
Facts
Thoughts
Qt
way, somehow: wrappingQt
's event loop in atry/except BaseException
won't work for all sorts of reasons.I feel this is a very important and non-trivial issue that we should seriously consider including, for the benefit of both Mu users and contributors: such tooling should lead to a better user experience and to more detailed, hopefully actionable, crash reports that contributors can address directly. :)
Shall we discuss this?