Skip to content

Instantly share code, notes, and snippets.

@yjwong
Last active March 29, 2025 19:10
Show Gist options
  • Save yjwong/8893677b003f38559197ab55c2099ec2 to your computer and use it in GitHub Desktop.
Save yjwong/8893677b003f38559197ab55c2099ec2 to your computer and use it in GitHub Desktop.
Lark client patch for Wayland

Version 7.36.11

The process to make this version work is similar to version 7.28.10. Simply modify /usr/share/applications/bytedance-lark.desktop, adding the --ozone-platform-hint=auto flag to the Exec line.

Set app_id

To fix this, look for this pattern in libframe.so (ui::XDGToplevelWrapperImpl::SetAppId):

55 48 89 e5 49 89 f1 48 8b 7f 20 80 7e 17 00 79 03 4d
8b 09

Replace with:

55 48 89 e5 49 89 f1 48 8b 7f 20 4c 8d 0d 0e 57 8b fa
90 90
                                 ^ Replacement starts here

This hardcodes the string lookup for SetAppId to the string bytedance-feishu.

To update it to bytedance-lark, go to offset 0x029fef30, replacing the value:

62 79 74 65 64 61 6e 63 65 2d 66 65 69 73 68 75

With this:

62 79 74 65 64 61 6e 63 65 2d 6c 61 72 6B

Version 7.28.10

As of version 7.28.10, Lark no longer crashes with SIGILL. In addition, the process of running in Wayland natively has been greatly simplified. It suffices to modify /usr/share/applications/bytedance-lark.desktop, adding the --ozone-platform-hint=auto flag to the Exec line.

However, the flag doesn't seem to propagate to the video meeting client, nor is app_id set correctly.

Unfortunately, it seems to be built on Chromium 121.0.6167.86. For Chinese text input to work, we probably need Chromium 129+ which adds the new --wayland-text-input-version=3 parameter. We will need to wait for ByteDance to update.

Set app_id

To fix this, look for this pattern in libframe.so (ui::XDGToplevelWrapperImpl::SetAppId):

55 48 89 e5 49 89 f1 48 8b 7f 20 80 7e 17 00 79 03 4d
8b 09

Replace with:

55 48 89 e5 49 89 f1 48 8b 7f 20 4c 8d 0d 1e c6 55 fa
90 90
                                 ^ Replacement starts here

This hardcodes the string lookup for SetAppId to the string bytedance-feishu.

To update it to bytedance-lark, go to offset 0x29c0c10, replacing the value:

62 79 74 65 64 61 6e 63 65 2d 66 65 69 73 68 75

With this:

62 79 74 65 64 61 6e 63 65 2d 6c 61 72 6B

Version 7.22.9

When running the Lark/Feishu client under Linux using the flags:

--ozone-platform-hint=wayland

As of version 7.22.9, It crashes with SIGILL.

Crash fix

To fix this, look for this pattern in libframe.so:

48 8b 05 53 26 b7 09 48 89 87 90 00 00 00

Replace the two bytes before the pattern with:

90 90

I have no idea why this code path is being taken. However, replacing the path with no-ops seems to have no visible side effects.

Start via Wayland by default

To start without needing a wrapper script or CLI option, look for this pattern in libframe.so:

55 48 89 e5 41 57 41 56 41 55 41 54 53 48 81 ec 58 01
00 00 64 48 8b 04 25 28 00 00 00 48 89 45 d0 44 8b 35
00 39 bb 0c

Replace the 5th byte onwards with:

b8 02 00 00 00 5d c3

This is equivalent to:

mov eax, 2
pop rbp
ret

There is some code path in the video meeting client that calls XGetWindowProperty even under Wayland, causing a crash like:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x0
  Serial number of failed request:  104
  Current serial number in output stream:  104

To fix this, look for this pattern in libframe.so:

55 48 89 e5 41 57 41 56 41 55 41 54 53 48 83 ec 38 48
89 7d d0 8a 05 15 8b f3 00 84 c0 0f 84 ca 00 00 00

Replace the 5th byte onwards with:

b8 03 00 00 00 48 89 ec 5d c3

This is equivalent to:

mov eax, 3
pop rbp
ret

This stubs the call to XGetWindowProperty, hardcoding its return value to 3 (BadWindow).

Set app_id

This is needed for the tray icon to be correct.

To fix this, look for this pattern in libframe.so (ui::XDGToplevelWrapperImpl::SetAppId):

55 48 89 e5 49 89 f1 48 8b 7f 20 80 7e 17 00 79
03 4d 8b 09 8b 4f 40 be 03 00 00 00 31 d2 45 31
c0 31 c0

Replace the bytes that come after with:

4c 8d 0d c6 17 7f fa 5d e9 20 ce 9c 03

This hardcodes the string lookup for SetAppId to 0x2e97b00, which is the string bytedance-feishu. This string appears to be unused anywhere else.

To update it to bytedance-lark, go to offset 0x2d97b00, replacing the value:

62 79 74 65 64 61 6e 63 65 2d 66 65 69 73 68 75

With this:

62 79 74 65 64 61 6e 63 65 2d 6c 61 72 6B

Known issues

  • There is instability.
    • Sometimes, when dragging text, the Lark client will crash entirely.
    • Sometimes, when joining meetings, the meeting client disappears.
  • Hover state can sometimes get broken.
  • Tooltip positions in the video meeting client can be wrong.
  • Pop-up subtitles window in the video meeting client can't be dragged. However, using the drag modifier on the keyboard (usually Alt) works.
  • Chinese IME doesn't work. However, this applies to all Electron-based apps (electron/electron#33662).

Appendix

The following is for my own reference:

  • Memory address to file offsets:
    • .text: subtract 0x7FFFE5A01000 from the memory address.
    • .data: subtract 0x7FFFE5A00000 from the memory address.
  • Lark 7.22.9 seems to be built on Chromium 109.0.5414.128. This is found by attaching a remote debugger and checking the navigator object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment