Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange artifacts after enabling nvenc #3761

Open
dmosdallas opened this issue Feb 10, 2023 · 10 comments
Open

Strange artifacts after enabling nvenc #3761

dmosdallas opened this issue Feb 10, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@dmosdallas
Copy link

Describe the bug
I have an xpra server & html5 client connecting to it. When I have nvenc disabled, I can connect and everything looks similar to a local desktop session. When I enable nvenc and interact with the xpra session, entire regions of the display jump up and to the left by like ~50px, leaving a large green negative space. Here's a recording of an example:

nvenc_artifacts.webm

To Reproduce
Steps to reproduce the behavior:

  1. server command
    • I've fiddled with quite a few parameters here while tuning & troubleshooting. They may not all make sense:
export XPRA_SCALING=0
export XPRA_SCROLL_ENCODING=0

xpra start --start-child-after-connect="$COMMAND" --bind=$UDS_SOCKET --daemon=no \
--exit-with-children --tray=no --server-idle-timeout=1800 \
--av-sync=no --mmap=no --clipboard=no --file-transfer=no --printing=no \
--terminate-children=yes --start-new-commands=no --tray=no \
--speaker=no --webcam=no \
--video-encoders=nvenc
  1. client command
    • No specific configurations, though I've adjusted the default client parameters during image build as follows:
echo "dpi = 96" >> /etc/xpra/html5-client/default-settings.txt && \
echo "bandwidth_limit = 20971520" >> /etc/xpra/html5-client/default-settings.txt
  1. specific action to trigger the bug
    • Connect to the web server from the client's browser, adjusting no configs beyond what's described above.

System Information (please complete the following information):

  • Server OS:
    • Docker image, based on nvidia/cuda:11.8.0-devel-ubuntu20.04
    • Kernel: Linux 5.10.165-143.735.amzn2.x86_64 SMP Wed Jan 25 03:13:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • Client OS: Windows 11, Chrome or Firefox html5 client
  • Xpra Server & Client Versions
    • Installed from xpra apt repos:
> apt list | grep xpra

xpra-html5/now 6.2-r1-1 all [installed,local]
xpra/now 4.4.3-r0-1 amd64 [installed,local]`

Additional context

  • This is running on aws with a g4dn instance.
    • Has a T4, with NVidia grid drivers installed
  • Running xpra encoding yeilds:
# xpra encoding

Warning: running as root
CUDA initialization (this may take a few seconds)
CUDA 11.8.0 / PyCUDA 2022.2.2, found 1 device:
  + Tesla T4 @ 0000:00:1E.0 (memory: 97% free, compute: 7.5)
NVidia driver version 525.85.5
NVENC v11 successfully initialized with codecs: h264, h265
Error querying drm devices: -2
modules found:
* csc_cython           : usr/lib/python3/dist-packages/xpra/codecs/csc_cython/colorspace_converter.cpython-38-x86_64-linux-gnu.so
* csc_libyuv           :
* csc_swscale          : usr/lib/python3/dist-packages/xpra/codecs/csc_swscale/colorspace_converter.cpython-38-x86_64-linux-gnu.so
* dec_avcodec2         : usr/lib/python3/dist-packages/xpra/codecs/dec_avcodec2/decoder.cpython-38-x86_64-linux-gnu.so
* dec_avif             :
* dec_jpeg             : usr/lib/python3/dist-packages/xpra/codecs/jpeg/decoder.cpython-38-x86_64-linux-gnu.so
* dec_nvjpeg           :
* dec_pillow           : usr/lib/python3/dist-packages/xpra/codecs/pillow/decoder.py
* dec_spng             :
* dec_vpx              : usr/lib/python3/dist-packages/xpra/codecs/vpx/decoder.cpython-38-x86_64-linux-gnu.so
* dec_webp             : usr/lib/python3/dist-packages/xpra/codecs/webp/decoder.cpython-38-x86_64-linux-gnu.so
* drm                  : usr/lib/python3/dist-packages/xpra/codecs/drm/drm.cpython-38-x86_64-linux-gnu.so
* enc_avif             :
* enc_ffmpeg           : usr/lib/python3/dist-packages/xpra/codecs/enc_ffmpeg/encoder.cpython-38-x86_64-linux-gnu.so
* enc_jpeg             : usr/lib/python3/dist-packages/xpra/codecs/jpeg/encoder.cpython-38-x86_64-linux-gnu.so
* enc_nvjpeg           : usr/lib/python3/dist-packages/xpra/codecs/nvjpeg/encoder.cpython-38-x86_64-linux-gnu.so
* enc_pillow           : usr/lib/python3/dist-packages/xpra/codecs/pillow/encoder.py
* enc_rgb              : usr/lib/python3/dist-packages/xpra/codecs/argb/encoder.py
* enc_spng             :
* enc_vpx              : usr/lib/python3/dist-packages/xpra/codecs/vpx/encoder.cpython-38-x86_64-linux-gnu.so
* enc_webp             : usr/lib/python3/dist-packages/xpra/codecs/webp/encoder.cpython-38-x86_64-linux-gnu.so
* enc_x264             : usr/lib/python3/dist-packages/xpra/codecs/enc_x264/encoder.cpython-38-x86_64-linux-gnu.so
* enc_x265             :
* evdi                 :
* nvenc                : usr/lib/python3/dist-packages/xpra/codecs/nvenc/encoder.cpython-38-x86_64-linux-gnu.so
* nvfbc                : usr/lib/python3/dist-packages/xpra/codecs/nvfbc/fbc_capture_linux.cpython-38-x86_64-linux-gnu.so
* v4l2                 : usr/lib/python3/dist-packages/xpra/codecs/v4l2/pusher.cpython-38-x86_64-linux-gnu.so

codecs versions:
* avcodec2                        : 58.54.100
* cython                          : 4.2
* drm                             : 4.4
* ffmpeg                          : 58.54.100
* jpeg                            : 1.0
* numpy                           : 1.23.1
* nvenc                           : 11.1
* nvfbc                           : 1.7
* nvjpeg                          : 11.8.0.2
* pillow                          : 7.0.0
* rgb                             : 4.3
* swscale                         : 5.5.100
* v4l2                            : 1.0
* vpx                             : 1.8.2
* webp                            : 0.6.1
* x264                            : 155
  • The docker command to kick off XPRA is basically this:
    docker run --gpus=all $IMAGE_ID $LAUNCH_COMMAND

  • I am doing a funny trick with socket forwarding, but I don't think it relates to this problem. I have a web server that kicks off xpra in docker, having xpra bind to a unix socket. My web server auth & client session management, forwarding requests to the unix socket xpra is bound to. This setup works very reliably with nvenc disabled.

I'm happy to provide any additional details to help with troubleshooting.

@dmosdallas dmosdallas added the bug Something isn't working label Feb 10, 2023
@dmosdallas
Copy link
Author

Oh, I forgot to include client logs in my initial report:

2023-02-10 20:23:11,267 no uinput module (not usually needed)
Feb 10, 2023 3:23:11 PM failed to initialize Gtk, no display?
2023-02-10 20:23:13,156 CUDA initialization (this may take a few seconds)
2023-02-10 20:23:13,482 CUDA 11.8.0 / PyCUDA 2022.2.2, found 1 device:
2023-02-10 20:23:13,482   + Tesla T4 @ 0000:00:1E.0 (memory: 99% free, compute: 7.5)
2023-02-10 20:23:12,665 pointer device emulation using XTest
Feb 10, 2023 3:23:13 PM serving html content from '/usr/share/xpra/www'
2023-02-10 20:23:12,710 wrote pid 11 to '/tmp/0/server.pid'

2023-02-10 20:23:12,726 xvfb pid=
202023-02-10 20:23:12,762 D-Bus notification forwarding is available
Feb 10, 2023 3:23:13 PM2023-02-10 20:23:12,967 waiting for initialization thread to complete
Feb 10, 2023 3:23:13 PM2023-02-10 20:23:12,967 xpra is ready.
Feb 10, 2023 3:23:14 PM Cannot get client list properties. 
2023-02-10 20:23:14,294 NVidia driver version 525.85.5
Feb 10, 2023 3:23:15 PM Cannot get client list properties. 
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)
Feb 10, 2023 3:23:15 PM 2023-02-10 20:23:15,228 OpenGL is supported on display ':0'
2023-02-10 20:23:15,228  using 'llvmpipe (LLVM 12.0.0, 256 bits)' renderer
2023-02-10 20:23:15,237 started command `ibus-daemon` with pid 113
Feb 10, 2023 3:23:15 PM 2023-02-10 20:23:14,509 NVENC v11 successfully initialized with codecs: h264, h265
Feb 10, 2023 3:23:15 PM2023-02-10 20:23:14,603 xpra X11 seamless version 4.4.3-r0 64-bit
Feb 10, 2023 3:23:15 PM 2023-02-10 20:23:14,604  uid=0 (root), gid=0 (root)
2023-02-10 20:23:14,604  running with pid 11 on Linux Ubuntu 20.04 focal2023-02-10 20:23:14,605  connected to X11 display :0 with 24 bit colors
Feb 10, 2023 3:23:15 PM2023-02-10 20:23:14,608 30.9GB of system memory
Feb 10, 2023 3:23:16 PM Cannot get client list properties. 

2023-02-10 20:23:25,382 server virtual display now set to 1896x997
2023-02-10 20:23:25,384  automatic picture encoding enabled, also available:
2023-02-10 20:23:25,384   jpeg, png, png/P, png/L, rgb32, rgb24, scroll, webp, h264
Feb 10, 2023 3:23:25 PM2023-02-10 20:23:25,393 started command `$COMMAND` with pid 279
2023-02-10 20:23:25,397 DPI set to 96 x 96
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:25,409 client   1 received xdg start menu data
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:25,409 client   1 startup complete
2023-02-10 20:23:25,409 client   1 connection-established
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:25,419 client   1 update encodings: encoding.rgb.version,encoding.pillow.version,encoding.webp.version,encoding.jpeg.version,encoding.nvjpeg.version,encoding.nvenc.version,encoding.swscale.version,encoding.cython.version,encodings,encodings.core,encodings.allowed,encodings.lossless,encodings.with_speed,encodings.with_quality,encodings.with_lossless_mode2023-02-10 20:23:24,530 Handshake complete; enabling connection
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:24,832 HTML5 Microsoft Windows Chrome client version 6.2
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:24,834 setting keyboard layout to 'us'
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:24,878  client root window size is 1896x997
Feb 10, 2023 3:23:25 PM
Feb 10, 2023 3:23:25 PM 2023-02-10 20:23:24,878   HTML (502x264 mm - DPI: 96x96)
2023-02-10 20:23:24,878     Canvas
Feb 10, 2023 3:23:26 PM Cannot get client list properties. 
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)
Feb 10, 2023 3:23:27 PM Cannot get client list properties. 
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)
Feb 10, 2023 3:23:28 PM Cannot get client list properties. 
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)
Feb 10, 2023 3:23:29 PM 2023-02-10 20:23:29,195 client   1 [object Object] 1 200 200 1946 600 [object Object] false false [object Object] (window) => this.send_configure_window(window, {}, false) (event, window) => this.on_mousemove(event, window) (event, window) => this.on_mousedown(event, window) (event, window) => this.on_mouseup(event, window) (event, window) => this.on_mousescroll(event, window) (window) => this._window_set_focus(window) (window) => this.send([PACKET_TYPES.close_window, window.wid]) 1
Feb 10, 2023 3:23:29 PM 2023-02-10 20:23:29,207 Warning: video scaling is disabled
2023-02-10 20:23:29,207  but the video size is too large: 1946x600
2023-02-10 20:23:29,207  the maximum supported is 1024x768
Feb 10, 2023 3:23:29 PM 2023-02-10 20:23:29,272 Error: failed to create data packet
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_source.py", line 2124, in make_data_packet_cb
    packet = self.make_data_packet(damage_time, process_damage_time, image, coding, sequence, options, flush)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_source.py", line 2640, in make_data_packet
    ret = encoder(coding, image, options)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_video_source.py", line 2110, in video_encode
    return self.do_video_encode(encoding, image, options)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_video_source.py", line 2210, in do_video_encode
    return self.video_fallback(image, options, warn=False)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_video_source.py", line 2106, in video_fallback
    return encode_fn(encoding, image, options)
  File "xpra/codecs/nvjpeg/encoder.pyx", line 517, in xpra.codecs.nvjpeg.encoder.encode
  File "xpra/codecs/nvjpeg/encoder.pyx", line 200, in xpra.codecs.nvjpeg.encoder.Encoder.init_context
  File "/usr/lib/python3/dist-packages/xpra/codecs/cuda_common/cuda_context.py", line 458, in __enter__
    raise TransientCodecException("failed to acquire cuda device lock")
xpra.codecs.codec_constants.TransientCodecException: failed to acquire cuda device lock
Feb 10, 2023 3:23:31 PM /usr/lib/python3.8/threading.py:870: UserWarning: module in out-of-thread context could not be cleaned up
  self._target(*self._args, **self._kwargs)
2023-02-10 20:23:31,490 Error: failed to create data packet
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_source.py", line 2124, in make_data_packet_cb
    packet = self.make_data_packet(damage_time, process_damage_time, image, coding, sequence, options, flush)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_source.py", line 2640, in make_data_packet
    ret = encoder(coding, image, options)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_video_source.py", line 2110, in video_encode
    return self.do_video_encode(encoding, image, options)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_video_source.py", line 2210, in do_video_encode
    return self.video_fallback(image, options, warn=False)
  File "/usr/lib/python3/dist-packages/xpra/server/window/window_video_source.py", line 2106, in video_fallback
    return encode_fn(encoding, image, options)
  File "xpra/codecs/nvjpeg/encoder.pyx", line 517, in xpra.codecs.nvjpeg.encoder.encode
  File "xpra/codecs/nvjpeg/encoder.pyx", line 200, in xpra.codecs.nvjpeg.encoder.Encoder.init_context
  File "/usr/lib/python3/dist-packages/xpra/codecs/cuda_common/cuda_context.py", line 458, in __enter__
    raise TransientCodecException("failed to acquire cuda device lock")
xpra.codecs.codec_constants.TransientCodecException: failed to acquire cuda device lock

@totaam
Copy link
Collaborator

totaam commented Feb 11, 2023

First, never do this:

--video-encoders=nvenc

nvenc should be enabled out of the box, what you're doing is counter productive.

export XPRA_SCALING=0

Then later on:

Warning: video scaling is disabled
but the video size is too large: 1946x600
the maximum supported is 1024x768

So, don't do that.

raise TransientCodecException("failed to acquire cuda device lock")

That's probably a transient error that happens during initialization.

This looks like a bug in the html5 client's rendering code. Perhaps it is using the unscaled size for painting?
@TijZwa ?
@dmosdallas If that's the case then you may experience the same issue with --video-encoders=enc_vpx,enc_x264 - this would tell us something.
Do these visual artifacts also occur with a native python client or only with the html5 client?

@dmosdallas
Copy link
Author

Thanks for the quick feedback!

I'll disable the --video-encoders flag. I was desperately bludgeoning things by the time I filed this issue :)

export XPRA_SCALING=0

This one's actually pretty load-bearing and given your suspicion about the client rendering code, may be another hint? When I disable this flag, everything turns to a blurry mess and jumps around all over the screen even with nvenc disabled. I'll try to get a screencap to show what I'm talking about.

the maximum supported is 1024x768

Right, that does seem like a recipe for problems. Do you have any idea why it believes the maximum supported resolution is 1024x768? From nvidia's docs, it looks like a T4 should be able to do h264 @ 4096x4096. Maybe I'm still misconfiguring something?

I'll give it another go with the --video-encoders=enc_vpx,enc_x264 flag and report back.

Thanks again!
Dallas

@dmosdallas
Copy link
Author

Oh, and as I mentioned above I have xpra sitting behind an authenticating proxy, so it'll take a bit of work to get the native python client pointed at it for comparison.

@dmosdallas
Copy link
Author

Okay, I've done another go of this with the XPRA_SCALING env removed and the --video-encoders flag removed. No other changes.

This is behaving differently from how I remember it. The quality and performance are significantly below what they are with hardware encoding support removed entirely. Occasionally, the entire display will freeze and won't recover until I disconnect the session and reconnect.

I am, however, no longer seeing those green regions -- I assume that's from turning off XPRA_SCALING.

Here's a snippet of that session. Around second 8, the entire display becomes unresponsive:
nvenc_scaling_enabled_video_encoders_removed.webm

Here's the logs that came out whole doing the screen recording:

2023-02-13 22:15:56,272 Handshake complete; enabling connection
Feb 13, 2023 5:15:56 PM2023-02-13 22:15:57,143 server virtual display now set to 1411x859
Feb 13, 2023 5:15:57 PM
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:57,146  automatic picture encoding enabled, also available:
2023-02-13 22:15:57,146   jpeg, png, png/P, png/L, rgb32, rgb24, scroll, webp, h264, vp8, vp92023-02-13 22:15:57,166 DPI set to 96 x 96
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:57,175 client   1 received xdg start menu data
Feb 13, 2023 5:15:57 PM
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:57,178 client   1 [object Object] 1 200 200 1946 600 [object Object] false false [object Object] (window) => this.send_configure_window(window, {}, false) (event, window) => this.on_mousemove(event, window) (event, window) => this.on_mousedown(event, window) (event, window) => this.on_mouseup(event, window) (event, window) => this.on_mousescroll(event, window) (window) => this._window_set_focus(window) (window) => this.send([PACKET_TYPES.close_window, window.wid]) 1
Feb 13, 2023 5:15:57 PM
(Xpra:11): Gdk-CRITICAL **: 22:15:57.190: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed2023-02-13 22:15:57,201 client   1 startup complete
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:57,206 client   1 connection-established
Feb 13, 2023 5:15:57 PM
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:57,206 client   1 update encodings: encoding.rgb.version,encoding.pillow.version,encoding.webp.version,encoding.jpeg.version,encoding.nvjpeg.version,encoding.x264.version,encoding.vpx.version,encoding.nvenc.version,encoding.ffmpeg.version,encoding.swscale.version,encoding.cython.version,encodings,encodings.core,encodings.allowed,encodings.lossless,encodings.with_speed,encodings.with_quality,encodings.with_lossless_mode2023-02-13 22:15:56,590 HTML5 Linux Chrome client version 6.2
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:56,593 setting keyboard layout to 'us'
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:56,639  client root window size is 1411x859
Feb 13, 2023 5:15:57 PM
Feb 13, 2023 5:15:57 PM2023-02-13 22:15:56,639   HTML (373x227 mm - DPI: 96x96)
2023-02-13 22:15:56,639     Canvas
Feb 13, 2023 5:16:14 PM/usr/lib/python3.8/threading.py:874: UserWarning: module in out-of-thread context could not be cleaned up
  del self._target, self._args, self._kwargs
/usr/lib/python3.8/threading.py:874: UserWarning: pagelocked_host_allocation in out-of-thread context could not be cleaned up
  del self._target, self._args, self._kwargs
/usr/lib/python3.8/threading.py:874: UserWarning: device_allocation in out-of-thread context could not be cleaned up
  del self._target, self._args, self._kwargs
Exception in thread threaded-clean:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "xpra/codecs/nvenc/encoder.pyx", line 2164, in xpra.codecs.nvenc.encoder.Encoder.threaded_clean
  File "xpra/codecs/nvenc/encoder.pyx", line 2165, in xpra.codecs.nvenc.encoder.Encoder.threaded_clean
  File "xpra/codecs/nvenc/encoder.pyx", line 2171, in xpra.codecs.nvenc.encoder.Encoder.do_clean
  File "/usr/lib/python3/dist-packages/xpra/codecs/cuda_common/cuda_context.py", line 458, in __enter__
    raise TransientCodecException("failed to acquire cuda device lock")
xpra.codecs.codec_constants.TransientCodecException: failed to acquire cuda device lock
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,168 Error: failed to encode jpeg frame
2023-02-13 22:16:16,168  using nvjpeg video encoder:2023-02-13 22:16:16,168  failed to acquire cuda device lock
Feb 13, 2023 5:16:16 PM
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,168  source: XShmImageWrapper(BGRX: 0, 714, 256, 49)
2023-02-13 22:16:16,169  options:
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,169    * cuda-device-context          : cuda_device_context(0 - False)
2023-02-13 22:16:16,169    * lz4                          : True2023-02-13 22:16:16,169    * quality                      : 100
Feb 13, 2023 5:16:16 PM
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,169    * rgb_formats                  : RGBX, RGBA, RGB
2023-02-13 22:16:16,169    * speed                        : 23
2023-02-13 22:16:16,170  encoder:
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,170    * frames                       : 0
2023-02-13 22:16:16,170    * height                       : 49
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,170    * quality                      : 100
2023-02-13 22:16:16,171    * speed                        : 50
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:16,171    * version                      : 11.8.0.2
2023-02-13 22:16:16,171    * width                        : 256
Feb 13, 2023 5:16:16 PMException in thread threaded-clean:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "xpra/codecs/nvenc/encoder.pyx", line 2164, in xpra.codecs.nvenc.encoder.Encoder.threaded_clean
  File "xpra/codecs/nvenc/encoder.pyx", line 2165, in xpra.codecs.nvenc.encoder.Encoder.threaded_clean
  File "xpra/codecs/nvenc/encoder.pyx", line 2171, in xpra.codecs.nvenc.encoder.Encoder.do_clean
  File "/usr/lib/python3/dist-packages/xpra/codecs/cuda_common/cuda_context.py", line 458, in __enter__
    raise TransientCodecException("failed to acquire cuda device lock")
xpra.codecs.codec_constants.TransientCodecException: failed to acquire cuda device lock
Feb 13, 2023 5:16:16 PM/usr/lib/python3.8/threading.py:870: UserWarning: module in out-of-thread context could not be cleaned up
  self._target(*self._args, **self._kwargs)
2023-02-13 22:16:15,890 Warning: setup_pipeline failed for2023-02-13 22:16:15,890  (75, (1, 1), None, 0, 0, None, 'BGRX', (1, 1), 256, 53, jpeg(BGRX to jpeg)):
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:15,890  failed to acquire cuda device lock
Feb 13, 2023 5:16:16 PM2023-02-13 22:16:17,301 Warning: setup_pipeline failed for
Feb 13, 2023 5:16:17 PM2023-02-13 22:16:17,302  (75, (1, 1), None, 0, 0, None, 'BGRX', (1, 1), 256, 49, jpeg(BGRX to jpeg)):
Feb 13, 2023 5:16:17 PM2023-02-13 22:16:17,303  failed to acquire cuda device lock
Feb 13, 2023 5:16:17 PM
Feb 13, 2023 5:16:17 PM2023-02-13 22:16:17,339 Warning: client decoding error:
2023-02-13 22:16:17,339  TypeError: Failed to execute 'configure' on 'VideoDecoder': Failed to parse codec string.2023-02-13 22:16:16,639 Warning: setup_pipeline failed for
Feb 13, 2023 5:16:17 PM
Feb 13, 2023 5:16:17 PM2023-02-13 22:16:16,639  (75, (1, 1), None, 0, 0, None, 'BGRX', (1, 1), 350, 41, jpeg(BGRX to jpeg)):
2023-02-13 22:16:16,639  failed to acquire cuda device lock
Feb 13, 2023 5:16:17 PM2023-02-13 22:16:16,645 Warning: setup_pipeline failed for
2023-02-13 22:16:16,645  (75, (1, 1), None, 0, 0, None, 'BGRX', (1, 1), 256, 49, jpeg(BGRX to jpeg)):
2023-02-13 22:16:16,646  failed to acquire cuda device lock
Feb 13, 2023 5:16:34 PM2023-02-13 22:16:33,980 Warning: delayed region timeout
2023-02-13 22:16:33,980  region is 15 seconds old, will retry - bad connection?
2023-02-13 22:16:33,980  43 late responses:
2023-02-13 22:16:33,980     379 rgb24:  16s
2023-02-13 22:16:33,980     380 rgb24:  16s
2023-02-13 22:16:33,980     381 rgb24:  16s
2023-02-13 22:16:33,980     382 rgb24:  16s
2023-02-13 22:16:33,980     383 vp8  :  16s
Feb 13, 2023 5:16:34 PM2023-02-13 22:16:33,980     384 rgb24:  16s
2023-02-13 22:16:33,980     385 rgb24:  16s
2023-02-13 22:16:33,980     386 rgb24:  16s
2023-02-13 22:16:33,980     387 jpeg :  16s
2023-02-13 22:16:33,980     388 rgb24:  16s
2023-02-13 22:16:33,980     389 jpeg :  16s
2023-02-13 22:16:33,980     390 rgb24:  16s
2023-02-13 22:16:33,980     391 rgb24:  16s
2023-02-13 22:16:33,980     392 rgb24:  16s
2023-02-13 22:16:33,980     393 jpeg :  16s
2023-02-13 22:16:33,981     394 rgb24:  16s
2023-02-13 22:16:33,981     395 jpeg :  16s
2023-02-13 22:16:33,981     396 jpeg :  16s
2023-02-13 22:16:33,981     397 rgb24:  16s
2023-02-13 22:16:33,981     398 rgb24:  16s
2023-02-13 22:16:33,981     399 rgb24:  16s
2023-02-13 22:16:33,981     400 jpeg :  16s
Feb 13, 2023 5:16:34 PM2023-02-13 22:16:33,981     401 rgb24:  16s
2023-02-13 22:16:33,981     402 rgb24:  16s
2023-02-13 22:16:33,981     403 rgb24:  16s
2023-02-13 22:16:33,981     404 rgb24:  16s
2023-02-13 22:16:33,981     405 vp8  :  16s
2023-02-13 22:16:33,981     406 webp :  16s
2023-02-13 22:16:33,981     407 rgb24:  16s
2023-02-13 22:16:33,981     408 rgb24:  16s
2023-02-13 22:16:33,981     409 jpeg :  16s
2023-02-13 22:16:33,981     410 webp :  16s
2023-02-13 22:16:33,981     411 rgb24:  16s
2023-02-13 22:16:33,981     412 webp :  16s
2023-02-13 22:16:33,981     413 rgb24:  16s
2023-02-13 22:16:33,981     414 rgb24:  16s
2023-02-13 22:16:33,981     415 vp8  :  16s
Feb 13, 2023 5:16:34 PM2023-02-13 22:16:33,981     416 webp :  16s
2023-02-13 22:16:33,981     417 vp8  :  16s
2023-02-13 22:16:33,981     418 vp8  :  15s
2023-02-13 22:16:33,981     419 vp8  :  15s
2023-02-13 22:16:33,981     420 vp8  :  15s
2023-02-13 22:16:33,981     421 webp :  14s
Feb 13, 2023 5:17:44 PM
2023-02-13 22:17:44,284 client   1 [object Object] 2 6 20 297 69 [object Object] true false [object Object] (window) => this.send_configure_window(window, {}, false) (event, window) => this.on_mousemove(event, window) (event, window) => this.on_mousedown(event, window) (event, window) => this.on_mouseup(event, window) (event, window) => this.on_mousescroll(event, window) (window) => this._window_set_focus(window) (window) => this.send([PACKET_TYPES.close_window, window.wid]) 1
2023-02-13 22:17:46,000 HTML5 client 1 disconnected.

@totaam
Copy link
Collaborator

totaam commented Feb 14, 2023

When I disable this flag, everything turns to a blurry mess and jumps around all over the screen even with nvenc disabled. I'll try to get a screencap to show what I'm talking about.

This means that the server is deciding to downscale the pixel data.
You can have better control over this using the video-scaling option.

Do you have any idea why it believes the maximum supported resolution is 1024x768?
From nvidia's docs, it looks like a T4 should be able to do h264 @ 4096x4096. Maybe I'm still misconfiguring something?

It's not the server that is setting this limit, it is the client.

HTML5 Microsoft Windows Chrome client version 6.2

Newer versions of the html5 client will allow for higher video resolutions when offscreen decoding is enabled: Less scaling for offscreen decoding
This may help.

I have xpra sitting behind an authenticating proxy, so it'll take a bit of work to get the native python client pointed at it for comparison

The python client in ws / wss mode should be able to mimic a browser, including authentication:

xpra attach wss://username:password@host:port/display?extra=whatever

Warning: delayed region timeout
region is 15 seconds old, will retry - bad connection?

This may happen because the server is hung waiting for its cuda context or because the HTML5 client somehow fails to report its failure to decode a screen update.
Perhaps newer / older versions would work better.
A new html5 release is imminent.

@dmosdallas
Copy link
Author

It's not the server that is setting this limit, it is the client.

Ah, nice! Looks like pulling from your apt repo still doesn't include that change.

Fiddling with things today, I've found that the nvjpeg encoder has been giving me pretty great results without the quirks I was seeing with nvenc. Is there a best practice for telling xpra to strongly prefer that encoder? I've forced it with --encoding=nvjpeg, but given your advice re: the --video-encoders flag this may not be a good idea?

I'll try to update to the html5 client including your linked changes in the next day or two and give the python wss client a go as well. With the nvjpeg approach giving me acceptable results, I'm probably not going to be able to focus on this full-time for the next few days.

Thanks!

@totaam
Copy link
Collaborator

totaam commented Feb 15, 2023

pulling from your apt repo still doesn't include that change.

I'll try to make some beta xpra-html5 v7 builds later today.

I've found that the nvjpeg encoder has been giving me pretty great results without the quirks I was seeing with nvenc

Yes, it is much easier to handle, both on the server side and client side.
Far fewer things that are likely to go wrong.
The main downside is that the bandwidth consumption will be higher.

I've forced it with --encoding=nvjpeg, but given your advice re: the --video-encoders flag this may not be a good idea?

That's an invalid value and should have triggered a warning. Generally speaking, it is best to not use the encoding and encodings options.
If you want to be using nvjpeg, --video-encoders is not such a bad option in that case...
Try --video-encoders=nvjpeg,x264,vpx with the latest builds and it should prefer nvjpeg since that one is GPU accelerated. YMMV.

@TijZwa
Copy link
Collaborator

TijZwa commented Feb 15, 2023

This looks like a bug in the html5 client's rendering code. Perhaps it is using the unscaled size for painting?

Scaling from 1946x600 to1024x768 does make the video look artifacted.
This commit fixed that.

@totaam
Copy link
Collaborator

totaam commented May 30, 2023

This could be related to #3837 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants