WLED icon indicating copy to clipboard operation
WLED copied to clipboard

Issue with the WLED frontend [DMX serial-out cannot handle 144 LEDs]

Open Stijn-Jacobs opened this issue 3 months ago • 1 comments

What happened?

After just having built the master build from source, I'm experiencing a weird issue where the frontend stops working after setting my led stripe length. I have DMX enabled on this build.

After configuring my LED config with the ui it works. This is the relevant part of my working config;

    "led": {
      "total": 5,
      "maxpwr": 8000,
      "cct": false,
      "cr": false,
      "ic": false,
      "cb": 0,
      "fps": 60,
      "rgbwm": 255,
      "prl": false,
      "ins": [
        {
          "start": 0,
          "len": 4,
          "pin": [
            16
          ],
          "order": 1,
          "rev": false,
          "skip": 0,
          "type": 22,
          "ref": false,
          "rgbwm": 0,
          "freq": 0,
          "maxpwr": 0,
          "ledma": 55,
          "text": ""
        },
        {
          "start": 4,
          "len": 1,
          "pin": [
            18
          ],
          "order": 1,
          "rev": false,
          "skip": 0,
          "type": 22,
          "ref": false,
          "rgbwm": 0,
          "freq": 0,
          "maxpwr": 0,
          "ledma": 255,
          "text": ""
        }
      ]
    },

If I then change the length of the strip from 1 to 144, the frontend throws the following exception:

TypeError: Cannot read properties of undefined (reading 'on')
    at readState ((index):7:66326)
    at (index):7:71514

This points to the javascript

function readState(e, t=!1) {
                if (!e)
                    return !1;
                if (e.success)
                    return !0;
                isOn = e.on,
                gId("sliderBri").value = e.bri,
                nlA = e.nl.on,
                nlDur = e.nl.dur,
                nlTar = e.nl.tbri,
                nlFade = e.nl.fade,

Where it seems to be failing to properly read the current state. If I revert the led length back to 1, everything functions normally again.

To Reproduce Bug

  1. Build WLED from source with DMX enabled
  2. Set led strip length to 144, from the default 30.
  3. Frontend no longer functions becouse of javascript exception.

Expected Behavior

Working frontend after having configured the correct led stripe length.

Install Method

Self-Compiled

What version of WLED?

WLED 0.16.0-alpha (2506160)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output


Anything else?

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

Stijn-Jacobs avatar Nov 29 '25 16:11 Stijn-Jacobs

Narrowed down the issue. It was caused by WLED simply unable to handle 144 leds worth of DMX output. I've hardcoded a limit so it only outputs 10 leds worth of DMX (while outputting to the leds as normal) and this seems to resolve the issue.

Maybe there should be an option to configure what actually is outputted to DMX, instead of just all registered strips?

Stijn-Jacobs avatar Nov 30 '25 19:11 Stijn-Jacobs

Maybe there should be an option to configure what actually is outputted to DMX, instead of just all registered strips?

@Stijn-Jacobs i've checked the DMX serial output code, and it seems that your analysis is correct. The handleDMXOutput() function is called in the wled main loop without any rate limiting, so it will very likely try to push out all LEDs to serial, no matter if the serial interface (and serial buffer) can handle it. In particular, the DMX output speed is not in sync with the LEDs rendering framerate. This will cause UI stalls, audioreactive lagging behind sound input, and may even lead to reboot by watchdog timer.

I've sketched a possible fix here, however I don't have any DMX hardware so cannot test if this will really improve the behaviour without unwanted side-effects.

softhack007 avatar Dec 15 '25 21:12 softhack007

Maybe there should be an option to configure what actually is outputted to DMX, instead of just all registered strips?

@Stijn-Jacobs i've checked the DMX serial output code, and it seems that your analysis is correct. The handleDMXOutput() function is called in the wled main loop without any rate limiting, so it will very likely try to push out all LEDs to serial, no matter if the serial interface (and serial buffer) can handle it. In particular, the DMX output speed is not in sync with the LEDs rendering framerate. This will cause UI stalls, audioreactive lagging behind sound input, and may even lead to reboot by watchdog timer.

I've sketched a possible fix here, however I don't have any DMX hardware so cannot test if this will really improve the behaviour without unwanted side-effects.

Thanks for your input. DMX itself is limited to 44hz max. But I think on the ESP32 that will still cause issues with 512 channels@44hz (512 is the max channels on 1 DMX cable). I think the only real solution is to have a setting for the max channels of DMX output, in combination with some sort of limiting. I'll see if I can test your changes myself.

Stijn-Jacobs avatar Dec 15 '25 21:12 Stijn-Jacobs