Fix infill hidden in G-code preview on Linux (forced lite mode)#581
Open
lolli42 wants to merge 1 commit into
Open
Fix infill hidden in G-code preview on Linux (forced lite mode)#581lolli42 wants to merge 1 commit into
lolli42 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_modesetting.Fixes #512
Root cause
Both the advanced renderer (
AdvancedRenderer::load_toolpaths) and the legacyrenderer (
GUI_Preview) contain a Linux-only heuristic that force-enables litemode when it judges memory to be "tight":
avail_bytescomes fromavailable_physical_memory(), which on Linux returnedsysinfo().freeram— i.e. MemFree, only fully-unused pages. Linuxdeliberately keeps MemFree low (idle RAM is used for reclaimable page/buffer
cache), so on virtually any machine
freeramis below 2 GB and below 12.5% oftotal. The heuristic therefore fired unconditionally, overrode the user's
explicit
gcode_preview_lite_mode = false, and left lite mode effectivelyalways-on on Linux — hiding infill and making the toggle appear broken.
Fix
follows
gcode_preview_lite_mode(&& !only_gcode).available_physical_memory()to report MemAvailable from/proc/meminfo(free + reclaimable cache), falling back to free + buffers onpre-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
#if defined(__linux__)or in the Linuxbranch of
available_physical_memory(). Windows/macOS behavior is unchanged.Testing
is_lite_mode=1evenwith
gcode_preview_lite_mode=false.is_lite_mode=0; toggling lite modeon/off (with a re-slice) is now honored.