Arksine / moonraker

Web API Server for Klipper
https://moonraker.readthedocs.io
GNU General Public License v3.0
1.05k stars 406 forks source link

Object height might not get read on large files with detailed top layers #750

Closed Jabele10 closed 10 months ago

Jabele10 commented 10 months ago

What happened

I am using PrusaSlicer (by viewing the code this might happen to other slicers as well) to slice my G-Code and had the issue that the object height sometimes had no value assigned in the Files view. I traced logs and searched the metadata.py for some indication of the problem. The problems seems to be a bad combination of circumstances:

I guess this is quite an edge case but it would be really nice to get the object height get parsed correctly even for such files.

Client

Mainsail

Browser

Chrome

How to reproduce

  1. Download this archive containing the original STL model (downloaded from Thingiverse) and the sliced G-Code for the same model
  2. Slice the original.stl file with PrusaSlicer (I used 2.6.1) or use the sliced.gcode file in the archive
  3. Upload the generated or extracted (in case you use sliced.gcode) file to Moonraker
  4. After scanning the file, the object height will stay undefined/unavailable

Additional information

Client and Browser are just the ones I used. However this issue does not depend on the Browser or client since the problem is in the Moonraker Python code itself.

Arksine commented 10 months ago

I increased the read size to 1 MiB, however this only alleviates the issue. Truthfully metadata.py isn't intended to inspect a large portion of the gcode file, and it would be preferable to avoid inspecting gcode commands all together. A more robust solution that I may look into is to create a generic metadata specification that can be added to the start or end gcode of a slicer. Most slicers seem to support placeholders, so it would be possible to put it all in one place.