commit 1949b1d37c2f4639dff63a637ed46dae54158c37
parent ed620cdee7bb063499f54733c34230e437694c1a
Author: Kui-Feng Lee <thinker.li@gmail.com>
Date: Tue, 9 Dec 2025 17:36:37 +0000
Bug 2001083: Truncate window title to 2048 bytes to respect Wayland protocol limits r=stransky
Firefox was truncating window titles to 4095 bytes, which when passed to GDK
on Wayland resulted in messages that exceeded the 4096-byte Wayland protocol
message limit. This caused "Wayland protocol error: message length exceeds 4096"
crashes on Wayland/Sway.
Truncate title string further to far smaller size than GDK's
MAX_WL_BUFFER_SIZE constant (2048 bytes which accounts for protocol
overhead.) The existing UTF-8 validation ensures we don't truncate in
the middle of multi-byte sequences.
Differential Revision: https://phabricator.services.mozilla.com/D273359
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
@@ -364,7 +364,11 @@ static uint32_t gLastTouchID = 0;
// throw it away otherwise.
MOZ_RUNINIT static GUniquePtr<GdkEventCrossing> sStoredLeaveNotifyEvent;
-#define NS_WINDOW_TITLE_MAX_LENGTH 4095
+// GDK's MAX_WL_BUFFER_SIZE is 4083 (4096 minus header, string
+// argument length and NUL byte). Here truncates the string length
+// further to prevent Wayland protocol message size limit exceeded
+// errors. See bug 2001083.
+#define NS_WINDOW_TITLE_MAX_LENGTH 2048
// cursor cache
static GdkCursor* gCursorCache[eCursorCount];