tomboy-notes/tomboy-ng

IPC thread failure

uwemock opened this issue · 20 comments

OS: Ubuntu 20.04
Tomboy version: 0.34-1 (GTK)

Tomboy starts up with a window saying "IPC thread failure":

Screenshot_20220502_074807

When I select "OK", Tomboy continues to start up, but there is no tray icon.

The strange thing is that Tomboy works in another account on the same system. This account started using Tomboy with the QT version. Due to some access violation issues, I have switched to the GTK version which makes no problems.

uwemock, that sounds interesting indeed. I use IPC to ensure there is not another instance of tomboy-ng running. But that error message is not from my code, its from an "upstream" IPC unit I use. So we need to work out whats going on.

Firstly, you mention "another account" - do you mean that you have another user account on the computer running when you have this problem ? And tomboy-ng is running in that other user account too ? Its possible that IPC does not like that, I saw a post a week or so ago hinting that someone was seeing a problem when two different users, running on the same machine, both used IPC.

(At the time, I thought it was something I needed to test, apparently IPC drops a file in /temp but does not set permissions as it should. But of course I have not got around to it.... !)

Trouble is that IPC should have absolutely nothing to do with the TrayIcon. And that prompts my next question, what desktop are you using ? There are some problems with the TrayIcon on Gnome Desktop, maybe you are seeing two different problems ?

Finally, stupid question time, when you say "Tomboy" you do mean tomboy-ng don't you ? You should be able to run both the old Tomboy and tomboy-ng on the same system but if thats a problem, I need to look at it quite differently. But I am pretty sure all instances you are running are tomboy-ng ....

Davo

Firstly, you mention "another account" - do you mean that you have another user account on the computer running when you have this problem ? And tomboy-ng is running in that other user account too ?

I'm not talking about two instances running concurrently. I have one user where I have used Tomboy ever since. I have now created another user account where I wanted to start using Tomboy. But I'm only logged in on one of these accounts.

Trouble is that IPC should have absolutely nothing to do with the TrayIcon. And that prompts my next question, what desktop are you using ?

I'm using the KDE Plasma desktop.

Finally, stupid question time, when you say "Tomboy" you do mean tomboy-ng don't you ?

Yes. I have been unsing non-ng before, but I uninstalled it in favor of -ng.

Hmm, I do have a number of KDE users and never had a IPC report. So, something strange is happening here. I am still of the impression you have two different problems, one, that strange IPC message and secondly, a lack of TrayIcon. I am assuming you won't mind doing a bit of debugging ? Please ....

So, lets see if we find out more about the first one, please have -ng running, open a terminal and try to start another instance -

tomboy-ng <enter>

What should happen is the instance you are starting, the second instance, should detect that one is already running and ask the first to show its search form and then, it, the second, exits cleanly. I'd like to know if you see any sort of error, get your terminal prompt back immediately and do see the Search form open.

If you get the splash screen, then its certainly an issue with IPC, close the second one ASAP !

Next, the tray icon. Please close all instances of -ng and then, from a terminal, please open a new one but with this command line (gtk2 only, won't work with Qt5) -

LAZUSEAPPIND=INFO tomboy-ng [enter]

That should give us a brief message about the model its using for the System Tray. Unfortunately, Linux distros have been quite silly for a couple of years now, Gnome trying to kill it off, KDE inspiring then abandoning the AppIndicator, its been a mess !

One last question, is your Linux install a fresh install or an older one that has been updated ?

Davo

So, lets see if we find out more about the first one, please have -ng running, open a terminal and try to start another instance
tomboy-ng <enter>

When I choose "OK" from the message box above, Tomboy starts and shows the menu etc. window. When I start it again, the same thing happens and I end up with two windows.

LAZUSEAPPIND=INFO tomboy-ng [enter]

Screenshot_20220502_151840

One last question, is your Linux install a fresh install or an older one that has been updated ?

It has been a fresh 20.04 install which has been updated to 20.04.4 meanwhile.

Another thing: There was a message complaining about a missing theme that I had never heard of (adwaita). I installed it from Synaptic, and the message went away.

OK uwemock, becoming clearer.
Firstly, appears IPC is not working on your system. I have absolutely no idea why not but need to find out. One more thing you can try please, with no tomboy-ng running -
ls -la /tmp | grep tomboy <enter>
And then repeat that with tomboy-ng running. The second time it should show a pipe, owned by your user name.

My suspicion is that there is already an existing pipe there, possibly owned by that other user name you use. If thats the case, it will explain quite a lot, your current user will not be able to remove it so cannot create its own. Hints at quite a nasty bug in IPC but an easily fixed one.


The system tray icon ? Yes, your system seems to be able to support both models so, as a test, try this, it will force the older System Tray model instead of AppIndicator, note the icon will (should) appear in a different part of the SysTray than you may be used to, might need to look carefully -

LAZUSEAPPIND=NO tomboy-ng <enter>

Davo

One more thing you can try please, with no tomboy-ng running - ls -la /tmp | grep tomboy <enter> And then repeat that with tomboy-ng running. The second time it should show a pipe, owned by your user name.

This is true. The pipe appears with tomboy-ng running, and it disappears once I quit tomboy-ng.

My suspicion is that there is already an existing pipe there, possibly owned by that other user name you use. If thats the case, it will explain quite a lot, your current user will not be able to remove it so cannot create its own. Hints at quite a nasty bug in IPC but an easily fixed one.

Also true. When I log off from the one account with tomboy-ng in the tray, the pipe remains in /tmp. When I log on to the other account, tomboy-ng refuses to start - but once I delete the pipe in /tmp, tomboy-ng starts up with no error message. The tray icon appears as an empty space, however.

LAZUSEAPPIND=NO tomboy-ng <enter>

This makes the tray icon appear. The question remains why it just works in the other account.

Another observation: It takes about 5 seconds to quit tomboy-ng. During these 5 seconds, the desktop does not respond to user interaction.

right, sounds like we are zooming in on it uwenmock. The IPC issue is definitely user account related. If you exit -ng before logging out, it should clean up that pipe and let the other user play nicely when it starts up. I will investigate just what I can do to fix the underlying problem, its probably going to be a FPC or Lazarus issue, while I can fix my builds easily enough, if you use the Debian/Ubuntu built ones, will not happen until new versions of FPC/Lazarus are released. The distros do not like using pre-release tools I am afraid.

I don't understand why you see a empty space for the TrayIcon, can you pull down the menu from there ?

And the TrayIcon works OK when we force the old System Tray model ? That is really, really bad news. I was under the impression that this absolute mess was settling down and recently submitted patches to Lazarus that preferences the AppIndicator because all the current systems I tested worked reliably. Maybe I did not test Ubuntu / KDE ? There are so many combinations I am afraid. If the KDE install has the AppIndicator then why does it not work ? I will have to build a U-KDE vm and do some more research.

You can solve your problem by always starting -ng with that env var. Typically add a bash script in your own bin dir with that command line and calling that script from the desktop file, /usr/share/applications/tomboy-ng.desktop

The script might look like this -

#!/bin/bash
export LAZUSEAPPIND=NO
/usr/bin/tomboy-ng

Will follow all this as time permits.

Davo

OK, the IPC issue very easily fixed, I have added Unix USER to IPC pipe name. Done.
Davo

I don't understand why you see a empty space for the TrayIcon, can you pull down the menu from there ?

Yes, the menu works. It's just missing an icon.

And the TrayIcon works OK when we force the old System Tray model ?

Yes.

OK, the IPC issue very easily fixed, I have added Unix USER to IPC pipe name.

I think that should be considered good practice anyway...

OK, I have built a U2004 KDE install and I cannot replicate your problem with the TrayIcon. I have tested both the GTK2 and Qt5 version.
Interesting, 'out of the box' it does not install an AppIndicator, neither the old Unity one or Ayatana one and tomboy-ng happily falls back to the traditional System Tray that is still built into KDE. Synaptic tells me that Ayatana is available in the repo but not installed. And there are other (uninstalled) packages there that might be the old Unity AppIndicator (that Ubuntu has brought forward from its experiment with Unity).

So, from the above, where the debug told you that "An appindicator has loaded True" I have to assume you do have an AppIndicator library of some sort installed and its not working with KDE. Thats not surprising because KDE does still have a working System Tray so an AppIndicator is not necessary, I doubt anyone has bothered to enable it under KDE. Ayatana was very early in its development when U2004 was released.

Are you aware of having installed an AppIndicator library ? Maybe you have had another Desktop (Mate, XFCe etc) also installed but not being used ? Or some extra panel tool perhaps ?

Anyway, the issue is that you do have a (probably non functioning) AppIndicator installed, tomboy-ng sees its there and is instructed to use it if it sees it. And using that env var we used earlier will override tomboy-ng's decision and force it to use the System Tray.

I cannot, in tomboy-ng code, change that preference for AppIndicator, in the vast majority of systems, its a good choice. To change it, I would need to alter the code in upstream Lazarus LCL (actually code I wrote but the devs would not be willing to change anyway).

Can we peruse the problem you had with the Qt5 version ?

Please let me know what you think.

Davo

Are you aware of having installed an AppIndicator library ? Maybe you have had another Desktop (Mate, XFCe etc) also installed but not being used ? Or some extra panel tool perhaps ?

I have checked in Synaptic. I have gir1.2-appindicator3-0.1 and libappindicator3-1 installed. The libappindicator3-1 seems to be a dependency for remmina.

Anyway, the issue is that you do have a (probably non functioning) AppIndicator installed, tomboy-ng sees its there and is instructed to use it if it sees it. And using that env var we used earlier will override tomboy-ng's decision and force it to use the System Tray.

The fun thing is that it works on the other account...

Can we peruse the problem you had with the Qt5 version ?

This was an "access violation" message when opening the menu from the tray icon. I did a web search and found the recommendation to use the GTK version instead.

The libappindicator3-1 seems to be a dependency for remmina.

Ok, so that explains it. Does remmina's Tray Icon work as expected ?

The fun thing is that it works on the other account...

Yeah, fun. The only difference can be ownership of the pipe. I am pretty sure thats not the case but I could be very wrong. Have you removed that Pipe and tested ? Need to do it in the other account or as SU. I am assuming the other account is not running so tomboy-ng there must have received the kill signal, apparently, I read, IPC cannot cleanup its pipes because the kill -9 cannot be caught at logout. My 'fixed' version of tomboy-ng will solve that problem but for now, removing the the pipe when it should not be there is the solution.

(Qt5) This was an "access violation" message when opening the menu from the tray icon. I did a web search and found the recommendation to use the GTK version instead.

Hmm, in the past I have seen some issues with the Qt5 version on KDE (ironic ?) but believed the current Qt5 libraries all work well now. Do you remember circumstances of the AV ? I tested the Qt5 version here, earlier, and had no issues but was only a superficial test. Either should work and it appears that U2004KDE is still being shipped with all the GTK2 libraries so no real advantage either way. I personally use the GTK2 version but reckon Qt5 does look just a bit better !

Davo

I checked remmina today on the account where tomboy-ng's tray icon did not appear. Remmina worked well - no problems at all.

But now, believe it or not, tomboy-ng also works.

The tomboy-ng tray icon appears with no extra measures.

Maybe remmina did some base initalization that was necessary for that type of tray icon?

The story goes on...
The tomboy-ng icon disappeared from the tray in the account where I usually had it. The space is there, and it is functional. But no icon.

I found a directory called "appindicators" in /tmp owned by the other account (the new one). I deleted it, restarted tomboy-ng,and now the icon is back there. The "appindicators" directory came back - owned by the user currently logged in (the old one).

I am not sure how these AppIndicators work but suspect they do pretty much the same as the old System Tray model and create a temp file containing the image to be displayed in the icon. If thats the case, and it appears to be, looking at my system, then it looks like it has the same problem as the IPC had in -ng, that is, it makes a temp dir in the global /temp that is owned by a specific user and not writable by another user.

If thats the case, its a massive bug and one that can only be dealt with by the Ayatana developers. But, honestly, seems very unlikely it would have gone this far without someone spotting this issue. We are both using a two year old Ubuntu, and Ayatana only really started about two years ago so I will start by doing some testing on a more current release. Not happy !

Rebooting will obviously clean out /tmp but we'd think we are back using Win95 !

Back to virtualbox I go ....

Yep, confirm same behaviour in U2204 Gnome, not looking good. I will report this to https://github.com/AyatanaIndicators, maybe there is a way of forcing the library to use a user unique dir name but I suspect not. Only other short term workaround I can think of is to force your session to use a local tmp dir, used to be pretty normal in Unix but Linux does not look so flexible.

In your case, removing /tmp/appindicator before logging off would work but is hardly convenient.

Davo

I have patched my own copies of the upstream source and tested superficially, all good. I will push out another beta with this fix as soon as I get on top of another, somewhat harder problem #260
I will submit my patches to the Lazarus developers and expect they will accept it but it will take some time. So distro managed versions of tomboy-ng will have this problem, for, "some time". If we are lucky, it will make it into the 2.4.0 release but no guarantees.


For anyone singing along from home, its just a case of editing lcl/interfaces/gtk2/unitwsctrls.pas, commenting out the line -

const
IconThemePath = '/tmp/appindicators/';

adding, under 'var' a few lines down -
IconThemePath : string;

altering this line

    GlobalAppIndicator := app_indicator_new_with_path(PChar(FName), PChar(FIconName),
      APP_INDICATOR_CATEGORY_APPLICATION_STATUS,  IconThemePath);
// becomes
    GlobalAppIndicator := app_indicator_new_with_path(PChar(FName), PChar(FIconName),
      APP_INDICATOR_CATEGORY_APPLICATION_STATUS,  PChar(IconThemePath));

and adding this line to initialisation section
IconThemePath := '/tmp/appindicators-' + GetEnvironmentVariable('USER') + '/';

(actually, thats so I have a permanent record in case #260 takes longer than I thought ...)

Davo

I have placed some 0.34c packages in https://github.com/tomboy-notes/tomboy-ng/releases
I believe that they fix both problems mentioned here, been quite a lot of code change so please report anything unexpected !
Thanks for your help.
Davo

For the record, merge request to Lazarus to fix the TrayIcon bug -

https://gitlab.com/freepascal.org/lazarus/lazarus/-/merge_requests/92

I've been usind 0.34c for a week now. Looks good. Thank you!

Great news ! Thanks for you contribution here, valuable.
Two bugs fixed.
Davo