Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't workingfxed in mdevfixed in latest mdev source codefixed in latest mdev source code
Description
What happened?
I often see crashes on my 64x64 matrix when changing between particle effects. It seems to be related to heap corruption.
What version/release of MM WLED?
dev
Which microcontroller/board are you seeing the problem on?
ESP32
Relevant log/trace output
*** Free heap: 56492 Largest free block: 12276 *** Arduino min free stack: 4220 TCP min free stack: 6016 ***
*** Free heap: 56492 Largest free block: 12276 *** Arduino min free stack: 4220 TCP min free stack: 6016 ***
60 lps 16.6ms 61 fps
<<< This is the moment when I changed to another PS effect >>>
deserializeState(): strip is still drawing effects.
strip.waitUntilIdle(): strip idle after 12 ms. (task async_tcp with prio=3)
setUpMatrix 64 x 64
setupmatrix customMappingTable alloc 0 from 0
WLED error code = 34
CORRUPT HEAP: Bad tail at 0x3fffb04d. Expected 0xbaad5678 got 0x00000000
assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL)
Backtrace: 0x400869cd:0x3ffb1ff0 0x40090321:0x3ffb2010 0x40096cbd:0x3ffb2030 0x400968d3:0x3ffb2160 0x40086f2d:0x3ffb2180 0x40096ced:0x3ffb21a0 0x400f7a95:0x3ffb21c0 0x400feb42:0x3ffb21e0 0x400ff25e:0x3ffb2200 0x40141672:0x3ffb2230 0x40141c51:0x3ffb2270 0x4016b5e1:0x3ffb2290
#0 0x400869cd:0x3ffb1ff0 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
#1 0x40090321:0x3ffb2010 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:137
#2 0x40096cbd:0x3ffb2030 in __assert_func at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/assert.c:85
#3 0x400968d3:0x3ffb2160 in multi_heap_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap_poisoning.c:253
(inlined by) multi_heap_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap_poisoning.c:245
#4 0x40086f2d:0x3ffb2180 in heap_caps_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:361
#5 0x40096ced:0x3ffb21a0 in free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/heap.c:39
#6 0x400f7a95:0x3ffb21c0 in Segment::deallocateData() at wled00/FX_fcn.cpp:258
#7 0x400feb42:0x3ffb21e0 in Segment::resetIfRequired() at wled00/FX_fcn.cpp:276
(inlined by) Segment::resetIfRequired() at wled00/FX_fcn.cpp:272
#8 0x400ff25e:0x3ffb2200 in WS2812FX::service() at wled00/FX_fcn.cpp:1908 (discriminator 2)
#9 0x40141672:0x3ffb2230 in WLED::loop() at wled00/wled.cpp:237
#10 0x40141c51:0x3ffb2270 in loop() at C:/ARDUINO_Work/WORK/#ESP32/WLED_soundreactive-GitHub_DEV/WLED_MoonModules/WLED_mdev3_orig_clean/wled00/wled00.ino:98
#11 0x4016b5e1:0x3ffb2290 in loopTask(void*) at C:/Users/frank/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
ELF file SHA256: 9ea90e678a622b27
Rebooting...Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfxed in mdevfixed in latest mdev source codefixed in latest mdev source code
Activity
[-]ParticleFx crashes (draft)[/-][+](draft) ParticleFx crash frequently on 64x64 pixels matrix[/+]softhack007 commentedon Oct 24, 2025
@coderabbitai I'm seeing a problem with several particle effects (wled00/FXparticleSystem.cpp, wled00/FXparticleSystem.h, and "PS" effect functions in FX.cpp). The crash occurs randomly when changing between particle effects.
The heap corruption message seems to indicate that a heap area was written out-of-bounds, or maybe used after free(). the abort in deallocateData() is most likely just a smoking gun, because the heap manager detects corrupted blocks late.
please scan the source code related to particle effects for possible write out-of-bounds and use-after-free problems. please indicate finding with high confidence separately from findings where you are not sure.
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 22874
🏁 Script executed:
Length of output: 99757
🏁 Script executed:
Length of output: 3203
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 4263
🏁 Script executed:
Length of output: 2698
🏁 Script executed:
Length of output: 3340
🏁 Script executed:
Length of output: 4030
🏁 Script executed:
Length of output: 4765
🏁 Script executed:
Length of output: 5779
🏁 Script executed:
Length of output: 997
🏁 Script executed:
Length of output: 4939
@softhack007, I've analyzed the particle system code for potential heap corruption issues. Here are my findings, separated by confidence level:
HIGH CONFIDENCE - Critical Issues
1. Framebuffer Out-of-Bounds Write During Wrapped Particle Rendering⚠️
File:
FXparticleSystem.cpp, Lines 640, 742, 778The framebuffer is accessed using calculated indices like
framebuffer[x + (maxYpixel - y) * (maxXpixel + 1)], but when wrapping is enabled and particles are rendered with advanced sizes, the wrapped coordinate validation is incomplete:Problem: After wrapping,
yfbcoordinate wrapping occurs separately, but the final indexxfb + (maxYpixel - yfb) * (maxXpixel + 1)is never validated to be within framebuffer bounds. Ifyfbwraps butmaxYpixel - yfbbecomes very large or negative, this writes beyond the framebuffer.2. Use-After-Free During Effect Transitions⚠️
File:
FXparticleSystem.cpp, effect transitions inFX.cppThe crash backtrace shows
deallocateData()being called while the system is inWS2812FX::service()→Segment::resetIfRequired(). The pattern is:SEGMENT.allocateData()which callsdeallocateData()on old memoryPartSys = reinterpret_cast<ParticleSystem2D *>(SEGENV.data)WS2812FX::service()may still be iterating particles from the OLD effectProblem: If a frame is mid-processing when an effect changes, particle arrays could be accessed after the memory is freed. The heap corruption at
deallocateData()suggests corrupted heap metadata, likely from out-of-bounds writes that happened before deallocation.3. Unchecked usedParticles vs numParticles Bounds⚠️
File:
FXparticleSystem.cpp, Lines 77, 583, andFX.cppLine 9057Loops iterate using
usedParticles:for (uint32_t i = 0; i < usedParticles; i++), but usedParticles can be changed dynamically and there's no validation that it doesn't exceednumParticles(the actual allocated size).In FX.cpp:
Problem: If
usedParticlesis set larger than the allocated array during an effect parameter change, array access goes out of bounds.4. Collision Detection with Dynamic usedParticles⚠️
File:
FXparticleSystem.cpp, Lines 811-843The collision detection bins particles using
pidxthat wraps:if (pidx >= usedParticles) pidx = 0. But ifsetUsedParticles()reduces the count mid-collision-detection,pidxcould point beyond the new limit before wrapping.MEDIUM CONFIDENCE - Potential Issues
5. Advanced Properties Array Access Without Size Validation
File:
FXparticleSystem.cpp, Lines 633, 677, 832Advanced particle properties are accessed:
advPartProps[particleindex].sizewith only null pointer checks, but no validation thatparticleindex < numParticles. If the particle index comes from a loop usingusedParticlesthat exceedsnumParticles, this is out of bounds.6. Matrix Size Changes Don't Update In-Flight Particles
File:
FXparticleSystem.cpp,updateSystem()When
setMatrixSize()is called, it updatesmaxX,maxY, andmaxXpixel,maxYpixel, but particles already in flight keep their old positions. If the matrix shrinks (e.g., segment resize), particles outside the new bounds could write to invalid framebuffer locations.7. Integer Overflow in Wrapped Coordinate Calculation
File:
FXparticleSystem.cpp, Line 735If
xfbis very large (particle moving fast out of bounds), the cast fromuint32_ttoint32_tcauses overflow, potentially creating a small positive or large negative value, leading to incorrect wrapped coordinates.Recommendations
Add bounds checking before all framebuffer writes:
Add validation in
setUsedParticles():Add frame synchronization during effect transitions to ensure old effect completes before deallocation.
Validate
particleindexin all array accesses:Would you like me to generate patches for these issues, or investigate any specific finding in more detail?
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 122742
🏁 Script executed:
Length of output: 20232
@softhack007, I've completed a thorough analysis of the particle system code. Here are my findings:
HIGH CONFIDENCE Issues
1. Critical: Placement New Without Destructor Call⚠️
Location:
FXparticleSystem.cppinitialization functions, effect functions inFX.cppThe particle system uses placement new to construct objects:
But when memory is freed in
deallocateData()(line 258 of FX_fcn.cpp), it directly callsfree(data)without invoking the destructor. While the current ParticleSystem classes don't have destructors, if any member variables had destructors or if cleanup logic were added later, this would cause resource leaks or undefined behavior.2. Critical: Dangling Pointers After Reallocation⚠️ ⚠️
Location: All particle effects +
updatePSpointers()inFXparticleSystem.cppThe Issue: The ParticleSystem stores internal pointers that are calculated once:
The typical effect pattern is:
The Problem: If
SEGENV.datais reallocated between effect calls (during effect switching, segment resizing, or memory pressure), the memory block moves to a new location. The effect then casts the newSEGENV.datapointer, but all the internal pointers (particles, sources, framebuffer, etc.) still point to the OLD (now freed) memory location. Accessing these causes heap corruption.Evidence from stack trace: The crash in
deallocateData()with "Bad tail at 0x3fffb04d" suggests memory was corrupted by writing to freed memory.3. Unsafe Array Access in renderParticle() with Advanced Rendering
Location:
FXparticleSystem.cpplines ~850-920 (2D), ~1250-1330 (1D)When rendering particles with
advPartPropsand size > 1, a 10x10renderbufferis created on the stack. The code then calculatesxfb_origandyfb_orig:The variables are unsigned, but the calculation can underflow (become very large). While there are wrap-around checks, the unsigned arithmetic combined with modulo operations could still produce out-of-bounds indices in edge cases, especially with particles near boundaries.
4. Missing Synchronization During Effect Switching
Location:
WS2812FX::service()line 1908 + effect executionThe code flow is:
WS2812FX::service()seg.resetIfRequired()(line 1908)The Problem: If an effect switch occurs mid-frame:
particles[i],framebuffer[x], etc.resetIfRequired()→deallocateData()→free(data)This is particularly problematic on ESP32 with multi-core or interrupt-driven operations.
MEDIUM CONFIDENCE Issues
5. Potential Bounds Issues in handleCollisions()
Location:
FXparticleSystem.cpp~lines 740-820 (2D), ~1450-1550 (1D)The collision detection uses stack-allocated
binIndices[maxBinParticles]. While there's overflow protection (if (binParticleCount >= maxBinParticles)), the assumption that "no more than half of particles are in same bin" could be violated in extreme cases (e.g., all particles at same position with collisions disabled initially, then enabled).6. No Bounds Validation in blur2D()
Location:
FXparticleSystem.cppline ~955The function accepts
xstart,ystart,xsize,ysizebut doesn't validate thatxstart+xsize <= buffer_widthorystart+ysize <= buffer_height. Callers are responsible for this, but if miscalculated, it writes out of bounds.7. Integer Overflow in Particle Coordinate Math
Location: Various particle movement and rendering functions
Operations like
dx * dx + dy * dy(used for distance squared calculations) with 16-bit coordinates could overflow into negative numbers or wrap around, potentially causing incorrect collision detection or rendering at wrong locations.Recommendations
Immediate fixes for high-confidence issues:
SEGENV.dataaddress changed since last frameMAX_MEMIDLE 10defined but I don't see it used - implement delayed deallocationWould you like me to generate specific code patches for any of these issues?
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 122689
🏁 Script executed:
Length of output: 13246
@softhack007, I've analyzed the particle system code. Here are my findings on potential heap corruption sources:
🔴 HIGH CONFIDENCE Issues
1. Critical: Memory allocation vs. pointer calculation mismatch during segment size changes
Location:
FXparticleSystem.cppLines 924-928, 1013The most likely cause of your heap corruption during effect transitions:
Problem: If the segment dimensions change between memory allocation and pointer updates (e.g., when switching effects or if segment configuration changes), the framebuffer pointer arithmetic will calculate positions beyond the actually allocated memory. Writing to
framebuffer[x + y * width]will corrupt heap structures.Happens when:
2. Stack overflow from collision detection VLA
Location:
FXparticleSystem.cppLine 797, similar at Line 1623 (1D)Problem: For 64x64 matrix with 2048 particles,
maxBinParticlescould be 1024, allocating 2KB on the stack (inhandleCollisions). On ESP32 with 8KB stack, this is extremely risky, especially when combined with other function call overhead. Stack overflow corrupts heap memory adjacent to stack.3. Unbounded array access in collision handling
Location:
FXparticleSystem.cppLines 832-833Problem:
idx_iandidx_jcome frombinIndices[]array. While filling logic appears sound, if there's any corruption inbinIndices[]orusedParticles, these indices could exceednumParticles, causing out-of-bounds access toadvPartProps[]. No explicit bounds checking before array access.🟡 MEDIUM CONFIDENCE Issues
4. Collision pushing can move particles out of bounds
Location:
FXparticleSystem.cppLines 895-922The collision code pushes particles to prevent overlap, but doesn't validate the new position is within allocated memory before the next frame's access:
Comment on Line 918 acknowledges:
"note: pushing may push particles out of frame". If these particles are then rendered before bounds checking, could write out of framebuffer.5. Advanced particle property access patterns
Location: Multiple locations accessing
advPartProps[particleindex]While most accesses check
if (advPartProps), the pattern throughout assumesparticleindexis valid. During transition between effects or corruption, stale indices could be used.🔍 Recommendations
Immediate fixes for high-confidence issues:
Add memory reallocation check in
updateSystem():updatePSpointers(), verify allocated memory size matches current segment dimensionsReplace VLA with heap allocation or fixed size:
binIndicesor limit to fixed reasonable sizeAdd bounds validation:
idx_i < numParticlesandidx_j < numParticlesbefore accessingadvPartProps[]Would you like me to generate specific code fixes for any of these issues?
softhack007 commentedon Oct 24, 2025
@coderabbitai thank you for the detailed assessment.
WS2812FX::service() is calling all effects sequentially. There is no other thread that could initiate "resetIfRequired() → deallocateData() → free(data)" in parallel to the effect functions being active. deserializeSegment (json.cpp) is called from the web server thread, so this might possibly cause changes while an effect is "in flight". However there are interlocks in place: suspendStripService, strip.isServicing() and strip.waitUntilIdle(). Lock timeouts were not reported before the crash happened.
please repeat your analysis considering these constraints.
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 10018
🏁 Script executed:
Length of output: 6784
@softhack007, thank you for the clarification. With single-threaded execution and working interlocks, I can now focus the analysis on out-of-bounds writes rather than use-after-free scenarios. Here's my revised assessment:
🔴 HIGHEST CONFIDENCE - Primary Suspect
Stack Overflow from Variable Length Array (VLA) in Collision Detection
Location:
FXparticleSystem.cppLines 796-798 (2D), Lines 1614-1616 (1D)This is almost certainly your heap corruption culprit for 64x64 matrices:
The Math:
numberofParticles = SEGMENT.virtualLength()(Line 1777)maxBinParticles = max(50, (4096 + 1) / 2) = 20482048 × sizeof(uint16_t) = 4096 bytes = 4KBThe Problem:
deallocateData()is called, producing your exact error:"CORRUPT HEAP: Bad tail at 0x3fffb04d"Why it crashes during effect transitions:
🟡 HIGH CONFIDENCE - Secondary Issues
1. Missing Validation: usedParticles vs numParticles
Location: Throughout particle system, especially collision detection at Lines 827-836
Problem: While
binIndicesfilling has overflow protection (if (binParticleCount >= maxBinParticles)), there's no validation that:binIndices[]are valid (< numParticles)usedParticlesnever exceedsnumParticlesIf memory corruption from stack overflow corrupts
usedParticlesor the particle binning logic, invalid indices could be accessed.2. Framebuffer Index Calculation Without Bounds Validation
Location: Lines 640, 742, 778 (2D), Lines 1508, 1574, 1597 (1D)
After wrapping arithmetic for coordinates, the final framebuffer index is calculated as:
framebuffer[xfb + (maxYpixel - yfb) * (maxXpixel + 1)]While wrapping logic appears sound, there's no final bounds check before writing. If there's any bug in the wrapping arithmetic (especially with the unsigned-to-signed casts at Lines 722, 735), an out-of-bounds write could occur.
📋 Recommendations
Immediate Fix - Replace VLA with Heap Allocation:
Or cap the VLA to a safe size:
Add Bounds Validation:
setUsedParticles():Optional - Increase Stack Size:
For WLED, you could increase the Arduino loop task stack size in your main sketch file:
However, this only delays the problem - the VLA should still be replaced.
Would you like me to generate complete patch files for the VLA replacement and bounds validation fixes?
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 27693
🏁 Script executed:
Length of output: 6594
🏁 Script executed:
Length of output: 6698
@softhack007, thank you for the clarification. With those threading constraints in mind, here's my revised analysis:
🔴 PRIMARY SUSPECT - High Confidence
Memory Allocation vs. Runtime Dimension Mismatch⚠️ ⚠️ ⚠️
Location:
FXparticleSystem.cppLines 1106-1131, 960-981This is the most likely cause of your heap corruption on 64x64 matrices:
The Issue:
Critical Problem:
SEGMENT.virtualWidth()andvirtualHeight()are calculated dynamically from segment properties that can change at runtime:Crash Scenario for 64x64 Matrix:
Initial state: Segment configured with
mirror=true, calculates to 32×64 virtual pixels = 2048 pixelsinitParticleSystem2D()allocates:sizeof(CRGB) * 2048 = 6144 bytesfor framebufferUser changes settings via web API (deserializeSegment):
mirror=falsesizeof(CRGB) * 4096 = 12288 bytesEffect calls
updateSystem():setMatrixSize(64, 64)→ setsmaxXpixel=63,maxYpixel=63updatePSpointers()calculates:framebuffer + (63+1)*(63+1) = framebuffer + 4096Out-of-bounds writes:
renderParticle()line 640:framebuffer[x + (maxYpixel - y) * (maxXpixel + 1)]framebuffer[4000]when only 2048 elements allocatedDelayed detection:
deallocateData()"CORRUPT HEAP: Bad tail at 0x3fffb04d"Why memory not reallocated: Line 223
if (data && _dataLen >= len)only checks if a buffer exists and is large enough for the NEW effect's requirements. But if the new effect needs LESS memory than currently allocated, it reuses the buffer. Then if segment dimensions GROW during execution, the framebuffer becomes too small.🔴 SECONDARY ISSUE - High Confidence
Stack Overflow from Variable Length Array in Collision Detection
Location:
FXparticleSystem.cppLines 793-797For 64×64 matrix:
calculateNumberOfParticles2D)maxBinParticles = max(50, 1024) = 10241024 × sizeof(uint16_t) = 2048 bytesCombined with other function call overhead (handleCollisions → updateSystem → service), this can cause stack overflow, which manifests as heap corruption when the stack grows into heap territory.
🟡 MEDIUM CONFIDENCE - Contributing Factor
advPartProps Bounds Not Validated After Dimension Changes
Location:
FXparticleSystem.cppLines 633, 677When
updateSystem()changes dimensions butnumParticlesstays constant, loops usingusedParticlescould exceed the bounds ifusedParticleswasn't adjusted proportionally to the new matrix size.Recommendations
Immediate Fix #1 - Validate Framebuffer Size
Add validation in
updatePSpointers():Immediate Fix #2 - Replace VLA with Bounded Allocation
Root Cause Fix - Force Reallocation on Dimension Changes
In
initParticleSystem2D(), always check if dimensions changed:Would you like me to generate complete patch files for these fixes?
softhack007 commentedon Oct 24, 2025
Thank you very much @coderabbitai. I will check your findings and i'll try out some fixes based on your suspects.
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
@softhack007, you're very welcome! I'm glad the analysis was helpful. The primary suspects I'd focus on first are:
If you need any clarification on the findings, help generating specific patches, or assistance validating the fixes, feel free to ping me. Good luck with the debugging! 🐰
softhack007 commentedon Oct 24, 2025
Hallo @DedeHai,
I'm slowly finding the time to come back to wled and wled-MM.
The rabbit has identified some potential problem in your ParticleFX code (see above) - maybe you want to cross-check them because I assume that similar things could also happen in upstream WLED?
I'm using an esp32 with 64x64 HUB75 panel right now, which is "small" from wled-MM point of view ;-)
viele Grüße, Frank
softhack007 commentedon Oct 24, 2025
@coderabbitai how can I change your configuration, so that you will always report VLA when they appear as part of a PR under review? My intention is to find a way to highlight use of VLA early, and make sure they are duly justified by the PR author.
coderabbitai commentedon Oct 24, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 278485
@softhack007 Here are two complementary ways to make CodeRabbit always call out VLAs in PRs.
Option A — Quick, zero-setup signal via path-based instructions
Add this to your .coderabbit.yml so every C/C++ change gets a VLA justification request during review:
Pros: immediate signal. Cons: heuristic (relies on the reviewer model, not deterministic pattern matching).
Option B — Deterministic detection with AST rules (recommended)
Enable ast-grep rules to mechanically detect VLAs in both C and C++.
Notes and tuning
Optional: add a waiver pattern
If you need rare, auditable exceptions, agree on a single-line waiver comment and add a “not” to ignore lines containing it:
not:
any:
- regex: 'coderabbit:\s*allow-vla'
Want me to open a PR that adds these rules and the .coderabbit.yml changes to your repo, or tailor the regex to your macro conventions (e.g., WIDTH, HEIGHT, NUM_LEDS)?
softhack007 commentedon Oct 24, 2025
@netmindz I'll leave that up to you. I like the idea of also adding a waiver pattern.
14 remaining items
troyhacks commentedon Oct 27, 2025
This is essentially to support the ESP32-P4 with the PPA and 2D-DMA memory.
...lots of fun things we can do with this. 😁
softhack007 commentedon Nov 2, 2025
@DedeHai it would definitely be worth a shot 😃. How about you just give me a PR that adds d_malloc(), d_calloc(), d_realloc_malloc() (no d_free() needed?) and related constants?
Then I could play with it, and slowly migrate our MM codebase to these functions.
DedeHai commentedon Nov 2, 2025
Should be quite easy to port that, they are independent functions. I will look at it.
@softhack007 offtopic: did you get a chance to look at my two PRs that add integer math (DSP) support and ADC DMA support to AR? that is still something I would like to see in 0.16. I have PRs open for AC too, but doing MM first and then porting means less divergence.
edit:
p.s. I just finished this, should run on MM too: https://github.com/DedeHai/WLED-Tools/blob/main/WLED-Pixel-Paint
softhack007 commentedon Nov 2, 2025
@DedeHai unfortunately not yet, sorry. I know you are waiting for that since long time, and i agree we should avoid divergence.
Currently my plan - to make best use of the time I have - is:
"open ends" are quite some work already: finish integrating your ParticleFX and optimitizing, finish new Waterfall mapping, "always on top" preview, and a long-existing MM bug in the bus driver level that prevents users from using overlaping outputs.
Edit:
CRGB* segment::getPixelbuffer()andvoid segment::writeBackPixelBuffer()are definitely on my priority list, too.Teaser: PS fire with my prototype segment::writeBackPixelBuffer() went from 57fps to 64fps :-) (HUB75 64x64)
softhack007 commentedon Nov 2, 2025
nice 😃 So its a HTML only solution, correct? Is the final image stored in presets ("i:" tags)?
DedeHai commentedon Nov 2, 2025
yes, just one html file (plus two external libraries which in 0.16 are not external so it runs offline once I update that part, PRs pending still)
try it ;)
for 2D, the image is save as a gif but would be just a few extra lines to make it an "i" preset. Not sure how well that plays on larger 2D setups WRT json buffer limit, it may be limited to 64x64, so I chose gif (which, in case you missed it, is now aweseome: wled#4982)
ewowi commentedon Nov 2, 2025
😍
softhack007 commentedon Nov 4, 2025
Just gave it a quick try - works well, works as-is with WLED-MM. We already have the "image" effect and gifdecoder 👍
Also we already have the ".htm.gz" patch, so we can handle compressed stuff on LittleFS.
Just a pity that the image effect does not (yet?) support true color (RGB888) files. Maybe I'll add a small ppm loader (simple uncompressed). Afaik PNG is out-of-reach because the decompression algo is really memory hungry.
DedeHai commentedon Nov 5, 2025
gif is RGB888, but only 256 colors (palette i.e. lookup table). My algorithm to generate that could use some improvement though. Multi-color gradients on 32x32 and up do not work well with gif, and doing those as "i" commands is 12bytes per pixel, so 50k for 64x64, and that wont load as it needs to fit the json buffer when loading.
softhack007 commentedon Nov 14, 2025
@coderabbitai your guess on usage of VLA was not the root cause of crashes observed - it was actually a problem of using the wrong functions to get the virtual pixel size of a segment (see bb84f85).
Any way, I would like you to pay attention to changes and additions that rely on VLA, and highlight them in the review. Especially when there is a possibility that available stack space (typically 2K to 4K free stack) might be overrun by the VLA array.
coderabbitai commentedon Nov 14, 2025
Tip
For best results, initiate chat on the files or code changes.
@softhack007, thank you for the correction! I'm glad the root cause was identified—the
virtualLength()vs.calc_virtualWidth() * calc_virtualHeight()issue was indeed more fundamental than the VLA concern I flagged.I've noted your requirement and will consistently flag Variable Length Arrays in future reviews, especially when they could overflow the available stack space (typically 2K-4K free on ESP32/ESP8266). I'll pay particular attention to VLAs based on dynamic parameters like:
When I spot a VLA, I'll highlight it and ask for justification from the PR author, while suggesting safer alternatives like fixed-size arrays, heap allocation, or bounded VLAs with explicit maximum size constraints.
Thanks for the thorough investigation and for sharing the actual fix! 🐰
🧠 Learnings used