pardon my ignorance. I just installed coreelec on my fire tv cube gen 3 and I’m now trying to run this moonlight add-on there. my coreelec version is the latest one, not v18 or 19 linked at the top of this post. can I still install this on top of my existing coreelec?
I’m also honestly not clear on how to install this to begin with. is there a repo? is the zip above the repo?
Luna/Moonlight on CoreELEC: black screen while the stream is actually running (fix for launch.sh)
I ran into the “stream runs, sound works, but the TV stays black” problem that several people reported in this thread (e.g. posts 306, 326, 333, and the question in 343 whether it is a black screen or Kodi’s last frame on top), and found something that fixed it reliably for me. Sharing it in case it helps.
Setup: CoreELEC 21.3 (Amlogic, 4.9 kernel), Luna script.luna 1.2.1, Moonlight Embedded 2.5.3, host: Sunshine on Linux (NVIDIA, h264, 1280x1024 @ 60 fps, 8 Mbit/s).
Symptom: after starting a game/desktop from Luna the TV is black, or shows only a frozen Kodi busy spinner, or shows only the top-left corner of the picture. At the same time:
/sys/class/vdec/vdec_status shows the frame count increasing (decoder is fine, no dropped frames),
the network receives the expected bitrate, no Unrecoverable frame in moonlight’s log,
sound works.
So it is not a network/bitrate/fps problem. In my case it happened in about 2 of 3 starts with the stock launch.sh (the stock scripts are identical to current upstream), and it was intermittent - the state I could read (/sys/class/display/mode, /sys/class/video/axis, screen_mode, OSD enable events in dmesg) was the same in black and in working starts, so I can’t tell you the exact kernel mechanism.
What I did find:
Kodi is frozen with SIGSTOP while streaming, so its last frame stays on the OSD layer, which is above the video layer. prescript.sh blanks the OSD only once.
After a display mode change /sys/class/video/axis can stay at the old resolution (e.g. a 4K axis on a 1080p mode), so only a corner of the picture is visible.
Changing things once in the middle of a running stream did not help. Re-applying them from the start of the stream did.
Fix: a modified launch.sh (coreelec launch script) that, while moonlight is running, every 2 seconds re-applies the OSD blank on fb0, sets /sys/class/video/axis to match the current display mode, and sets /sys/class/video/screen_mode to 0 (keeps aspect ratio, useful for non-16:9 sources); it restores axis/screen_mode when moonlight exits. Result on my box: stock script ~2 of 3 starts black, with the fix 0 of ~8.
Note: blanking fb1 every 2 s made the picture flicker for me, so the loop only touches fb0 and fb1 is blanked once.
Install (overlay, no binaries included - apply over an existing Luna 1.2.x install):
The release also fixes a small upstream bug in addon.py: os.system('chmod +x' + path) was missing a space, so create_bug_report.sh never became executable and the “Create bug report?” dialog crashed with PermissionError.
Unfortunately upstream Luna looks unmaintained (last commit Dec 2022, issues disabled), hence the fork. If anyone can test on other hardware (S905X3, S922X, Odroid) and report whether it helps, that would be great.
Fix: after Ctrl+Alt+Shift+Q the next stream ended at the first key
drm: picture fitted again for each stream
drm: possible fix for a black stream after the last one ended with statistics on
aml: possible fix for a broken picture after a second decoder error
aml balanced: possibly lower latency, standing frame queue cut back
aml: reference frame invalidation only when decoder error marks can be turned off
Dolby Digital: possible fix for no sound on cards with a small buffer
Sound: delay held at 60 ms, whole packets dropped, possibly fewer clicks
Possible fix for a game menu scrolling by itself at stream start
Microsoft keyboards and mice no longer get rumble commands
Experimental: “Bluetooth pads on an older chip”, off by default: asks Xbox BLE pads for an 8.75-11.25 ms link instead of their fixed 7.5 ms; for testing with several pads on older BT chips
Thanks for testing! The N2 (S922X) is a chip I dont have, so a few details would help a lot:
What does the corruption look like?
Is “Capture buffers from the display driver” turned on? (addon settings, expert level).
Video backend: drm or aml?
I need logs: set Logging to debug in the addon settings, start an HEVC stream until the corruption shows, quit, and then, before starting anything else, over ssh:
0Desktop8814487670GTA V7807552970Steam Big Picture1093255277
UI: 3 apps
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 304 value 0 → -
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 547 value 1 → RIGHT
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 547 value 0 → -
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 547 value 1 → RIGHT
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 547 value 0 → -
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 304 value 1 → OK
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 304 value 0 → -
UI: PLAYSTATION(R)3Conteroller-PANHAI: key 304 value 1 → OK
UI: telling the host the display runs at 60.00 Hz
UI: PLAYSTATION(R)3Conteroller-PANHAI went away
UI: cec_input went away
UI: input_ethrcu went away
UI: ShanWan PC/PS3/Android went away
UI: ir_keypad_common went away
UI: ir_keypad0_0 went away
UI: ir_keypad0_1 went away
Request https://192...*:47984/applist?uniqueid=0123456789ABCDEF&uuid=bb25d8d8-2c6f-4a18-8c23-e8eb104facb1
Response:
<?xml version="1.0" encoding="utf-8"?>
0Desktop8814487670GTA V7807552970Steam Big Picture1093255277
fix: aml sometimes dropped frames down, new settings “one frame per refresh” (expert setting, on by default)
aml AV1: statistics no longer stuck at 48 fps
test fix: drm HEVC on S922X only (no compressed copy),
Menu: newer stb_image and stb_truetype
I forgot to ask @Sharuman : did you turn off UVM in the settings? Before you install the latest version, please disable it first. The “no compressed copy” change only applies to DRM without UVM, because UVM needs the compressed copy.
.209 moonlight
Settings rebuilt. Options that work without restarting Moonlight are now in the menu, at the bottom. Options that need a restart stay in Kodi’s expert settings.
The UVM result is a useful clue: corruption shrinking to one area with UVM on, then becoming full-screen with UVM off, points more to the DRM/compressed-copy buffer path than HEVC decoding itself, especially since aml is clean. I’d compare .208 and .209 with UVM toggled on the same HEVC sample, and capture a debug log for each run before restarting. If the one-area corruption stays in the same screen region with UVM on, that also helps distinguish a buffer/stride issue from decoder output corruption.
I think I found the cause. On the S922X chip in the N2, the HEVC decoder makes two copies of every frame. One of them is broken on this chip. Coreelec own decoder knows this and turns that copy off, so aml works. The decoder that drm uses doesn’t do this, so the picture breaks.
Drm alone can’t fix that. With UVM, drm uses the good copy instead. In 210 i added possibly fix for the S922X: drm now always turns UVM ON (only for N2 S922x) and makes only the good copy, just like coreelec aml.
aml works well on your box, so you can keep using it.