Skip to content

Fix divide by zero exception in InterlockingGenerator.#9925

Merged
lanewei120 merged 1 commit into
bambulab:masterfrom
mpaperno:mp/fix_interlock_divzero
Mar 13, 2026
Merged

Fix divide by zero exception in InterlockingGenerator.#9925
lanewei120 merged 1 commit into
bambulab:masterfrom
mpaperno:mp/fix_interlock_divzero

Conversation

@mpaperno

@mpaperno mpaperno commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #9910

There's a more fundamental issue in that the current config option minimum/maximum value types are int, so setting a minimum of something like 0.1 doesn't work (minimum becomes zero). The GUI validation then doesn't work as expected. Some of the code seems to completely ignore that fact, like for this interlocking beam width option:

def->min = 0.01;

I'll likely submit a PR for that fix next, unless it turns into a bigger deal than it appears so far.

Thanks,
-Max

@mpaperno

mpaperno commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

Somewhat related:

The generator hangs during slicing when the beam width gets "too small". I'm not clear on what defines the actual practical lower limit. For example on an arbitrary test object (some text on bottom of a cube), using .4 nozzle with .2 layer height and .42 line width, reducing the beam width to 0.1 caused a hang. With 0.2 width it took a long time but completed (though generated "garbage"). After switching to .6 nozzle w/ .3/.62 height/width, it no longer hangs with a beam width of 0.1, but will with 0.01 (the currently configured minimum value).

@Noisyfox Perhaps you can take a look? (I think you originally ported this? If not, sorry and NVM!) It's probably preferable not to impose some arbitrary minimum, if it could be calculated. Or maybe the algorithm could be improved to skip unworkable cells?

There's no way to exit gracefully after a hang, the "stop" button in the status bar window is ineffective. Which is likely a separate issue in general (haven't looked).

-Max

@Noisyfox

Copy link
Copy Markdown
Contributor

Are you able to provide a test project that would cause a hang (possibly created by BBS and Orca separately)? Thanks.

@mpaperno

mpaperno commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Noisyfox , thanks for your response.

I should have tested more thoroughly and provided a repro case to begin with, and probably a separate issue. Turns out maybe it's more of an edge case than I thought (my luck that the "random object" I tested with happened to exhibit the issue).

I'm attaching a repro project here since I'm posting anyway, but really this should be a separate Issue, for further discussion. I'm happy to open one if you (or anyone else) wants to work on this. Given the specific nature of what I discovered the overall state of Studio, perhaps it's not a huge priority.

In the attached project, if I just change the global-level interlocking beam width to 0.1, I get the hang. It start slowing down and doing funky things around 0.3 width.

I'm pretty sure it is because of the thin part of the text object piece, under/joining the text characters (this was an example I made for someone on the forums). It is 0.05mm thick, and I'm not sure why it's even appearing in the sliced result in this specific configuration (with or w/out interlocking).

If the layer height is changed to anything smaller than .24mm, this thin bit is no longer sliced at all (I'd expect the opposite, if anything). And I don't get the hang with 0.1 beam width (though it still takes a bit of time). Same if I change initial layer height to .24, or if I flip the cube over so the text is on top. But when it is included in the sliced result, for whatever reason, that seems to cause the interlock generator to... lock up.

It could be that if that piece was thicker and always in included in the sliced result, say as one layer, that the issue could also be reproduced. But I haven't tried.

I haven't tried Orca, but I've reduced the project file to the bare minimum changes to reproduce the issue, which are basically selecting a .4 nozzle, the default .24mm profile, and enabling interlock.

Thanks,
-Max

(Unpacking not required, just rename to remove the .zip extension.)
Interloack-Test2.bs25.3mf.zip

@ArthurBambulab ArthurBambulab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. Thank you~

@lanewei120 lanewei120 merged commit cdd60ab into bambulab:master Mar 13, 2026
14 of 16 checks passed
@lanewei120

Copy link
Copy Markdown
Collaborator

thank you for doing this~
@mpaperno

@Noisyfox

Noisyfox commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

I managed to slice the project file with 0.1mm beam width after ~4 minutes, so it's not completed hang, but very slow due to too many microstructures generated.

Even though I haven't figured out a way of determine the proper lower limit of this size, nor have I figured out why it generats funny results with such parameters, however I do managed to solve the cancellation problem. Now it can properly been cancelled with the following changes:
Noisyfox/OrcaSlicer@4859174

It shouldn't be hard to cherry pick those changes to BBS I believe.

@mpaperno

Copy link
Copy Markdown
Contributor Author

I do managed to solve the cancellation problem.

That's even better, thank you! Now people can try silly things with less concern. And you have more patience than I do... didn't make it past a couple minutes' waiting.

I can definitely 'pick those changes if you prefer, easy enough! Thanks again.

@mpaperno

Copy link
Copy Markdown
Contributor Author

Thank you @ArthurBambulab and @lanewei120 ! Nice to hear from you. Cheers!

SoftFever added a commit to OrcaSlicer/OrcaSlicer that referenced this pull request Mar 15, 2026
With certain irrational beam interlocking parameters, it will take a few
minutes to complete the interlocking generation; even worse:
cancellation doesn't work once it started.

This PR fix that by adding cancellation check inside some of the most
time consuming loops so it can be stopped ASAP.

Also cherry picked a sanity check from
bambulab/BambuStudio#9925 by @mpaperno. Thanks!

The following test project (which was modified from the upper PR by
@mpaperno) took me more than 90s to complete with 0.1mm beam width:

[Interloack-Test2.orca.3mf.txt](https://github.com/user-attachments/files/25975637/Interloack-Test2.orca.3mf.txt)
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

Successfully merging this pull request may close these issues.

Divide by zero - Beam

4 participants