unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Qt can now survive Wayland compositor restarts
@ 2023-03-10 16:31 Sean Whitton
  2023-03-10 21:46 ` Dmitry Gutov
  2023-03-10 23:48 ` Po Lu
  0 siblings, 2 replies; 16+ messages in thread
From: Sean Whitton @ 2023-03-10 16:31 UTC (permalink / raw)
  To: emacs-devel

Apropos the infamous Gtk bug, I saw this piece of news I thought I
should share:
<https://codereview.qt-project.org/c/qt/qtwayland/+/377104>.

-- 
Sean Whitton



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-10 16:31 Qt can now survive Wayland compositor restarts Sean Whitton
@ 2023-03-10 21:46 ` Dmitry Gutov
  2023-03-10 22:17   ` Arsen Arsenović
  2023-03-10 23:46   ` Po Lu
  2023-03-10 23:48 ` Po Lu
  1 sibling, 2 replies; 16+ messages in thread
From: Dmitry Gutov @ 2023-03-10 21:46 UTC (permalink / raw)
  To: Sean Whitton, emacs-devel

On 10/03/2023 18:31, Sean Whitton wrote:
> Apropos the infamous Gtk bug, I saw this piece of news I thought I
> should share:
> <https://codereview.qt-project.org/c/qt/qtwayland/+/377104>.

That might not give it an advantage over GTK still: over here, all 
applications survive Alt+F2 r RET in GNOME, including Emacs.

What's (allegedly) a problem for Emacs, is the crash when the X server 
goes away. Not just the compositor.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-10 21:46 ` Dmitry Gutov
@ 2023-03-10 22:17   ` Arsen Arsenović
  2023-03-11  2:06     ` Björn Bidar
  2023-03-11  7:05     ` Eli Zaretskii
  2023-03-10 23:46   ` Po Lu
  1 sibling, 2 replies; 16+ messages in thread
From: Arsen Arsenović @ 2023-03-10 22:17 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Sean Whitton, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1295 bytes --]


Dmitry Gutov <dgutov@yandex.ru> writes:

> On 10/03/2023 18:31, Sean Whitton wrote:
>> Apropos the infamous Gtk bug, I saw this piece of news I thought I
>> should share:
>> <https://codereview.qt-project.org/c/qt/qtwayland/+/377104>.
>
> That might not give it an advantage over GTK still: over here, all applications
> survive Alt+F2 r RET in GNOME, including Emacs.
>
> What's (allegedly) a problem for Emacs, is the crash when the X server goes
> away. Not just the compositor.

That's a different kind of compositor.  Wayland compositors are also
display servers.

GTK can definitely not survive that; the only source of instability I
see in Emacs is GTK calling _exit () because of a Wayland connection
timeout while in some blocking code (such as in smtpmail).

I was considering trying to do a separation of UI and Elisp threads as a
solution, but, seeing this happen makes me think a Qt port is easier.

I'd still like opinions on the former idea, though.  It might be
worthwhile, but I am operating with little knowledge of that part of the
code-base, so I'm unsure if there's some deeper reason behind this not
being the case today.

Though, this still makes Emacs as a server not very resilient, sadly...

Have a lovely night.
-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-10 21:46 ` Dmitry Gutov
  2023-03-10 22:17   ` Arsen Arsenović
@ 2023-03-10 23:46   ` Po Lu
  1 sibling, 0 replies; 16+ messages in thread
From: Po Lu @ 2023-03-10 23:46 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Sean Whitton, emacs-devel

Dmitry Gutov <dgutov@yandex.ru> writes:

> That might not give it an advantage over GTK still: over here, all
> applications survive Alt+F2 r RET in GNOME, including Emacs.

It does - the Wayland compositor is also the display server.

Ironically, Qt deals badly with X window manager restarts, however, when
the new window manager supports a different set of features from the old
one.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-10 16:31 Qt can now survive Wayland compositor restarts Sean Whitton
  2023-03-10 21:46 ` Dmitry Gutov
@ 2023-03-10 23:48 ` Po Lu
  1 sibling, 0 replies; 16+ messages in thread
From: Po Lu @ 2023-03-10 23:48 UTC (permalink / raw)
  To: Sean Whitton; +Cc: emacs-devel

Sean Whitton <spwhitton@spwhitton.name> writes:

> Apropos the infamous Gtk bug, I saw this piece of news I thought I
> should share:
> <https://codereview.qt-project.org/c/qt/qtwayland/+/377104>.

I think this is a good thing for Qt users, but not good enough for us.
The problem is that Qt will keep trying to reconnect in a loop, instead
of closing the display connection, and telling Emacs that the display
has been closed.  That doesn't work if the display server has actually
gone away and has not crashed, only to restart moments later.  Emacs
must be given full control over display connections.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-10 22:17   ` Arsen Arsenović
@ 2023-03-11  2:06     ` Björn Bidar
  2023-03-11  7:05     ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Björn Bidar @ 2023-03-11  2:06 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: Dmitry Gutov, Sean Whitton, emacs-devel


See also bug#56967.

https://lists.gnu.org/r/bug-gnu-emacs/2022-08/msg00305.html



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-10 22:17   ` Arsen Arsenović
  2023-03-11  2:06     ` Björn Bidar
@ 2023-03-11  7:05     ` Eli Zaretskii
  2023-03-11  7:35       ` Po Lu
  1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2023-03-11  7:05 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: dgutov, spwhitton, emacs-devel

> From: Arsen Arsenović <arsen@aarsen.me>
> Cc: Sean Whitton <spwhitton@spwhitton.name>, emacs-devel@gnu.org
> Date: Fri, 10 Mar 2023 23:17:17 +0100
> 
> I was considering trying to do a separation of UI and Elisp threads as a
> solution, but, seeing this happen makes me think a Qt port is easier.
> 
> I'd still like opinions on the former idea, though.  It might be
> worthwhile, but I am operating with little knowledge of that part of the
> code-base, so I'm unsure if there's some deeper reason behind this not
> being the case today.

FYI: the MS-Windows build of Emacs uses a separate thread for input
and UI.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11  7:05     ` Eli Zaretskii
@ 2023-03-11  7:35       ` Po Lu
  2023-03-11 10:58         ` Arsen Arsenović
  0 siblings, 1 reply; 16+ messages in thread
From: Po Lu @ 2023-03-11  7:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Arsen Arsenović, dgutov, spwhitton, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arsen Arsenović <arsen@aarsen.me>
>> Cc: Sean Whitton <spwhitton@spwhitton.name>, emacs-devel@gnu.org
>> Date: Fri, 10 Mar 2023 23:17:17 +0100
>> 
>> I was considering trying to do a separation of UI and Elisp threads as a
>> solution, but, seeing this happen makes me think a Qt port is easier.
>> 
>> I'd still like opinions on the former idea, though.  It might be
>> worthwhile, but I am operating with little knowledge of that part of the
>> code-base, so I'm unsure if there's some deeper reason behind this not
>> being the case today.
>
> FYI: the MS-Windows build of Emacs uses a separate thread for input
> and UI.

Likewise for the Haiku and Android ports, FWIW.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11  7:35       ` Po Lu
@ 2023-03-11 10:58         ` Arsen Arsenović
  2023-03-11 11:12           ` Po Lu
  0 siblings, 1 reply; 16+ messages in thread
From: Arsen Arsenović @ 2023-03-11 10:58 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]


Po Lu <luangruo@yahoo.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Arsen Arsenović <arsen@aarsen.me>
>>> Cc: Sean Whitton <spwhitton@spwhitton.name>, emacs-devel@gnu.org
>>> Date: Fri, 10 Mar 2023 23:17:17 +0100
>>> 
>>> I was considering trying to do a separation of UI and Elisp threads as a
>>> solution, but, seeing this happen makes me think a Qt port is easier.
>>> 
>>> I'd still like opinions on the former idea, though.  It might be
>>> worthwhile, but I am operating with little knowledge of that part of the
>>> code-base, so I'm unsure if there's some deeper reason behind this not
>>> being the case today.
>>
>> FYI: the MS-Windows build of Emacs uses a separate thread for input
>> and UI.
>
> Likewise for the Haiku and Android ports, FWIW.

Reassuring, thanks for the info.  I'll try making some time to do the
same for PGTK, though I can't promise anything.
-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 10:58         ` Arsen Arsenović
@ 2023-03-11 11:12           ` Po Lu
  2023-03-11 11:23             ` Arsen Arsenović
  0 siblings, 1 reply; 16+ messages in thread
From: Po Lu @ 2023-03-11 11:12 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

Arsen Arsenović <arsen@aarsen.me> writes:

> Po Lu <luangruo@yahoo.com> writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>>>> From: Arsen Arsenović <arsen@aarsen.me>
>>>> Cc: Sean Whitton <spwhitton@spwhitton.name>, emacs-devel@gnu.org
>>>> Date: Fri, 10 Mar 2023 23:17:17 +0100
>>>> 
>>>> I was considering trying to do a separation of UI and Elisp threads as a
>>>> solution, but, seeing this happen makes me think a Qt port is easier.
>>>> 
>>>> I'd still like opinions on the former idea, though.  It might be
>>>> worthwhile, but I am operating with little knowledge of that part of the
>>>> code-base, so I'm unsure if there's some deeper reason behind this not
>>>> being the case today.
>>>
>>> FYI: the MS-Windows build of Emacs uses a separate thread for input
>>> and UI.
>>
>> Likewise for the Haiku and Android ports, FWIW.
>
> Reassuring, thanks for the info.  I'll try making some time to do the
> same for PGTK, though I can't promise anything.

Do what?

If you want to fix the GTK crash, you will have to run the GTK stuff in
a separate *process*.  Now that would be a real pain.

Thanks.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 11:12           ` Po Lu
@ 2023-03-11 11:23             ` Arsen Arsenović
  2023-03-11 11:37               ` Po Lu
  2023-03-12  1:41               ` Madhu
  0 siblings, 2 replies; 16+ messages in thread
From: Arsen Arsenović @ 2023-03-11 11:23 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]


Po Lu <luangruo@yahoo.com> writes:

> Arsen Arsenović <arsen@aarsen.me> writes:
>
>> Po Lu <luangruo@yahoo.com> writes:
>>
>>> Eli Zaretskii <eliz@gnu.org> writes:
>>>
>>>>> From: Arsen Arsenović <arsen@aarsen.me>
>>>>> Cc: Sean Whitton <spwhitton@spwhitton.name>, emacs-devel@gnu.org
>>>>> Date: Fri, 10 Mar 2023 23:17:17 +0100
>>>>> 
>>>>> I was considering trying to do a separation of UI and Elisp threads as a
>>>>> solution, but, seeing this happen makes me think a Qt port is easier.
>>>>> 
>>>>> I'd still like opinions on the former idea, though.  It might be
>>>>> worthwhile, but I am operating with little knowledge of that part of the
>>>>> code-base, so I'm unsure if there's some deeper reason behind this not
>>>>> being the case today.
>>>>
>>>> FYI: the MS-Windows build of Emacs uses a separate thread for input
>>>> and UI.
>>>
>>> Likewise for the Haiku and Android ports, FWIW.
>>
>> Reassuring, thanks for the info.  I'll try making some time to do the
>> same for PGTK, though I can't promise anything.
>
> Do what?

A separate UI thread.

> If you want to fix the GTK crash, you will have to run the GTK stuff in
> a separate *process*.  Now that would be a real pain.

It would be indeed.

The likelihood of crashes would be lowered if the display server event
loop is not kept busy by the Elisp interpreter, though, which is why a
separate thread would help (for instance, I suspect that the reason I
see crashes when sending mail on occasion is because smtpmail blocks the
main thread and a bunch of mouse events get queued up in the meanwhile,
causing libwayland to give up).

In either case, the better fix would be teaching GTK not to do silly
things on error conditions, and instead consult the user, but I'm not
sure how doable that is.

> Thanks.


-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 11:23             ` Arsen Arsenović
@ 2023-03-11 11:37               ` Po Lu
  2023-03-11 12:25                 ` Arsen Arsenović
  2023-03-12  1:41               ` Madhu
  1 sibling, 1 reply; 16+ messages in thread
From: Po Lu @ 2023-03-11 11:37 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

Arsen Arsenović <arsen@aarsen.me> writes:

> It would be indeed.
>
> The likelihood of crashes would be lowered if the display server event
> loop is not kept busy by the Elisp interpreter, though, which is why a
> separate thread would help (for instance, I suspect that the reason I
> see crashes when sending mail on occasion is because smtpmail blocks the
> main thread and a bunch of mouse events get queued up in the meanwhile,
> causing libwayland to give up).

If the display server crashes, the connection is closed, and GDK gives
up when it calls `wl_display_flush' at some point and gets SIGPIPE.
It's not related to events being queued up or whatever.

> In either case, the better fix would be teaching GTK not to do silly
> things on error conditions, and instead consult the user, but I'm not
> sure how doable that is.

Very easy, as was proven when this feature actually worked as intended
sometime during the 2.14 series.  It's just that the GTK developers need
their power fix and refuse to actually fix the problem, because ``only
Emacs needs this fixed.''



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 11:37               ` Po Lu
@ 2023-03-11 12:25                 ` Arsen Arsenović
  2023-03-11 12:33                   ` Po Lu
  0 siblings, 1 reply; 16+ messages in thread
From: Arsen Arsenović @ 2023-03-11 12:25 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]


Po Lu <luangruo@yahoo.com> writes:

> Arsen Arsenović <arsen@aarsen.me> writes:
>
>> It would be indeed.
>>
>> The likelihood of crashes would be lowered if the display server event
>> loop is not kept busy by the Elisp interpreter, though, which is why a
>> separate thread would help (for instance, I suspect that the reason I
>> see crashes when sending mail on occasion is because smtpmail blocks the
>> main thread and a bunch of mouse events get queued up in the meanwhile,
>> causing libwayland to give up).
>
> If the display server crashes, the connection is closed, and GDK gives
> up when it calls `wl_display_flush' at some point and gets SIGPIPE.
> It's not related to events being queued up or whatever.

Yes, it's indeed not related in the display server crash case.  That is
not the case that concerns me in this instance, though.

The display server keeps working just fine when I see GTK call _exit.

You can simulate this by starting Emacs, suspending it, resizing the
window a bunch and clicking around, and then unsuspending it:

  ~$ emacs
  ^Z
  [1]+  Stopped                 emacs
  << Some mouse/resize spam here for a few seconds >>
  ~ 148 $ fg
  emacs
  Gdk-Message: 13:26:40.087: Lost connection to Wayland compositor.
  ~ 1 $ 

>> In either case, the better fix would be teaching GTK not to do silly
>> things on error conditions, and instead consult the user, but I'm not
>> sure how doable that is.
>
> Very easy, as was proven when this feature actually worked as intended
> sometime during the 2.14 series.  It's just that the GTK developers need
> their power fix and refuse to actually fix the problem, because ``only
> Emacs needs this fixed.''

That's what I was fearing too ;).  I know of at least one instance of
this affecting GTK apps, so "only Emacs needs this" is false.  Do you
have a link to the bug handy?  I'd like to read the history.
-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 12:25                 ` Arsen Arsenović
@ 2023-03-11 12:33                   ` Po Lu
  2023-03-11 12:36                     ` Arsen Arsenović
  0 siblings, 1 reply; 16+ messages in thread
From: Po Lu @ 2023-03-11 12:33 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

Arsen Arsenović <arsen@aarsen.me> writes:

> Yes, it's indeed not related in the display server crash case.  That is
> not the case that concerns me in this instance, though.
>
> The display server keeps working just fine when I see GTK call _exit.
>
> You can simulate this by starting Emacs, suspending it, resizing the
> window a bunch and clicking around, and then unsuspending it:
>
>   ~$ emacs
>   ^Z
>   [1]+  Stopped                 emacs
>   << Some mouse/resize spam here for a few seconds >>
>   ~ 148 $ fg
>   emacs
>   Gdk-Message: 13:26:40.087: Lost connection to Wayland compositor.
>   ~ 1 $ 

Well, in this case the compositor has still closed the connection, so
the consequences are the same.

The Lisp interpreter should periodically poll for input and also read
input as it becomes available, so this should not be a problem with
long-running Lisp code.  If it is, please report a bug.  Thanks.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 12:33                   ` Po Lu
@ 2023-03-11 12:36                     ` Arsen Arsenović
  0 siblings, 0 replies; 16+ messages in thread
From: Arsen Arsenović @ 2023-03-11 12:36 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, dgutov, spwhitton, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 670 bytes --]


Po Lu <luangruo@yahoo.com> writes:

> Well, in this case the compositor has still closed the connection, so
> the consequences are the same.
>
> The Lisp interpreter should periodically poll for input and also read
> input as it becomes available, so this should not be a problem with
> long-running Lisp code.  If it is, please report a bug.  Thanks.

Hm, interesting.  I'll try to get an actionable bug report out of it,
then.  I don't really have great reproduction steps currently, usually
it's just "hope it doesn't happen when sending an email", which I don't
think is sufficient for a bug report.

Thanks for the heads-up.
-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Qt can now survive Wayland compositor restarts
  2023-03-11 11:23             ` Arsen Arsenović
  2023-03-11 11:37               ` Po Lu
@ 2023-03-12  1:41               ` Madhu
  1 sibling, 0 replies; 16+ messages in thread
From: Madhu @ 2023-03-12  1:41 UTC (permalink / raw)
  To: emacs-devel

* Arsen Arsenović <86a60j1q55.fsf @aarsen.me> :
Wrote on Sat, 11 Mar 2023 12:23:28 +0100:
> Po Lu <luangruo@yahoo.com> writes:
>>> Reassuring, thanks for the info.  I'll try making some time to do the
>>> same for PGTK, though I can't promise anything.
>>
>> Do what?
>
> A separate UI thread.

AIUI all gtk calls have to happen on the default main context and so on
the.  Even if this is a different thread, the issues around locking the
default main context make the glib mainloop go mad.

There's a lot of history, too much of it, so it obscures. I think the
bug I filed is at https://gitlab.gnome.org/GNOME/gtk/-/issues/2315

[In your case I think the _exit() there only to prevent the glib main
loop from spamming errors when it gets into an inconsistent state, the
issues are in glib, but I've not refreshed my unreliable memory]




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-03-12  1:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 16:31 Qt can now survive Wayland compositor restarts Sean Whitton
2023-03-10 21:46 ` Dmitry Gutov
2023-03-10 22:17   ` Arsen Arsenović
2023-03-11  2:06     ` Björn Bidar
2023-03-11  7:05     ` Eli Zaretskii
2023-03-11  7:35       ` Po Lu
2023-03-11 10:58         ` Arsen Arsenović
2023-03-11 11:12           ` Po Lu
2023-03-11 11:23             ` Arsen Arsenović
2023-03-11 11:37               ` Po Lu
2023-03-11 12:25                 ` Arsen Arsenović
2023-03-11 12:33                   ` Po Lu
2023-03-11 12:36                     ` Arsen Arsenović
2023-03-12  1:41               ` Madhu
2023-03-10 23:46   ` Po Lu
2023-03-10 23:48 ` Po Lu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).