Bug 451086 - Cannot connect to KRFB desktop running on Fedora 36 KDE.
Summary: Cannot connect to KRFB desktop running on Fedora 36 KDE.
Status: CONFIRMED
Alias: None
Product: krfb
Classification: Applications
Component: general (show other bugs)
Version: 21.12.1
Platform: RedHat Enterprise Linux Linux
: NOR major
Target Milestone: ---
Assignee: George Goldberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-03 14:54 UTC by Lukas Ruzicka
Modified: 2023-03-22 22:30 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Ruzicka 2022-03-03 14:54:59 UTC
SUMMARY

A KRFB session running on Fedora 36 cannot be connected to even if everything seems to be working normally.

Version-Release number of selected component (if applicable):
krfb 21.12
KDE 5.24.2
Wayland

How reproducible:
Always

Steps to Reproduce:
1. Start KRFB (from CLI due to other bug).
2. Enable desktop sharing.
3. Connect via vncviewer from a remote machine.
4. When asked for password, enter the password shown in krfb.
5. When asked to allow incoming connection, allow it.

Actual results:
Vncviewer loses the connection and suggests to try again with the following error:

Thu Mar  3 15:28:55 2022
 DecodeManager: Detected 8 CPU core(s)
 DecodeManager: Creating 4 decoder thread(s)
 CConn:       Connected to host 192.168.122.78 port 5900
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 CConnection: Choosing security type VncAuth(2)
X_CreatePixmap: BadAlloc (insufficient resources for operation) 0x7b2
XRequest.139: BadDrawable (invalid Pixmap or Window parameter) 0x200006c

Thu Mar  3 15:29:11 2022
 CConn:       malloc
XRequest.139: RenderBadPicture (invalid Picture parameter) 0x200006d
X_FreePixmap: BadPixmap (invalid Pixmap parameter) 0x200006c


Expected results:
VNC connection works.
Comment 1 haziest_pretax0m 2022-05-09 10:11:02 UTC
I can confirm this issue too.

OS: Gentoo
krfb version: 21.12.3
window system: wayland

The problem lies in the screen size reported by VNC server to client. When a VNC client connects to a VNC server, the server needs to tell the client its desktop screen size.
My screen size is 1920x1080, but krfb reported 65535x65535 back to client, causing the malloc error.

In fact, the width and height variable are not being set during the initialization, they both remain value -1. The width and height are 16bit long in VNC protocol, so krfb reported 65535x65535.

Use the following patch to output the width and height variable.

diff --git a/krfb/rfbservermanager.cpp b/krfb/rfbservermanager.cpp
index 0878f86..484b6e8 100644
--- a/krfb/rfbservermanager.cpp
+++ b/krfb/rfbservermanager.cpp
@@ -205,6 +205,7 @@ rfbScreenInfoPtr RfbServerManager::newScreen()
         //qDebug() << "bpp: " << bpp;

         rfbLogEnable(KRFB().isDebugEnabled());
+        qCDebug(KRFB) << "width: " << w << ", height: " << h;

         screen = rfbGetScreen(nullptr, nullptr, w, h, 8, 3, bpp);
         screen->paddedWidthInBytes = d->fb->paddedWidth();

The krfb's output:
 $ env LANG=C QT_LOGGING_RULES='krfb.*=true' krfb
QSocketNotifier: Can only be used with threads started with QThread
krfb.krfb: found plugin at  "/usr/lib64/qt5/plugins/krfb/framebuffer/krfb_framebuffer_xcb.so"
krfb.krfb: Loaded plugin with name  "xcb"
krfb.krfb: found plugin at  "/usr/lib64/qt5/plugins/krfb/framebuffer/krfb_framebuffer_qt.so"
krfb.krfb: Loaded plugin with name  "qt"
krfb.krfb: found plugin at  "/usr/lib64/qt5/plugins/krfb/framebuffer/krfb_framebuffer_pw.so"
krfb.krfb: Loaded plugin with name  "pw"
krfb.krfb: Using FrameBuffer: "pw"
krfb.framebuffer.pipewire: Egl initialization succeeded
krfb.framebuffer.pipewire: "EGL version: 1.4"
Initializing D-Bus connectivity with XDG Desktop Portal
DBus session created:  "/org/freedesktop/portal/desktop/request/1_150/krfb2361472498"
krfb.krfb: width:  -1 , height:  -1
09/05/2022 18:09:10 WARNING: Width (-1) is not a multiple of 4. VncViewer has problems with that.
krfb.krfb: Starting server. Listen port: 5900 Listen Address: "0.0.0.0" Password enabled: true
09/05/2022 18:09:10 Unable to establish connection with systemd socket
09/05/2022 18:09:10 Listening for VNC connections on TCP port 5900
09/05/2022 18:09:10 Listening for VNC connections on TCP6 port 5900
^C
Comment 2 JacekJagosz 2022-06-28 11:11:42 UTC
I also wanted to confirm this issue,
krfb 22.04.2
KDE 5.24.5
Wayland
OS: Solus 4.3
Mesa 22.0.4, Radeon (Renoir)
I also think bug 454036 is related or the same issue, as I am getting both.
Comment 3 Andrea Frati 2022-09-08 15:00:34 UTC
I also wanted to confirm this issue,
krfb 22.08.0-1
plasma-desktop 5.25.5-1
Wayland 1.21.0-1
OS: 5.19.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 05 Sep 2022 18:09:09 +0000 x86_64 GNU/Linux
Video Card: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
Comment 4 Henrik Harmsen 2023-02-02 17:24:27 UTC
I also can confirm this. When trying this in X11 with the pipewire (pw) plugin I get the below output (with debug turned on). It says a bit down: 

"krfb.framebuffer.pipewire: Failed to create session:  2"

But then it continues (unsuccessfully). I don't know if pw plugin is supposed to work on X11 or just Wayland?
(I am trying to get this to work on Wayland but testing is tricky so I ran it on X11 first. )


hch@srv:~/kde/src$ kdesrc-run krfb
################################################################################
                                   kdesrc-run
Module:             krfb
Program:            krfb
Revision:           21b2361c9f669e826b78531b4443d18f19d70e4b
Arguments:          
################################################################################

krfb.krfb: Loaded plugin with name  "qt"
krfb.krfb: Loaded plugin with name  "pw"
krfb.krfb: Loaded plugin with name  "xcb"
krfb.krfb: Using FrameBuffer: "pw"
Initializing D-Bus connectivity with XDG Desktop Portal
DBus session created:  "/org/freedesktop/portal/desktop/request/1_113/krfb575529447"
krfb.krfb: Starting server. Listen port: 5903 Listen Address: "0.0.0.0" Password enabled: true
02/02/2023 17:39:31 Listening for VNC connections on TCP port 5903
02/02/2023 17:39:31 Listening for VNC connections on TCP6 port 5903
krfb.framebuffer.pipewire: Failed to create session:  2
02/02/2023 17:49:27 Got connection from client 192.168.0.139
02/02/2023 17:49:27   0 other clients
02/02/2023 17:49:27 Normal socket connection
02/02/2023 17:49:27 Client Protocol Version 3.8
02/02/2023 17:49:27 Protocol version sent 3.8, using 3.8
02/02/2023 17:49:27 rfbProcessClientSecurityType: executing handler for type 2
krfb.krfb: about to start authentication
krfb.krfb: Loaded plugin with name  "xdp"
krfb.krfb: Loaded plugin with name  "x11"
02/02/2023 17:49:33 Client 192.168.0.139 gone
02/02/2023 17:49:33 Statistics             events    Transmit/ RawEquiv ( saved)
02/02/2023 17:49:33  TOTALS              :      0 |         0/        0 (  0,0%)
02/02/2023 17:49:33 Statistics             events    Received/ RawEquiv ( saved)
02/02/2023 17:49:33  TOTALS              :      0 |         0/        0 (  0,0%)
02/02/2023 17:49:37 Got connection from client 192.168.0.139
02/02/2023 17:49:37   0 other clients
02/02/2023 17:49:37 Normal socket connection
02/02/2023 17:49:37 Client Protocol Version 3.8
02/02/2023 17:49:37 Protocol version sent 3.8, using 3.8
02/02/2023 17:49:37 rfbProcessClientSecurityType: executing handler for type 2
krfb.krfb: about to start authentication
02/02/2023 17:49:48 Client 192.168.0.139 gone
02/02/2023 17:49:48 Statistics             events    Transmit/ RawEquiv ( saved)
02/02/2023 17:49:48  ServerCutText       :      1 |        25/       25 (  0,0%)
02/02/2023 17:49:48  TOTALS              :      1 |        25/       25 (  0,0%)
Comment 5 tonyseek 2023-02-11 16:32:11 UTC
*** This bug has been confirmed by popular vote. ***
Comment 6 Henrik Harmsen 2023-02-16 15:55:43 UTC
Some more troubleshooting information. My previous comment should be ignored because that was due to another problem which got fixed in krfb: "pw" plugin does not work at all in X11 so that is why it did not work. krfb now no longer enables "pw" under X11 anymore.
However, I set up a KDE wayland desktop (in a VM) and I am now using that for troubleshooting. Using the "pw" plugin here, I get two different outcomes:

1. If "Portal" pops up a window asking what to share (as described in https://bugs.kde.org/show_bug.cgi?id=458191) then I can semi-successfully connect to krfb from VNC. However the client window has changed everything that is blue into yellow. Seems RGB got mixed up somewhere. This is the first time krfb has ever worked in any fashion on Wayland for me. So semi-success there.

2. If I restart krfb rather quickly, then "Portal" does not pop up a window asking what to share (maybe the answer is cached) and then I get the failure mode described here with the invalid window sizes. I don't even know what Portal is yet though. 

I'm attaching here a printout from krfb in the two modes described above. By the way I am using Kubuntu 22.10 for my testing, probably it doesn't matter.

1. 
################################################################################
                                   kdesrc-run
Module:             krfb
Program:            krfb
Revision:           b740b6518eef498e184a3ccfafc3ba854748531e
Arguments:          
################################################################################

krfb.krfb: Loaded plugin with name  "pw"
Initializing D-Bus connectivity with XDG Desktop Portal
DBus session created:  "/org/freedesktop/portal/desktop/request/1_63/krfb718875647"
krfb.krfb: Using FrameBuffer: "pw"
krfb.krfb: Starting server. Listen port: 5902 Listen Address: "0.0.0.0" Password enabled: true
16/02/2023 16:32:02 Listening for VNC connections on TCP port 5902
16/02/2023 16:32:02 Listening for VNC connections on TCP6 port 5902
kpipewire_logging: Failed to query DMA-BUF formats.
16/02/2023 16:32:39 Got connection from client 192.168.122.1
16/02/2023 16:32:39   0 other clients
16/02/2023 16:32:39 Normal socket connection
16/02/2023 16:32:39 Client Protocol Version 3.8
16/02/2023 16:32:39 Protocol version sent 3.8, using 3.8
16/02/2023 16:32:39 rfbProcessClientSecurityType: executing handler for type 2
krfb.krfb: about to start authentication
krfb.krfb: Loaded plugin with name  "xdp"
krfb.krfb: Loaded plugin with name  "x11"
16/02/2023 16:32:43 Pixel format for client 192.168.122.1:
16/02/2023 16:32:43   32 bpp, depth 24, little endian
16/02/2023 16:32:43   true colour: max r 255 g 255 b 255, shift r 16 g 8 b 0
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC6)
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0x574D5664)
16/02/2023 16:32:43 Enabling full-color cursor updates for client 192.168.122.1
16/02/2023 16:32:43 Enabling X-style cursor updates for client 192.168.122.1
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0x574D5666)
16/02/2023 16:32:43 Enabling NewFBSize protocol extension for client 192.168.122.1
16/02/2023 16:32:43 Enabling ExtDesktopSize protocol extension for client 192.168.122.1
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFECD)
16/02/2023 16:32:43 Enabling LastRect protocol extension for client 192.168.122.1
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xC0A1E5CE)
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC7)
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEC8)
16/02/2023 16:32:43 rfbProcessClientNormalMessage: ignoring unsupported encoding type Enc(0xFFFFFEFE)
16/02/2023 16:32:43 Using compression level 2 for client 192.168.122.1
16/02/2023 16:32:43 Using image quality level 8 for client 192.168.122.1
16/02/2023 16:32:43 Using JPEG subsampling 0, Q92 for client 192.168.122.1
16/02/2023 16:32:43 Using tight encoding for client 192.168.122.1
16/02/2023 16:32:43 Sending rfbEncodingExtDesktopSize for size (1920x1080) 
16/02/2023 16:33:34 Client 192.168.122.1 gone
16/02/2023 16:33:34 Statistics             events    Transmit/ RawEquiv ( saved)
16/02/2023 16:33:34  FramebufferUpdate   :    355 |         0/        0 (  0,0%)
16/02/2023 16:33:34  LastRect            :    355 |      4260/     4260 (  0,0%)
16/02/2023 16:33:34  tight               :  48172 | 173806190/-1354123816 (  0,0%)
16/02/2023 16:33:34  RichCursor          :      1 |      1525/     1525 (  0,0%)
16/02/2023 16:33:34  ExtendedDesktopSize :      1 |        32/       32 (  0,0%)
16/02/2023 16:33:34  TOTALS              :  48884 | 173812007/-1354117999 (  0,0%)
16/02/2023 16:33:34 Statistics             events    Received/ RawEquiv ( saved)
16/02/2023 16:33:34  PointerEvent        :    319 |      1914/     1914 (  0,0%)
16/02/2023 16:33:34  FramebufferUpdate   :    357 |      3570/     3570 (  0,0%)
16/02/2023 16:33:34  SetEncodings        :      1 |        92/       92 (  0,0%)
16/02/2023 16:33:34  SetPixelFormat      :      1 |        20/       20 (  0,0%)
16/02/2023 16:33:34  TOTALS              :    678 |      5596/     5596 (  0,0%)


2.

################################################################################
                                   kdesrc-run
Module:             krfb
Program:            krfb
Revision:           b740b6518eef498e184a3ccfafc3ba854748531e
Arguments:          
################################################################################

krfb.krfb: Loaded plugin with name  "pw"
Initializing D-Bus connectivity with XDG Desktop Portal
DBus session created:  "/org/freedesktop/portal/desktop/request/1_67/krfb2759804091"
krfb.krfb: Using FrameBuffer: "pw"
krfb.krfb: Starting server. Listen port: 5902 Listen Address: "0.0.0.0" Password enabled: true
16/02/2023 16:33:55 Listening for VNC connections on TCP port 5902
16/02/2023 16:33:55 Listening for VNC connections on TCP6 port 5902
16/02/2023 16:34:06 Got connection from client 192.168.122.1
16/02/2023 16:34:06   0 other clients
16/02/2023 16:34:06 Normal socket connection
16/02/2023 16:34:06 Client Protocol Version 3.8
16/02/2023 16:34:06 Protocol version sent 3.8, using 3.8
16/02/2023 16:34:06 rfbProcessClientSecurityType: executing handler for type 2
krfb.krfb: about to start authentication
krfb.krfb: Loaded plugin with name  "xdp"
krfb.krfb: Loaded plugin with name  "x11"
16/02/2023 16:34:08 Client 192.168.122.1 gone
16/02/2023 16:34:08 Statistics             events    Transmit/ RawEquiv ( saved)
16/02/2023 16:34:08  TOTALS              :      0 |         0/        0 (  0,0%)
16/02/2023 16:34:08 Statistics             events    Received/ RawEquiv ( saved)
16/02/2023 16:34:08  TOTALS              :      0 |         0/