From ef876fe5770f1822720927ba692de11605ac646f Mon Sep 17 00:00:00 2001 From: Rodrigo Faselli <162915171+RF47@users.noreply.github.com> Date: Mon, 5 Jan 2026 09:15:23 -0300 Subject: [PATCH] Wipe Tower Auto Brim bug-fix (Non BBL printers) (#11831) # Description Fix application freeze when Prime Tower brim is set to Auto This PR fixes an issue where enabling Auto brim width for the Prime Tower caused the application to freeze and consume unbounded amounts of memory. Root cause https://github.com/OrcaSlicer/OrcaSlicer/blob/0c5f6c9865642f7ba923aee412f54f79f29531a2/src/libslic3r/GCode/WipeTower2.cpp#L2036-L2039 When Auto brim is selected, the brim width was not being computed and the raw configuration value (-1) was used directly. This resulted in an effectively infinite loop during Prime Tower brim generation, leading to runaway memory allocation instead of a controlled failure or a crash. Solution The Auto brim width is now properly computed based on the Prime Tower height, matching the intended behavior and existing logic used in other slicer implementations. --- src/libslic3r/GCode/WipeTower2.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/GCode/WipeTower2.cpp b/src/libslic3r/GCode/WipeTower2.cpp index 6bec4168f4..19e98e4a09 100644 --- a/src/libslic3r/GCode/WipeTower2.cpp +++ b/src/libslic3r/GCode/WipeTower2.cpp @@ -2036,7 +2036,11 @@ WipeTower::ToolChangeResult WipeTower2::finish_layer() // brim (first layer only) if (first_layer) { writer.append("; WIPE_TOWER_BRIM_START\n"); - size_t loops_num = (m_wipe_tower_brim_width + spacing/2.f) / spacing; + float brim_width = m_wipe_tower_brim_width; + if (brim_width < 0.f) + brim_width = WipeTower::get_auto_brim_by_height(m_wipe_tower_height); + + size_t loops_num = (brim_width + spacing / 2.f) / spacing; for (size_t i = 0; i < loops_num; ++ i) { poly = offset(poly, scale_(spacing)).front();