https://bugs.documentfoundation.org/show_bug.cgi?id=160275

--- Comment #13 from Huanyu Liu <1293660...@qq.com> ---
After some investigation, I think I've found out the root causes of this crash!
(Yeah, root cause*s* indeed...)

First, I tried to search for the error message "width and height must be
positive and non-zero" and finally found it here:
https://invent.kde.org/plasma/kwin/-/blob/master/src/wayland/xdgshell.cpp#L863-L879
It seems that this error will be triggered when you are attempting to set the
size of something to a non-positive value, and the error message is
KWin-exclusive.

Then, I launched LO with `WAYLAND_DEBUG=1` and reproduced the crash. When
toggling fcitx in the main region of LO Writer, the following logs were
produced:

[3215568.634]  -> xdg_wm_base@3.create_positioner(new id xdg_positioner@51)
[3215568.638]  -> xdg_positioner@51.set_anchor_rect(209, 310, 1, 1)
[3215568.641]  -> xdg_positioner@51.set_anchor(6)
[3215568.643]  -> xdg_positioner@51.set_gravity(8)
[3215568.644]  -> xdg_positioner@51.set_size(62, 71)
[3215568.646]  -> xdg_positioner@51.set_constraint_adjustment(9)

When toggling fcitx in the comment region of LO Writer, the following logs were
produced (and then crashed):

[3215568.677]  -> xdg_wm_base@39.create_positioner(new id xdg_positioner@57)
[3215568.681]  -> xdg_positioner@57.set_anchor_rect(0, 0, 1, 0)
[3215568.684]  -> xdg_positioner@57.set_anchor(6)
[3215568.701]  -> xdg_positioner@57.set_gravity(8)
[3215568.703]  -> xdg_positioner@57.set_size(62, 71)
[3215568.705]  -> xdg_positioner@57.set_reactive()
[3215568.706]  -> xdg_positioner@57.set_constraint_adjustment(9)

Note that `set_anchor_rect(0, 0, 1, 0)` will indeed trigger the error message
mentioned above. I thought that these logs are related to fcitx positioning its
candidate window and found the relevant code here:
https://github.com/fcitx/fcitx5-qt/blob/master/qt5/platforminputcontext/fcitxcandidatewindow.cpp#L496-L590

According to the code of fcitx5-qt, it is indeed difficult to reproduce this
crash... You have to use KWin, Qt>=6.6.0, fcitx5-qt and Wayland all at the same
time... By the way, fcitx5-qt is not completely adapting to Qt6, but adding
patches for Qt6 to the existing Qt5 code, so the relevant code is in the qt5
directory.

fcitx5-qt is roughly doing the following things: (1) Request the current cursor
position of the "host" window from Qt; (2) Convert it to the native coordinate;
(3) Clamp the cursor position within the window if it is out of bound; (4) Show
the candidate window at the (possibly clamped) cursor position. However, there
is a bug at Step (3) such that only the width is properly handled (while the
height is possibly set to 0 thus causing the crash). Actually, the clamping
process is seldom encountered, so most of the time everything goes OK. I'll
report this bug to fcitx5-qt later.

At the LO side, the problem is that the cursor position is not correctly
reported to Qt at certain places (input line of Calc, comment region of Writer
& Draw & Impress and input region of Math). Actually, the cursor is not
blinking at (and only at) these places; this might be related to the crash.

Under X11, LO does not crash, but the candidate window of fcitx is indeed
displayed at the wrong position. This is not the case when using
`SAL_USE_VCLPLUGIN=gtk3` under Wayland, so it should be a Qt-exclusive issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to