Lazarus

Using the Lazarus IDE => General => Topic started by: Sashulya on September 11, 2020, 11:37:54 pm

Title: Problem with Lazarus in Ubuntu Gnome
Post by: Sashulya on September 11, 2020, 11:37:54 pm
Hi,
I have problem using Lazarus in Ubuntu 20.04 (with Gnome). I just installed the last version of Lazarus, 2.0.10, and converted my old Delphi project. The project is very light, but the resulting executable starts with a big delay, about 20-30 seconds. And before it starts it shows warning, like "Wait" or "Force Quit".
I found no reason why it could happen, and then I installed Lazarus in another Linux - Manjaro XFCE. Everything was fine there, no matter which executable I run - compiled in Ubuntu or in Manjaro, both start very quickly, as they should.
Then I tried even in Windows, opened and compiled this project in Lazarus - and everything was fine.
It seems like this problem with big delay exists only in Ubuntu (or probably in Gnome). Could you please tell me, is it a known problem, and what can be done with it?
Title: Re: Problem with Lazarus in Ubuntu
Post by: Sashulya on September 12, 2020, 01:31:46 am
Surfing the internet, I found some partial solutions of this problem:

1. Compiled projects starts quickly with root privileges;

2. The problem disappears after installing appmenu-gtk2-module (sudo apt install appmenu-gtk2-module)

The second decision looks helpful, but of course I cannot distribute my application, if user's OS don't have this appmenu-gtk2-module installed. Maybe it is possible somehow to include this appmenu-gtk2-module in the project? If it is possible, could you please explain how it can be done?
Title: Re: Problem with Lazarus in Ubuntu
Post by: Handoko on September 12, 2020, 04:49:17 am
Hello Sashulya,
Welcome to the forum.

I'm sorry to hear you have problem with Lazarus. I use Lazarus on Ubuntu Mate, so far no any serious issue.

Can you please provide any compile-able demo so we can inspect the problem? If you're not willing to publicize the project, you can write a simple demo that can show the problem.

Create a new folder, copy and paste all the necessary files into it except: the binary (exe file), *.bak, lib and backup folders. Compress the folder and send the zip here.
Title: Re: Problem with Lazarus in Ubuntu
Post by: trev on September 12, 2020, 05:38:17 am
Create a new folder, copy and paste all the necessary files into it except: the binary (exe file), *.bak, lib and backup folders. Compress the folder and send the zip here.

Better yet, use the "Lazarus > Project > Publish Project" option which will create a compressed archive of the project for you.
Title: Re: Problem with Lazarus in Ubuntu
Post by: Handoko on September 12, 2020, 08:10:41 am
Thank you for informing us the tool.

I tried it some years ago and I've just tested it again. No, it is not 'better' as you said. For example I tested it on my CATWW project, it did not include all the necessary images. It failed on my test.

Don't get me wrong. It would be great and I appreciate the attempt of creating the tool. Unfortunately it still need need more improvements to make it really usable.
Title: Re: Problem with Lazarus in Ubuntu
Post by: trev on September 12, 2020, 08:24:19 am
For example I tested it on my CATWW project, it did not include all the necessary images. It failed on my test.

Did you add your image extension to the default list: *.(pas|pp|inc|lpr|lfm|lrs|lpi|lpk|xml|sh) ?
Title: Re: Problem with Lazarus in Ubuntu
Post by: Handoko on September 12, 2020, 08:37:33 am
Yes, it works. Thank you.
Title: Re: Problem with Lazarus in Ubuntu
Post by: Sashulya on September 12, 2020, 06:11:07 pm
Hello Sashulya,
Welcome to the forum.

I'm sorry to hear you have problem with Lazarus. I use Lazarus on Ubuntu Mate, so far no any serious issue.

Can you please provide any compile-able demo so we can inspect the problem? If you're not willing to publicize the project, you can write a simple demo that can show the problem.

Create a new folder, copy and paste all the necessary files into it except: the binary (exe file), *.bak, lib and backup folders. Compress the folder and send the zip here.

Hi,

thanks for the info and tips, I decided to investigate further and installed Ubuntu MATE, which you use. And in MATE everything is fine!

So it seems that the problem can be narrowed down: the delay after start of compiled application exists in Ubuntu Gnome only.

I just checked, MATE has this package preinstalled: appmenu-gtk2-module
And it looks like it is the sourse of the problem - this package is not installed by default in Ubuntu Gnome, but without it a compiled application has a delay while starting.

I'll try to make some simple example soon, so it can be checked by other people, and then upload here.
Title: Re: Problem with Lazarus in Ubuntu
Post by: Handoko on September 12, 2020, 06:23:29 pm
Thank you for reporting back and sharing what you found.
This will be useful for someone with similar problem as yours in the future.
Title: Re: Problem with Lazarus in Ubuntu
Post by: Sashulya on September 13, 2020, 11:21:35 am
Now I made a video to make the problem as clear as possible. As seen in video, the problem appears even with "dummy" project with single button:

https://www.youtube.com/watch?v=8NuJRA2wAFA

As we discussed, I also made a zip-archive of this project.

So, by now problem looks like this: Any project, made with the default installation of Lazarus, has a delay before starting, if the system has no appmenu-gtk2-module or some other gtk2-module installed. For example, in Ubuntu Gnome.

Seems like it depends on interface library, which by default is GTK2 in Lazarus.

Is it possible to solve this problem somehow by including some gtk2-module package in project, or do I need to use other libraries, like QT or GTK3? Thanks in advance.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: Sashulya on September 21, 2020, 07:56:34 pm
Could anybody help? :-[

No need to look into the archived code, it's almost empty project, but the video should explain the problem.

I hope I managed to explain the essence of the question :)
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: Fred vS on September 21, 2020, 08:08:33 pm
Hello.

Are you using Ubuntu 20.04 with Wayland or Xorg display server?

Afaik, Lazarus is not yet Wayland compatible and needs to deal with a Xorg emulation.

Wayland offers a Xorg emulation but it needs some time for conversion and that could explain the delay.

Anyway, Andrew Haines has published his Wayland-fpc conversion, maybe Lazarus team could take a look at this:

https://github.com/andrewd207/fpc-wayland

Fre;D

Title: Re: Problem with Lazarus in Ubuntu
Post by: JuhaManninen on September 21, 2020, 09:24:35 pm
2. The problem disappears after installing appmenu-gtk2-module (sudo apt install appmenu-gtk2-module)
The second decision looks helpful, but of course I cannot distribute my application, if user's OS don't have this appmenu-gtk2-module installed.
You can instruct your clients to run the "apt install" command if they have a similar problem.
It requires root access but people who run graphical desktops on Linux typically have it.
Is there a reason why they could not do it?

Quote
Maybe it is possible somehow to include this appmenu-gtk2-module in the project? If it is possible, could you please explain how it can be done?
No, it is a system library.
Why LCL-GTK2 depends on it, nobody knows. I doubt it will be fixed ever, especially because GTK2 is becoming obsolete and all effort should go to improve LCL-GTK3.

You should distribute also a LCL-QT5 version of your application. Then people can choose which one to use. LCL-QT5 is especially good with desktops built with QT5, like KDE. I personally have Manjaro + KDE and build my Lazarus mostly with LCL-QT5.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: Sashulya on September 21, 2020, 09:27:53 pm
Hello.

Are you using Ubuntu 20.04 with Wayland or Xorg display server?

Hi, just checked echo $XDG_SESSION_TYPE, it's X11, i.e. Xorg.

But thanks anyway!
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: JuhaManninen on September 21, 2020, 09:29:49 pm
Afaik, Lazarus is not yet Wayland compatible and needs to deal with a Xorg emulation.
It is Wayland compatible when using a widgetset that supports Wayland directly. AFAIK QT5 supports it.
Anyway, Wayland has nothing to do with Sashulya's problem.

Quote
Anyway, Andrew Haines has published his Wayland-fpc conversion, maybe Lazarus team could take a look at this:
You mean to create a new LCL-Wayland widgetset? Yes, good idea, but somebody must volunteer to do it. Who?
BTW, LCL does not have a direct X11 widgetset either. X11 is used indirectly through other GUI libraries like GTKx and QTx.
Title: Re: Problem with Lazarus in Ubuntu
Post by: Sashulya on September 21, 2020, 09:35:56 pm
You can instruct your clients to run the "apt install" command if they have a similar problem.
It requires root access but people who run graphical desktops on Linux typically have it.
Is there a reason why they could not do it?
I just wanted to make it free, i.e. anybody could download, install and use. Some additional instructions, even very simple, may seriousely reduce people's interest, I guess.

No, it is a system library.
Why LCL-GTK2 depends on it, nobody knows. I doubt it will be fixed ever, especially because GTK2 is becoming obsolete and all effort should go to improve LCL-GTK3.
Thanks for the info!
You should distribute also a LCL-QT5 version of your application. Then people can choose which one to use. LCL-QT5 is especially good with desktops built with QT5, like KDE. I personally have Manjaro + KDE and build my Lazarus mostly with LCL-QT5.
Thanks! Now I see that I should learn working with QT5. And as I understand, it will run fine even in GTK systems, so it seems to be good decision :)
Title: Re: Problem with Lazarus in Ubuntu
Post by: JuhaManninen on September 21, 2020, 09:50:02 pm
I just wanted to make it free, i.e. anybody could download, install and use. Some additional instructions, even very simple, may seriousely reduce people's interest, I guess.
Ubuntu users typically run "apt install" commands routinely. It should not be a problem.
You can also instruct them to use a proper Linux distro. Many people have an obsession with Ubuntu. In my opinion it is not a very good distro any more.

Quote
Thanks! Now I see that I should learn working with QT5. And as I understand, it will run fine even in GTK systems, so it seems to be good decision :)
Yes if the system has Qt5 libraries and the libQt5Pas C++ mapping lib.
At least Manjaro provides them all from its repository. Super-easy.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: Fred vS on September 21, 2020, 11:10:34 pm
BTW, LCL does not have a direct X11 widgetset either. X11 is used indirectly through other GUI libraries like GTKx and QTx.

Ha, ok, I was thinking that LCL did have  direct access to X11.
So maybe Wayland is more a target for fpGUI or MSEgui.

For LCL I think that GTK3 has done lot of work to be Wayland compatible.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 22, 2020, 06:21:53 am
>Are you using Ubuntu 20.04 with Wayland or Xorg display server?
Hi, just checked echo $XDG_SESSION_TYPE, it's X11, i.e. Xorg.
[/quote]

Sashulya, I think the key part of Fred's question was about which version of Ubuntu you are using.

There was an issue in U19.04 (hmm, was that U19.10?)  that could be solved by installing the module you mention, the problem related to Ubuntu leaving it out of the list of things that GTK2 depended on.  You should not be using U19.04 now, its out of date and no longer supported.

However, if you are seeing this same problem in a current version of Ubuntu, its bad, very bad !

Please tell us the version of Ubuntu you are using.  From the command line -
Code: [Select]
cat /etc/issue [enter]
Davo
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: PascalDragon on September 22, 2020, 09:14:18 am
Quote
Anyway, Andrew Haines has published his Wayland-fpc conversion, maybe Lazarus team could take a look at this:
You mean to create a new LCL-Wayland widgetset? Yes, good idea, but somebody must volunteer to do it. Who?
BTW, LCL does not have a direct X11 widgetset either. X11 is used indirectly through other GUI libraries like GTKx and QTx.

What about CustomDrawn-X11 then? At least according to the wiki (https://wiki.freepascal.org/Custom_Drawn_Interface/X11) it's supposed to be working in principle.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 22, 2020, 10:00:41 am
I am not sure how this discussion about Wayland and our widgetsets will help the original question asker.  But ...

Both GTK2 and Qt5 seem to work fine under Wayland, Generally, I would not expect otherwise.  However, the System Tray Icon does not, and apparently will not because Wayland cannot pass back the position the user clicked (on the tray icon) back to the application.  There may, therefore be other widgets and widget like things that will not work with Wayland, possibly.

I have a number of users who use my app, tomboy-ng, with Wayland (on Fedora) and have to use an ugly workaround because of the lack of system tray icon. But otherwise, it works OK. Apparently.

Davo

Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: JuhaManninen on September 22, 2020, 10:27:15 am
What about CustomDrawn-X11 then? At least according to the wiki (https://wiki.freepascal.org/Custom_Drawn_Interface/X11) it's supposed to be working in principle.
Ok, I didn't remember that one. The CustomDrawn widgetset does not work very well. I was not able to run any application with it last time I checked.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: Sashulya on September 22, 2020, 01:27:45 pm
There was an issue in U19.04 (hmm, was that U19.10?)  that could be solved by installing the module you mention, the problem related to Ubuntu leaving it out of the list of things that GTK2 depended on.  You should not be using U19.04 now, its out of date and no longer supported.

However, if you are seeing this same problem in a current version of Ubuntu, its bad, very bad !

Please tell us the version of Ubuntu you are using.  From the command line -
Code: [Select]
cat /etc/issue [enter]
Davo
Hi, it's Ubuntu 20.04.1 LTS. Quite a fresh installation, I use it about 2 months.
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 23, 2020, 02:08:45 am
Hi, it's Ubuntu 20.04.1 LTS. Quite a fresh installation, I use it about 2 months.

Oh, thats bad news indeed.  My test installs are U20.04, updated to U20.04.1, perhaps I had better get a real U20.04.1 installer and see if they have dropped the module out of that.  This could be very messy indeed.

Bad timing too, all the school kids are at home right now due to C19 lockdown and they are really putting some strain on the network bandwidth ;-)

Davo
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 23, 2020, 03:20:56 am
Hmm, interesting results !
I made a new VM based on U20.04.1, nothing added or installed except sshfs (to transfer binaries in). It does not have the GTK2 appmenu module installed.

Now, it fails to run your app, but runs mine (some 16K lines) with out problems. I need to look through your very, very minimal app and see what you are doing !  Mine does use cmem because its multithreaded, must be other basic differences ...

Davo
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 23, 2020, 03:50:38 am
OK, some answer, maybe not a good one !

I initially installed U20.04.1 and told it not to do updates as it installed (I have limited bandwidth). And like that, a pure U20.04.1 I see the problem you describe with a minimal Lazarus project. A form with a button on it.  But my app runs fine.

I tried a few easy checks of the diff between the minimal Laz app and mine, heaptrace, cmem, different debugging. No help.

So, I allowed the OS  to do its auto updates, it wanted to put some 250Meg on, must be a new kernel because it requested a reboot. And the problem went away !

Sashulya, have you allowed your OS to update itself since installing ?

I will have to repeat my tests to be sure but it seems that there is something dodgy in U20.04.1 and they have fixed it with some updates. Be a job to workout what that is and it might not be the updates at all but only further testing will reveal ...

Davo
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 23, 2020, 09:26:40 am
No, sorry, on further testing, its not so simple. It seems its a random error, only when you do a bunch of tests do you see the pattern. So, I have run a minimal Lazarus app, a button on a form, 30 times. For comparison, I also run my app, a Lazarus GTK2 16K lines of code, also 30 times.

On U20.04.1 'out of the box' -
* Minimal Laz app - failed 20 out of 30 runs.
* tomboy-ng app  - did not fail in 30 runs.

On U20.04-1 with all updates available on 23 September -
* Minimal Laz app - failed 5 out of 30 runs.
* tomboy-ng app  - did not fail in 30 runs.

On U20.04-1 with all updates available on 23 September and appmenu-gtk2-module -
* Minimal Laz app - failed 14 out of 30 runs.
* tomboy-ng app  - did not fail in 30 runs.

So, this raises some very worrying questions -
* Thirty runs seems enough to draw a reasonable conclusion that something has improved between the release of U20.04.1 and now. But while its an improvement, it has not solved the problem completely.
* Appmenu-gtk2-module does not solve the problem, may indeed make it worse ?
* My much more complicated application does not seem to suffer from this issue.

tomboy-ng is a little unconventional in that its first unit is not an LCL unit, it has no GUI aspect, it examines the command line arguments and if certain ones are there, it does whatever is requested and exits, all without a GUI appearing.  In a more usual startup, that first unit starts the GUI units.

It also has a lot more things happening, obviously, but that startup seems a bit likely to be the difference ???

Anyone care to comment, please ?

Davo
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: JuhaManninen on September 23, 2020, 10:17:40 am
Anyone care to comment, please ?
See my earlier comment about Ubuntu versus other distros.  :)
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: dbannon on September 23, 2020, 01:40:08 pm
Well, Juha, it certainly does seem that they are putting less and less effort into GTK2.
And the Gnome 3 desktop is certainly a problem on any distribution IMHO. 

I test my app at each release against a number of distributions and I have to say, I still think Ubuntu (Mate, not Gnome) feels the best. But maybe just because I'm so used to it...

Davo
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: Sashulya on September 24, 2020, 02:29:42 am
Sashulya, have you allowed your OS to update itself since installing ?
Yes, I made installation with updates, and later allowed further updates, which also required reboot.

You've got interesting results, which are different from mine, because for my installation adding the appmenu-gtk2-module removed the problem completely. I made more than 100 trials already I guess, without single delay.

Well, it seems the problem not just exists, but can vary depending on certain installation.

Thanks for your investigation!
Title: Re: Problem with Lazarus in Ubuntu Gnome
Post by: PascalDragon on September 24, 2020, 10:47:42 pm
What about CustomDrawn-X11 then? At least according to the wiki (https://wiki.freepascal.org/Custom_Drawn_Interface/X11) it's supposed to be working in principle.
Ok, I didn't remember that one. The CustomDrawn widgetset does not work very well. I was not able to run any application with it last time I checked.

Aside from a compile error (https://bugs.freepascal.org/view.php?id=37813) the X11 backend does work, though quite some components are not yet implemented (e.g. TCustomListBox or menus).
TinyPortal © 2005-2018