openscopeproject / TrguiNG

Remote GUI for Transmission torrent daemon
GNU Affero General Public License v3.0
278 stars 33 forks source link

Program stopped starting torrent when opening #113

Closed username227 closed 8 months ago

username227 commented 8 months ago

I must be cursed. The program, after the reinstall of my Arch system, now works fine as long as I use the webview export command that webkit that they told me about.

I am using Cinnamon and Nemo file manager. trgui-ng is set as the default to open my torrent files. Everything worked fine until just recently. Just today I noticed that the program wasn't opening new torrents properly. The dialog box that usually comes up doesn't appear, and the torrent isn't added. IF the torrent is already present, the box that says error doesn't come up.

I'm not sure what's changed. This may not be a bug with this program, but perhaps you have some idea what might be happening? Thanks!

username227 commented 8 months ago

UPDATE: this only happens when trgui-ng is running on Nvidia card. It does not happen when it is running on the integrated AMD card, and it does not happen when in hybrid mode. So obviously something about nvidia. But that doesn't tell me anything about whether it's a nvidia error or a webkit error. I understand if you don't want to do anything about this now. I can run in hybrid mode and forget about this for a month or two and then come back to it and see if it's resolved.....

qu1ck commented 8 months ago

I have seen glitches like dialogs not popping up on newest ubuntu running in a VM. But the DMA buffer disabling env variable cured it for me. Another thing I noticed was that resizing the window a bit would fix the dialog as well.

When you open a torrent file does TrguiNG window pop into focus even if add dialog does not show? If it does then this is likely webkit rendering issue but if not then it's something else.

username227 commented 8 months ago

"Normal" behavior for me seems to be that the icon on the bottom of the cinnamon bar blinks red, but the program doesn't necessarily come to the forefront, assuming the program is already open in the tray. TBH, while troubleeshooting today, I've seen it both ways.

Most of the time, nothing happens. The program was closed, it didn't open. The program was opened in the tray with the webkit dmabuf variable disabled, and opening a torrent file through nemo did nothing. I started to wonder if perhaps it was attempting to open a new instance of the program and getting a segmentation fault, but i can't prove that this is what's happening, i'm not sure this makes sense anymore.

A few times, I did notice the icon on the bottom turned red but no dialog box appeared. I can't reproduce to test now, as I have not noticed a pattern (as of yet, at least) regarding when this does or does not happen. I tested your idea of resizing the windows when no red blinking started, and it did not show any dialog box. Next time I see it start to blink without a dialog box, I will attempt to resize and report back.

qu1ck commented 8 months ago

Can you verify that the env var is applied correctly? Run this in terminal cat /proc/$(pgrep trgui-ng)/environ | xargs -0 -n1 echo | grep WEBKIT_DISABLE_DMABUF_RENDERER

Depending on where you defined the variable it may not apply if you open a torrent file in file manager.

username227 commented 8 months ago

this is the output:

`DMABUF_RENDERER
cat: /proc/6046: Is a directory
cat: 6048/environ: No such file or directory

I created a script with the dmabuf command is automatically run followed by the program. `

qu1ck commented 8 months ago

cat: /proc/6046: Is a directory cat: 6048/environ: No such file or directory

That means you have 2 instances of the program running which should never happen. Kill both and I bet your issues will go away.

username227 commented 8 months ago

OK, so yes, I did have two, but I suspect that one was the program and one was the script I made. I changed the name of the script and ran the program. I also tried running it manually through a terminal without the script (the two commands). In both instances, the problem was still present. :-(

qu1ck commented 8 months ago

How did you associate torrent files with the program?

The "normal" way in linux is through .desktop files, I have one made for ubuntu package but obviously you are not using it in arch. So are you pointing cinnamon to open torrent files through your script which passes arguments to trgui-ng?

username227 commented 8 months ago

Yes, basically. In Nemo, I am simply right-clicking on the torrent file, choosing open with, and then pointing it specifically to the executable. If the program isn't open already, then it will fail because of the segfault; but if it was open already, it would work flawlessly and open the torrent dialog. That's what stopped - it still works fine in AMD or hybrid mode; just not in nvidia mode. Which doesn't really make a lot of sense.

qu1ck commented 8 months ago

Yes, basically. In Nemo, I am simply right-clicking on the torrent file, choosing open with, and then pointing it specifically to the executable.

That's different from what I said. If you are pointing "open with" dialog to executable and not your script then it is run without the environment variable.

If the program isn't open already, then it will fail because of the segfault

From this I am assuming that without the environment variable the program crashes for you. That would explain random behavior of sometimes opening the file and sometimes not.

For context, this is how opening files in trguing from system works:

  1. System invokes the executable and passes path to the torrent file as an argument. It does not care whether trguing is already running, new process is created every time.
  2. First thing trguing does is try to communicate to another running trguing process. If it succeeds then it just passes along the argument it received to pre-existing process and shuts down. If it doesn't then it assumes it is the first process and processes the argument itself.

Because of the crash without env var there is likely a race condition in step 2 and sometimes trguing is lucky to pass the argument to main process before it crashes, sometimes not so lucky.

The proper fix to this is to avoid crashing. That means teaching your desktop environment to always launch the program with env variable. For that you should create a .desktop file. Side bonus is that magnet links in browsers will work too.

Create trgui-ng.desktop file in ~/.local/share/applications with following contents:

[Desktop Entry]
Categories=Utility;
Exec=env WEBKIT_DISABLE_DMABUF_RENDERER=1 /full/path/to/trgui-ng %u
Icon=trgui-ng
Name=TrguiNG
Comment=Transmission torrent daemon remote GUI
Terminal=false
Type=Application
MimeType=application/x-bittorrent;x-scheme-handler/magnet;

Note the variable in Exec line and change the path to correct one. Also leave %u at the end, it is important.

Then restart or reload cinnamon. New entry should appear in your applications menu and in file manager "open with" should suggest trguing right away.

username227 commented 8 months ago

Thanks, yes that did indeed work. I had been trying to add the environment variable directly to the file but couldn't figure out the exact format. I have no idea why on earth my method would have worked flawlessly on amd card but noot on nvidia. that I guess shall remain a mystery.

qu1ck commented 8 months ago

I have no idea why on earth my method would have worked flawlessly on amd card but noot on nvidia. that I guess shall remain a mystery.

Because on amd graphics the app does not crash. So it does not matter that using "open with" the env variable was not applied, trguing was always able to pass the argument to the main process which would open the file.

username227 commented 8 months ago

Just wanted to say congrats on your latest release -v1.0. Great program.