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

Streaming shows one frame and goes back to loading screen on Raspberry Pi 4 Bookworm 64-bit #1480

Open
daniele-athome opened this issue Dec 11, 2024 · 10 comments

Comments

@daniele-athome
Copy link

Describe the bug
When I try to start a stream (from Sunshine host), Moonlight constantly switches between the "Resuming" screen and the stream: the stream shows only a single frame and then goes back to the "Resuming" screen.

Steps to reproduce
Just start a stream on a Raspberry Pi 4 running Raspberry Pi OS 64-bit Bookworm.

Other Moonlight clients
On the same hardware, using the latest version of OSMC, Moonlight works perfectly. I'm trying to replicate the same configuration in my Bookworm installation.

Moonlight settings (please complete the following information)
No changes from default except resolution (1080p).

Client PC details (please complete the following information)

  • OS: Raspberry Pi OS Bookworm 64-bit
  • Moonlight Version: v6.1.0
  • GPU: Raspberry Pi GPU
  • Linux package type: installed through apt-get

Server PC details (please complete the following information)

  • OS: Debian Linux testing
  • Sunshine v2024.1115.143556
  • GPU: AMD Radeon RX 6800

Moonlight Logs (please attach)
moonlight.log

Additional context

I also installed Pulseaudio (following the instructions on the wiki page) and rebooted but nothing changed.

If I use latest OSMC (based on Debian Bullseye so running a very old 5.x kernel), Moonlight works perfectly. I tried many things, I don't know what else to do:

  • altering config.txt (including trying fkms instead of kms)
  • QT_QPA_EGLFS_ALWAYS_SET_MODE=1
  • forcing 1080p resolution via video= cmdline option

On both systems (OSMC and Raspberry Pi OS), I start Moonlight from a bare TTY.

Bookworm config.txt:

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Additional overlays and parameters are documented
# /boot/firmware/overlays/README

# Automatically load overlays for detected cameras
camera_auto_detect=0

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Automatically load initramfs files, if found
auto_initramfs=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

# Run as fast as firmware / board allows
arm_boost=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[cm5]
dtoverlay=dwc2,dr_mode=host

[pi4]
dtoverlay=rpivid-v4l2

[all]

hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=97
hdmi_drive=2
gpu_mem=256
hdmi_blanking=0
audio_pwm_mode=2
hdmi_enable_4kp60=1
disable_splash=1

OSMC config.txt (perfectly working system):

[pi4]
dtoverlay=rpivid-v4l2
arm_64bit=1
kernel=kernel.img

[all]
dtoverlay=vc4-kms-v3d,cma-512
disable_overscan=1
start_x=1
disable_splash=1
disable_fw_kms_setup=1
hdmi_ignore_cec_init=1
sdtv_aspect=1
start_x=1
hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=97
hdmi_drive=2
gpu_mem=256
hdmi_blanking=0
audio_pwm_mode=2
hdmi_enable_4kp60=1

[pi02]
dtoverlay=vc4-kms-v3d,cma-256

[board-type=0x0e]
dtoverlay=vc4-kms-v3d,cma-256

Might be similar to #1336, and I recently saw a user reporting a very similar issue on Discord.

@Bobbar
Copy link

Bobbar commented Dec 12, 2024

Are you booting directly into TTY, or are you switching to TTY1 from the GUI? Make sure it's the former.

Also, you can remove the dtoverlay=rpivid-v4l2 config. It shouldn't be needed for current RPi OSs.

Could not queue DRM page flip on screen HDMI1 (Permission denied)
I only ever see this if I launch Moonlight from anything other than TTY. Or if more than one instance of Moonlight is running. (Or anything else that attaches to DRM, like Kodi or something)

@daniele-athome
Copy link
Author

Also, you can remove the dtoverlay=rpivid-v4l2 config. It shouldn't be needed for current RPi OSs.

Done, nothing changed I'm afraid.

I only ever see this if I launch Moonlight from anything other than TTY. Or if more than one instance of Moonlight is running. (Or anything else that attaches to DRM, like Kodi or something)

You got me: the log was from a SSH session - sorry, my bad. Here is from a TTY session:
moonlight.log

The command line was:

QT_LOGGING_RULES="qt.qpa.*=true" QT_QPA_EGLFS_KMS_CONFIG=eglfs.json QT_QPA_EGLFS_ALWAYS_SET_MODE=0 moonlight-qt -platform eglfs stream gaming 'Steam Big Picture'

eglfs.json (in a desperate attempt to make this work :-):

{
  "device": "/dev/dri/card0",
  "outputs": [
    {
      "name": "HDMI1",
      "mode": "3840x2160"
    }
  ]
}

I have nothing else running that uses the GPU: it's a barebone Raspberry Pi OS Lite installation with nothing else but Moonlight.

I also tried moonlight-embedded but with different results: streaming works, but only at low bitrate (<= 20 mbit) and only in H264. I'd rather use moonlight-qt anyway.

@Bobbar
Copy link

Bobbar commented Dec 13, 2024

Weird. I have pretty much the exact same setup*, in multiple places.

*EDIT: Not quite, I'm on Bullseye 6.1.19.

What about this stuff? I've never needed any of those options, except maybe the last two.

hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=97
hdmi_drive=2
gpu_mem=256
hdmi_blanking=0
audio_pwm_mode=2
hdmi_enable_4kp60=1
disable_splash=1

And here's what I have for driver overlays:

dtoverlay=vc4-kms-v3d
dtoverlay=cma,cma-512
max_framebuffers=2 

Is it any different if you launch into the moonlight GUI with no additional options, instead of issuing the eglfs and stream options?

@Bobbar
Copy link

Bobbar commented Dec 13, 2024

GBM: Using DRM device "/dev/dri/card0" specified in config file

This seems suspect too. My RPis always use /dev/dri/card1.

@daniele-athome
Copy link
Author

daniele-athome commented Dec 14, 2024

What about this stuff? I've never needed any of those options, except maybe the last two.

Those were options from a previous installation, legacy options which are for the most part ignored (except for the last two, as you said, which should still be valid). I commented all out to no avail.

And here's what I have for driver overlays:

I tried with the cma overlay (I didn't know about it), both with kms and fkms, same issue.

This seems suspect too. My RPis always use /dev/dri/card1.

The eglfs configuration file was actually a desperate test too. card1 doesn't work at all for me - Moonlight won't even start (probably the kernel assigning a different number for some reason?). Anyway it doesn't work even without the configuration file.

A new log moonlight.log is attached with:

  • cmdline.txt with video=HDMI-A-1:1920x1080M@60
  • no eglfs config file
  • command line: QT_SCALE_FACTOR=1 QT_LOGGING_RULES="qt.qpa.*=true" moonlight-qt -platform eglfs stream gaming 'Steam Big Picture'

Is it any different if you launch into the moonlight GUI with no additional options, instead of issuing the eglfs and stream options?

No, those were options I added later as an experiment: the first thing I did was launch moonlight-qt without any parameter like I always do on the other system.

@daniele-athome
Copy link
Author

daniele-athome commented Dec 14, 2024

As a later experiment, I tried to replicate as much as possible what the Kodi extension does - the one I use in the other (working) system. Here is my script:

#!/bin/bash

export QT_SCALE_FACTOR=0.9
export QT_QPA_EGLFS_PHYSICAL_WIDTH=$( awk "BEGIN { print int($QT_SCALE_FACTOR*437)}" )
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=$( awk "BEGIN { print int($QT_SCALE_FACTOR*250)}" )
export QT_LOGGING_RULES="qt.qpa.*=true"
export QT_QPA_EGLFS_KMS_CONFIG=eglfs.json
export QT_QPA_EGLFS_ALWAYS_SET_MODE=0
export SDL_AUDIO_DRIVER=alsa

moonlight-qt -platform eglfs stream gaming 'Steam Big Picture'

I tried with both values of QT_QPA_EGLFS_ALWAYS_SET_MODE and also tried pulse as SDL audio driver.

eglfs config file:

{
  "device": "/dev/dri/card0",
  "outputs": [
    {
      "name": "HDMI1",
      "mode": "1920x1080"
    }
  ]
}

cmdline.txt:

console=serial0,115200 console=tty1 root=PARTUUID=8445d4f6-02 rootfstype=ext4 fsck.repair=yes rootwait video=HDMI-A-1:1920x1080M@60

config.txt:

dtparam=audio=on
camera_auto_detect=0
display_auto_detect=0
auto_initramfs=1
#dtoverlay=vc4-kms-v3d
dtoverlay=vc4-fkms-v3d
dtoverlay=cma,cma-512
max_framebuffers=2

disable_fw_kms_setup=1

arm_64bit=1

disable_overscan=1
arm_boost=1

[all]

hdmi_force_hotplug=1
#hdmi_enable_4kp60=1
disable_splash=1

EDIT: at this point, if we can determine that the problem is not with my system configuration, I can help debugging this in a more advanced way if needed.

@Bobbar
Copy link

Bobbar commented Dec 19, 2024

Very strange. It should just work out of the box. I'll have to try a fresh Bookworm image at some point.

Are there any related messages in dmesg and/or kern.log?

@daniele-athome
Copy link
Author

I didn't think about that, here it is with vc4-kms-v3d:

[  130.473051] rpivid feb10000.codec: rpivid_h265_start: (1344x736)
[  130.478039] rpivid feb10000.codec: SPS changed
[  130.478061] rpivid feb10000.codec: PPS changed
[  130.480197] rpivid feb10000.codec: rpivid_h265_stop
[  132.864762] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[  132.869620] rpivid feb10000.codec: SPS changed
[  132.869639] rpivid feb10000.codec: PPS changed
[  132.872009] rpivid feb10000.codec: rpivid_h265_stop
[  133.183667] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[  133.187302] rpivid feb10000.codec: SPS changed
[  133.187322] rpivid feb10000.codec: PPS changed
[  133.189764] rpivid feb10000.codec: rpivid_h265_stop
[  136.791954] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[  136.796228] rpivid feb10000.codec: SPS changed
[  136.796248] rpivid feb10000.codec: PPS changed
[  136.798789] rpivid feb10000.codec: rpivid_h265_stop
[  141.375079] rpivid feb10000.codec: rpivid_h265_start: (1920x1088)
[  141.388694] rpivid feb10000.codec: SPS changed
[  141.388726] rpivid feb10000.codec: PPS changed
[  141.421518] rpivid feb10000.codec: rpivid_h265_stop
[  141.591403] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[  141.594937] rpivid feb10000.codec: SPS changed
[  141.594945] rpivid feb10000.codec: PPS changed
[  141.597186] rpivid feb10000.codec: rpivid_h265_stop
[  143.860953] rpivid feb10000.codec: rpivid_h265_start: (1920x1088)
[  143.872166] rpivid feb10000.codec: SPS changed
[  143.872187] rpivid feb10000.codec: PPS changed
[  143.904754] rpivid feb10000.codec: rpivid_h265_stop
[  144.063141] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[  144.067301] rpivid feb10000.codec: SPS changed
[  144.067319] rpivid feb10000.codec: PPS changed
[  144.069528] rpivid feb10000.codec: rpivid_h265_stop

With vc4-fkms-v3d:

[   30.708811] rpivid feb10000.codec: rpivid_h265_start: (1344x736)
[   30.713761] rpivid feb10000.codec: SPS changed
[   30.713776] rpivid feb10000.codec: PPS changed
[   30.716081] rpivid feb10000.codec: rpivid_h265_stop
[   33.007086] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[   33.011398] rpivid feb10000.codec: SPS changed
[   33.011412] rpivid feb10000.codec: PPS changed
[   33.013724] rpivid feb10000.codec: rpivid_h265_stop
[   33.264489] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[   33.270330] rpivid feb10000.codec: SPS changed
[   33.270348] rpivid feb10000.codec: PPS changed
[   33.272752] rpivid feb10000.codec: rpivid_h265_stop
[   36.816694] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[   36.823018] rpivid feb10000.codec: SPS changed
[   36.823038] rpivid feb10000.codec: PPS changed
[   36.825260] rpivid feb10000.codec: rpivid_h265_stop
[   41.311118] rpivid feb10000.codec: rpivid_h265_start: (1920x1088)
[   41.324424] rpivid feb10000.codec: SPS changed
[   41.324440] rpivid feb10000.codec: PPS changed
[   41.349338] rpivid feb10000.codec: phase1_cb: Post wait: 0x8
[   41.350135] rpivid feb10000.codec: phase1_thread: Coeff realloc (600000) OK
[   41.421193] rpivid feb10000.codec: rpivid_h265_stop
[   41.557406] rpivid feb10000.codec: rpivid_h265_start: (1280x736)
[   41.561184] rpivid feb10000.codec: SPS changed
[   41.561202] rpivid feb10000.codec: PPS changed
[   41.563604] rpivid feb10000.codec: rpivid_h265_stop
[   43.791463] rpivid feb10000.codec: rpivid_h265_start: (1920x1088)
[   43.804873] rpivid feb10000.codec: SPS changed
[   43.804888] rpivid feb10000.codec: PPS changed
[   43.826578] rpivid feb10000.codec: rpivid_h265_stop
[   43.952253] rpivid feb10000.codec: rpivid_h265_start: (1280x736)

Same logs continue to appear until I (forcibly) kill Moonlight. I wonder why the weird resolutions: I can understand 1920x1088, but where did 1280x736 and 1344x736 come from?

@Bobbar
Copy link

Bobbar commented Dec 19, 2024

That's all normal, except for the fact that they keep repeating continuously when it should be staying at the PPS changed line, following the _start: (1920x1088) line until streaming ends (or realloc). The weird resolutions are just some rounding artifacts, for memory layout or something. Don't quote me on that, but they are normal.

Does the OSMC build support HEVC, or was it using H264? Is your host actually able to provide an HEVC stream?

The way you (we) are setup, Moonlight will only support HEVC.

What do the Sunshine logs on your host look like?

@daniele-athome
Copy link
Author

daniele-athome commented Dec 26, 2024

Moonlight was configured with codec autodetection, but I'm pretty sure it would autoselect HEVC. Anyway I configured it to force hardware encoding and HEVC codec. On the server I can see it is sending HEVC:

dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.358]: Info: New streaming session started [active sessions: 1]
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.367]: Info: CLIENT CONNECTED
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.369]: Info: /dev/dri/card0 -> i915
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.369]: Info: /dev/dri/card1 -> amdgpu
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.369]: Info: Screencasting with KMS
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.369]: Info: /dev/dri/card0 -> i915
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.369]: Info: /dev/dri/card1 -> amdgpu
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.370]: Info: Found monitor for DRM screencasting
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.370]: Info: Found connector ID [131]
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.370]: Info: Found cursor plane [88]
dic 26 15:57:02 server sunshine[1474]: libva info: VA-API version 1.22.0
dic 26 15:57:02 server sunshine[1474]: libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
dic 26 15:57:02 server sunshine[1474]: libva info: Found init function __vaDriverInit_1_22
dic 26 15:57:02 server sunshine[1474]: libva info: va_openDriver() returns 0
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.377]: Info: Creating encoder [hevc_vaapi]
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.377]: Info: Color coding: SDR (Rec. 601)
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.377]: Info: Color depth: 8-bit
dic 26 15:57:02 server sunshine[1474]: [2024-12-26 15:57:02.377]: Info: Color range: MPEG

I don't understand how other people can run it perfectly fine. I could try another installation from scratch and try following #1484 to the letter, maybe I'll have more luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants