Nheko-Reborn / nheko

Desktop client for Matrix using Qt and C++20.

Home Page:https://nheko-reborn.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible race condition leads to weird formatting of join/part messages

geekosaur opened this issue · comments

Describe the bug

In a room with a puppeted heisenbridge, join and part messages are relayed from the linked IRC channel. Sometimes, when the user immediately rejoins, the join or part message gets formatted to the width of the corresponding part/join message, but because heisenbridge removed its display name, its (synthetic and fairly long) MXID is formatted instead. This doesn't happen consistently, which makes me think there's a race condition where it sizes the part message with the display name but that is gone by the time it displays it.

To Reproduce

  1. Join a room with a puppeted heisenbridge, such as #hackage:matrix.org
  2. Wait for a user to part and rejoin IRC.

What happened?

The message (not very consistently) is formatted to the width it would have been with the display name, but is output with the MXID.

Expected behavior

The display name should have been cached when the width was computed, and used for the actual output.

Screenshots

nheko-race-condition

Version

0.12.0-24c687d

Operating system

Linux

Installation method

Flatpak nightly repo or download

Qt version

No response

C++ compiler

No response

Desktop Environment

MATE with xmonad as window manager

Did you use profiles?

  • Profiles used?

Relevant log output

No response

Backtrace

No response

That's not a bug. When a user leaves a room, we remove their display name. As a result all their messages will be rendered without a displayname and just their mxid. This should also happen without any race if you just close and reopen a room, that someone left.

That it does that is not the bug. The bug is the resulting formatting, which is inconsistent and appears to possibly be a race.

Here's how a normal one looks. Note that it's formatted with the width of the mxid, not the display name.
Screenshot_2024-07-27_23-30-35

If it's not clear, in the first screenshot it's the part message for surfbluecrab_ that's wrong, not the one following it which is what I would expect.