[Gnome 51] (gnome) Wayland protocol error: xdg_session_v1#69: error 1: Name of toplevel is already in use
Categories
(Core :: Widget: Gtk, defect)
Tracking
()
People
(Reporter: stransky, Assigned: mmitar)
References
()
Details
Attachments
(1 file, 3 external files, 2 obsolete files)
|
2.89 MB,
text/plain
|
Details |
Fedora 45+ / Gnome 51:
Aug 17 10:09:34 Fedora org.mozilla.firefox.desktop[22256]: [GFX1-]: (gnome) Wayland protocol error: xdg_session_v1#69: error 1: Name of toplevel is already in use
Aug 17 10:09:34 Fedora gnome-shell[4193]: WL: error in client communication (pid 22256)
| Reporter | ||
Updated•3 months ago
|
| Reporter | ||
Comment 1•3 months ago
|
||
Feature disabled on release, enabled on Nightly/Beta only.
STR:
- Start Firefox 154
- Not click „Restore session“
- Instead, open a new tab to access about:config
- Switch widget.wayland.session-management.enabled off
- Quite Firefox and start it again
- Then click on „Restore Session“
| Reporter | ||
Comment 2•3 months ago
|
||
I see that. SRT:
- disable session restore
- open various windows
- quit
- open again (without session restore)
- Go to hamburger menu -> history -> restore previous session
- crash
| Reporter | ||
Comment 3•3 months ago
|
||
| Reporter | ||
Comment 4•3 months ago
|
||
Looks like we can't restore the session when a toplevel window is already visible.
Comment 5•3 months ago
|
||
I noticed this crash with Firefox ( not beta, just latest upstream ) .
It only started appearing when I added session management protocol to the compositor.
I think this may differ from compositor to another compositor implementation but I need to check. Eitherway, if I find anything useful i'll share it here.
And additional thing while you are inspecting this:
It would be pretty awesome if Firefox, in contrary to what chrome does, will allow the option for per-window session rather than a full-on restoration.
So whenever I open a window and the compositor bind the session for it, it will open that window tabs instead of restoring every window I have.
Hope it makes sense, if not , i can explain with a video.
Comment 6•3 months ago
|
||
And there is no session management toggle (" widget.wayland.session-management.enabled") in the version im using (153.0.3)
| Reporter | ||
Comment 7•3 months ago
|
||
Session management is disabled by default on release - I enabled in on Fedora only as Fedora also needed backports gtk3 fixes. but will be happy for any bug report regard it.
| Reporter | ||
Comment 8•3 months ago
|
||
Filed as https://gitlab.gnome.org/GNOME/mutter/-/work_items/4992 - looks like Mutter bug.
| Reporter | ||
Comment 9•3 months ago
|
||
XDG session management on wayland is not implemented in Firefox 153.n line.
Comment 10•3 months ago
|
||
From firefox: 153. n - i might've enable session management on beta when i had beta installed before.
[ 123220.175] {Default Queue} wl_registry#2.global(29, "xdg_session_manager_v1", 1)
[ 123220.187] {Default Queue} wl_registry#2.global(31, "xx_session_manager_v1", 1)
[ 123276.344] {Default Queue} wl_registry#29.global(29, "xdg_session_manager_v1", 1)
[ 123276.351] {Default Queue} wl_registry#29.global(31, "xx_session_manager_v1", 1)
[ 123276.354] {Default Queue} -> wl_registry#29.bind(31, "xx_session_manager_v1", 1, new id [unknown]#43)
[ 123276.381] {Default Queue} -> xx_session_manager_v1#43.get_session(new id xx_session_v1#44, 1, nil)
[ 123285.861] {Default Queue} xx_session_v1#44.created("01a0249d-876f-7f40-a4ac-fcb88eec8c07")
[ 123508.885] wl_registry#52.global(29, "xdg_session_manager_v1", 1)
[ 123508.897] wl_registry#52.global(31, "xx_session_manager_v1", 1)
[ 123536.130] wl_registry#54.global(29, "xdg_session_manager_v1", 1)
[ 123536.132] wl_registry#54.global(31, "xx_session_manager_v1", 1)
[ 123590.200] {Default Queue} wl_registry#30.global(29, "xdg_session_manager_v1", 1)
[ 123590.203] {Default Queue} wl_registry#30.global(31, "xx_session_manager_v1", 1)
Same crash:
[ 139554.385] {Default Queue} -> xx_session_v1#44.add_toplevel(new id xx_toplevel_session_v1#130, xdg_toplevel#73, "2")
[ 139554.907] {Default Queue} -> xx_session_v1#44.add_toplevel(new id xx_toplevel_session_v1#99, xdg_toplevel#91, "2")
[ 139558.914] {Display Queue} wl_display#1.error(xx_session_v1#44, 2, "toplevel name '2' already in use in this session")
[GFX1-]: (y5compositor) Wayland protocol error: xx_session_v1#44: error 2: toplevel name '2' already in use in this session
I still dont claim it is a firefox issue- i just implemented the protocol on a compositor, so it could be implementation problem.
Comment 11•3 months ago
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #8)
Filed as https://gitlab.gnome.org/GNOME/mutter/-/work_items/4992 - looks like Mutter bug.
I ran into this today after firefox updated last night. I'm running Fedora KDE 44, so it's not an issue limited to mutter. I had to start firefox in xwayland mode
MOZ_ENABLE_WAYLAND=0 firefox
then switch
widget.wayland.session-management.enabled = false
as mentioned above
Comment 12•2 months ago
|
||
I fixed it in the compositor side by not sending the protocol error "NameInUse", even when firefox started 2 windows requesting the same top level name ( under session protocol specs ). meaning to make firefox work while still having session protocol support, I can't fully comply with the protocol.
I used Firefox 153.0.3 which doesn't even have session support ( and the setting not available in about:config ) yet something still tries to bind it. I might've open Firefox beta before and then uninstalled it, so it may have its remains on prefs.
| Reporter | ||
Comment 13•2 months ago
|
||
Will look at it again today. But I don't quite understand how's that issues the protocol error when wayland log doesn't show that...or I'm just blind.
| Reporter | ||
Comment 14•2 months ago
|
||
(In reply to yarden apelker from comment #10)
From firefox: 153. n - i might've enable session management on beta when i had beta installed before.
[ 123220.175] {Default Queue} wl_registry#2.global(29, "xdg_session_manager_v1", 1) [ 123220.187] {Default Queue} wl_registry#2.global(31, "xx_session_manager_v1", 1) [ 123276.344] {Default Queue} wl_registry#29.global(29, "xdg_session_manager_v1", 1) [ 123276.351] {Default Queue} wl_registry#29.global(31, "xx_session_manager_v1", 1) [ 123276.354] {Default Queue} -> wl_registry#29.bind(31, "xx_session_manager_v1", 1, new id [unknown]#43) [ 123276.381] {Default Queue} -> xx_session_manager_v1#43.get_session(new id xx_session_v1#44, 1, nil) [ 123285.861] {Default Queue} xx_session_v1#44.created("01a0249d-876f-7f40-a4ac-fcb88eec8c07") [ 123508.885] wl_registry#52.global(29, "xdg_session_manager_v1", 1) [ 123508.897] wl_registry#52.global(31, "xx_session_manager_v1", 1) [ 123536.130] wl_registry#54.global(29, "xdg_session_manager_v1", 1) [ 123536.132] wl_registry#54.global(31, "xx_session_manager_v1", 1) [ 123590.200] {Default Queue} wl_registry#30.global(29, "xdg_session_manager_v1", 1) [ 123590.203] {Default Queue} wl_registry#30.global(31, "xx_session_manager_v1", 1)Same crash:
[ 139554.385] {Default Queue} -> xx_session_v1#44.add_toplevel(new id xx_toplevel_session_v1#130, xdg_toplevel#73, "2") [ 139554.907] {Default Queue} -> xx_session_v1#44.add_toplevel(new id xx_toplevel_session_v1#99, xdg_toplevel#91, "2") [ 139558.914] {Display Queue} wl_display#1.error(xx_session_v1#44, 2, "toplevel name '2' already in use in this session") [GFX1-]: (y5compositor) Wayland protocol error: xx_session_v1#44: error 2: toplevel name '2' already in use in this sessionI still dont claim it is a firefox issue- i just implemented the protocol on a compositor, so it could be implementation problem.
This is actually a Bug 2059617. This one is about Mutter specific bug in the session protocol.
| Reporter | ||
Comment 15•2 months ago
|
||
Let's disable session restore on mutter until it's fixed. KDE works without any problem.
Comment 16•2 months ago
|
||
I did experience this issue using CTRL+SHIFT+N to reopen the last closed window ...
And today I'm experiencing it just by starting Firefox ... because I had multiple windows opened in previous session ...
Restarting without Wayland backend allowed me to close the other windows.
Comment 17•2 months ago
|
||
I'm using Firefox Nightly under Fedora Rawhide with Gnome session.
https://crash-stats.mozilla.org/report/index/a6b9a8c7-21cb-4776-b8a6-edda70260825
...
https://crash-stats.mozilla.org/report/index/04fed598-5f60-4454-bab8-95a280260912
Updated•2 months ago
|
| Reporter | ||
Comment 18•2 months ago
•
|
||
(In reply to Yann Droneaud from comment #17)
I'm using Firefox Nightly under Fedora Rawhide with Gnome session.
https://crash-stats.mozilla.org/report/index/a6b9a8c7-21cb-4776-b8a6-edda70260825
...
https://crash-stats.mozilla.org/report/index/04fed598-5f60-4454-bab8-95a280260912
Bug 2070815 is not fixed - updated the patch there.
Thanks.
Comment 19•2 months ago
|
||
A datapoint against this being mutter-specific, and a third name variant: the empty string.
I hit it on a non-mutter compositor (synoik, which follows mutter's session-management implementation) by setting XDG_CURRENT_DESKTOP so that Nightly bypasses the IsGnomeDesktopEnvironment() gate added in comment 15:
xdg_session_v1#68: error 1: a toplevel with this name is already in the session:
<session-uuid>/ is held by toplevel xdg_toplevel@106, cannot also be toplevel xdg_toplevel@91
Nothing after the / — the name is "", on two different toplevels.
CreateRestoreSession() passes mWorkspaceID.get() straight to the protocol. Its only guard rewrites a numeric legacy ID (bug 2059617), and nsCString::ToInteger("") fails, so an empty ID goes through untouched. mWorkspaceID is empty because SessionStore.sys.mjs only calls moveToWorkspace() under if (winData.workspaceID && ...), and while the DE gate was active GetWorkspaceID() truncated instead of minting — so workspaceID is now absent on every window in recovery.jsonlz4.
That makes the gate self-perpetuating: any profile that ran while it was active will crash on the first run after session management is re-enabled, on any compositor.
Extending the existing guard covers it:
(void)mWorkspaceID.ToInteger(&ret);
if (mWorkspaceID.IsEmpty() || NS_SUCCEEDED(ret)) {
mWorkspaceID = GenerateWorkspaceID();
aRestoreWindow = false;
}
For this variant at least there is nothing for mutter to fix: xdg_session_add_toplevel() does a plain hash lookup on the name with no emptiness check, and raising name_in_use on a duplicate is what the protocol asks for.
| Reporter | ||
Comment 20•2 months ago
|
||
okay, filed as https://bugzilla.mozilla.org/show_bug.cgi?id=2074753
| Assignee | ||
Comment 21•20 days ago
|
||
I looked into this. I think Mutter's error is correct and the fix belongs in Firefox. I had Claude Opus 5.5 generate three patches against main to fix this locally for me. I am attaching them here if anyone finds them useful, but they are above my head to review them myself. See a reproduction below.
Why Mutter raises the error
For add_toplevel, xdg-session-management-v1 says: "The name given to the toplevel must not correspond to any previously existing toplevel names in the session. If the name matches an already known toplevel name in the session, a 'name_in_use' protocol error will be raised." Mutter stores the state of each toplevel of a session when its window is unmapped, so a name used in an earlier run of the session is known to it, and add_toplevel with that name has to fail. KWin raises name_in_use only for a name used by another toplevel of the same session object, and for a stored name it discards the stored state and accepts the name, which is why it works there. wayland-protocols#317 reads the protocol the way Mutter does: a client has to know which names are part of a session, or add_toplevel in a later connection fails. A comment there proposes relaxing the protocol so that add_toplevel discards stored state instead, as KWin does. That would avoid the crash with compositors which adopt it, but not with Mutter 51 as released, and it would not help with the second problem below.
What Firefox does
Bug 2074753 fixed the empty name from comment 19. The case here is a different one, a valid name from an earlier run of the session, and it still happens on main. When a previous session is restored from the History menu, or a closed window is reopened, the windows are shown right away, because no startup session restore is in progress and mWaitingToSessionRestore is false. The session store then calls moveToWorkspace() with the ID saved in the earlier session. nsWindowWaylandToplevel::MoveToWorkspace() stores that ID although the window does not wait for restore, and the next GetWorkspaceID() adds the window to the session with add_toplevel under the old ID.
Patch 1: MoveToWorkspace() stores the passed ID only for a window which waits for session restore, which is the only case in which the window is restored under it. Other windows keep their own ID.
A second problem: windows without a saved ID are never shown
While testing I found that a window created during startup session restore is shown only by MoveToWorkspace(), which the session store calls only when winData.workspaceID is set. nsWindow::SessionRestoreFinished() releases only the window which requested focus. Session management is disabled on GNOME, so every GNOME profile saves its windows without IDs, and removing the GNOME check alone would make the first start with browser.startup.page = 3 show at most the window which requested focus. In my headless test, where no window requested focus, 0 of 3 windows were shown (no xdg_toplevel was ever created for them, and the log shows each window stuck in NativeShow() waiting to session restore). With browser.startup.page = 3 and a fresh profile, the first window stayed hidden as well.
Patch 2: SessionRestoreFinished() shows every window which still waits for session restore.
Possible follow-up
Firefox never sends xdg_session_v1.remove_toplevel, neither for a window closed while the browser keeps running nor for an ID it stops using, and Mutter never prunes stored toplevels on its own (it records a last-used time per session but does not read it), so the session data grows with every window Firefox ever had, by about 270 bytes each in my test. Firefox could remove a toplevel when its window is closed for good, and remove the old ID in MoveToWorkspace() where patch 1 now ignores it. The latter needs Mutter to honor remove_toplevel for names from an earlier run, which it currently ignores; I filed that as https://gitlab.gnome.org/GNOME/mutter/-/work_items/5174. Regarding mutter#4992, the name_in_use error itself is what the protocol requires.
| Assignee | ||
Comment 22•20 days ago
|
||
| Assignee | ||
Comment 23•20 days ago
|
||
| Assignee | ||
Comment 24•20 days ago
|
||
Correction: I attached two patches, not three. The third only enabled session restore on GNOME again, reverting bug 2070815, which makes sense only once this bug is fixed.
| Reporter | ||
Comment 25•19 days ago
|
||
Please submit the patches via Phabricator:
https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html
Thanks.
| Assignee | ||
Comment 26•19 days ago
|
||
nsWindowWaylandToplevel::MoveToWorkspace() stored the passed ID also for a
window which does not wait for session restore. Such a window is already shown
or it is shown without restore, so GetWorkspaceID() later added it to the
session with xdg_session_v1.add_toplevel under that ID. The ID comes from the
previous session, and a compositor which still stores state for it has to
raise a name_in_use protocol error, as the protocol requires add_toplevel to
use a name which is not known in the session. Mutter does so and Firefox
crashes. This happens when a previous session is restored from the menu or a
closed window is reopened.
When the window had already been added under its own ID, the stored ID also
replaced it, and the session store then saved an ID under which the compositor
did not know the window.
MoveToWorkspace() now stores the ID only for a window which waits for session
restore, which is the only case in which the window is restored under it.
Updated•19 days ago
|
| Assignee | ||
Comment 27•19 days ago
|
||
A toplevel created while session restore is in progress is not shown until
nsWindowWaylandToplevel::MoveToWorkspace() passes it its saved ID. The session
store calls moveToWorkspace() only for a window with a saved workspace ID, so a
window without one stayed hidden. nsWindow::SessionRestoreFinished() released
only the window which requested focus.
Every profile used with session restore disabled, as it is on GNOME since bug
2070815, saves its windows without IDs, so the first start with session restore
enabled showed at most the window which requested focus. With
browser.startup.page set to 3 and no previous session, the first window could
stay hidden too.
SessionRestoreFinished() now shows every window which still waits for session
restore.
| Reporter | ||
Comment 28•18 days ago
|
||
Thanks, will look at it. Mitar, did you test that under Gnome 51? I don't have the system handy right now.
| Reporter | ||
Updated•18 days ago
|
| Assignee | ||
Comment 29•18 days ago
|
||
Yes, with mutter 51.1 (Fedora 45's package), run headless, and Firefox 159.0.1 with these two patches applied (and the GNOME check in nsAppShell::IsSessionRestoreSupported() removed), on GTK 3.24.52 with your commit backported, as no 3.24 release has it yet, driven through Marionette. mutter 51.1 offers xdg_session_manager_v1 version 1.
- Restore from the History menu: without the patches, Firefox fails with "Name of toplevel is already in use" and crashes. With them, the reopened windows are added under new IDs, and the next start restores all three, each answered with restored().
- Restore at startup from a profile saved without IDs, as every GNOME profile is now: without the patches, none of the three windows is shown. With them, all three are shown and added, and the next start restores them.
- Restore at startup from a profile with IDs: with the patches, all three windows are restored under their IDs.
Comment 30•18 days ago
|
||
Comment 31•18 days ago
|
||
| Reporter | ||
Updated•17 days ago
|
| Reporter | ||
Comment 32•17 days ago
|
||
Filed Bug 2089456 for the toplevel removal, that's good point.
| Reporter | ||
Comment 33•17 days ago
|
||
Mitar, the patches looks good, please file a third one to remove the gnome restriction for session restore.
Thanks.
| Reporter | ||
Updated•16 days ago
|
| Assignee | ||
Comment 34•16 days ago
|
||
| Assignee | ||
Comment 35•16 days ago
|
||
Bug 2070815 disabled Wayland session restore on GNOME, because restoring a
session from the History menu made Mutter raise a name_in_use protocol error
and Firefox crashed. The two previous patches for this bug fix that error and
show the windows of profiles saved without IDs while session restore was
disabled, so the GNOME check is removed again.
Session restore still needs a compositor which offers xdg_session_manager_v1,
on GNOME Mutter 51, and GTK 3 with the xdg-toplevel-realized signal, both
checked in the same function.
Comment 36•16 days ago
|
||
| Reporter | ||
Updated•16 days ago
|
Comment 37•16 days ago
|
||
| Reporter | ||
Updated•16 days ago
|
| Reporter | ||
Comment 38•16 days ago
|
||
We may add a release note for it.
Comment 39•16 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/68cddba213c8
https://hg.mozilla.org/mozilla-central/rev/c9d0238d0204
https://hg.mozilla.org/mozilla-central/rev/6ac749309747
| Reporter | ||
Comment 40•11 days ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: Enable Firefox session restore on Gnome 51+
[Affects Firefox for Android]: none
[Suggested wording]:
[Links (documentation, blog post, etc)]: When configured to restore previous sessions, Firefox now restores windows to their saved positions on GNOME 51 and later, matching existing support on KDE Plasma 6.8+.
Updated•11 days ago
|
Updated•6 days ago
|
Description
•