Skip to content

Fix infill hidden in G-code preview on Linux (forced lite mode)#581

Open
lolli42 wants to merge 1 commit into
CrealityOfficial:masterfrom
lolli42:fix/512-lite-mode
Open

Fix infill hidden in G-code preview on Linux (forced lite mode)#581
lolli42 wants to merge 1 commit into
CrealityOfficial:masterfrom
lolli42:fix/512-lite-mode

Conversation

@lolli42

@lolli42 lolli42 commented Jul 13, 2026

Copy link
Copy Markdown

Summary

On Linux, the G-code preview permanently hid infill (and other internal
toolpaths), and the in-app Lite Mode toggle never stuck — regardless of the
gcode_preview_lite_mode setting.

Fixes #512

Root cause

Both the advanced renderer (AdvancedRenderer::load_toolpaths) and the legacy
renderer (GUI_Preview) contain a Linux-only heuristic that force-enables lite
mode when it judges memory to be "tight":

const bool low_available = (avail_bytes > 0 && avail_bytes < 2GB);
const bool low_ratio     = (avail_bytes / total_bytes < 0.125);
if (!only_gcode && (low_available || low_ratio || huge_preview))
    is_lite_mode = true;   // overrides the user's explicit setting

avail_bytes comes from available_physical_memory(), which on Linux returned
sysinfo().freeram — i.e. MemFree, only fully-unused pages. Linux
deliberately keeps MemFree low (idle RAM is used for reclaimable page/buffer
cache), so on virtually any machine freeram is below 2 GB and below 12.5% of
total. The heuristic therefore fired unconditionally, overrode the user's
explicit gcode_preview_lite_mode = false, and left lite mode effectively
always-on on Linux — hiding infill and making the toggle appear broken.

Fix

  • Remove the auto-enable override from both renderers so lite mode strictly
    follows gcode_preview_lite_mode (&& !only_gcode).
  • Fix available_physical_memory() to report MemAvailable from
    /proc/meminfo (free + reclaimable cache), falling back to free + buffers on
    pre-3.14 kernels. This also corrects the LOD memory estimate in 3DScene.cpp,
    which uses the same function and was being throttled on the same bad reading.

Platforms

  • Linux only — all changes are under #if defined(__linux__) or in the Linux
    branch of available_physical_memory(). Windows/macOS behavior is unchanged.
  • Users who want lite mode can still enable it via the toggle; it now persists.

Testing

  • Built and run on Linux Mint 22.3 (Ubuntu 24.04 base, GCC 13).
  • Before: infill hidden in preview; debug log shows is_lite_mode=1 even
    with gcode_preview_lite_mode=false.
  • After: infill renders; log shows is_lite_mode=0; toggling lite mode
    on/off (with a re-slice) is now honored.

The G-code preview had a Linux-only heuristic (in both the advanced
and legacy renderers) that force-enabled "lite mode" whenever it
judged memory tight or the preview huge, overriding the user's
explicit gcode_preview_lite_mode setting. With lite mode on, infill
and other internal toolpaths are hidden and the in-app toggle never
sticks (issue CrealityOfficial#512).

The memory check used available_physical_memory(), which on Linux
returned sysinfo().freeram (MemFree) -- only fully-unused pages.
Linux keeps MemFree low by design (idle RAM holds reclaimable page
cache), so the "< 2 GB" and "< 12.5% of total" tests fired on
essentially every Linux machine regardless of real memory pressure,
making lite mode effectively always-on.

Remove the override from both renderers so lite mode strictly
follows the config value (&& !only_gcode). Also fix
available_physical_memory() to report MemAvailable from
/proc/meminfo (free + reclaimable cache), falling back to
free + buffers on pre-3.14 kernels -- this also corrects the LOD
memory estimate in 3DScene.cpp that used the same function.
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.

Can't turn off Lite Mode in Preview

1 participant