Skip to content

Cura 5.13: preview thumbnail not injected due to Snapshot.snapshot() returning None (fix + PR ready) #420

Description

@hobibilgisi

Environment

  • OS: Windows 10/11
  • Ultimaker Cura: 5.13.0
  • MKS WiFi Plugin: 1.4.6-dev (this repo, develop branch)
  • Printer: MKS Robin Nano v1.x + Marlin 2.0 (Bluer / Blue Whale variant), Chitu 480×320 LCD

Summary

On Cura 5.13 the plugin silently fails to inject the ;simage: / ;;gimage:
preview header into the generated gcode. The printer's LCD shows only the
file name — the model thumbnail never appears. Affects both local
Save-to-File and WiFi upload paths.

Reproduction

  1. Cura 5.13.0, this plugin installed.
  2. Any printer profile.
  3. Load a model, slice, then File → Save to File (or Print over WiFi).
  4. Open the produced .gcode in a text editor — no ;simage: block.
  5. Printer LCD shows the file name without a thumbnail.

Log evidence

WARNING - cura.Snapshot.snapshot [200]: Failed to crop the snapshot even after 10 attempts!
DEBUG   - MKSWifiPlugin.MKSPreview.add_preview: Skipping adding screenshot

Root cause

Four cascading defects — all four need to be addressed for the LCD
thumbnail to appear reliably:

  1. cura.Snapshot.snapshot() returns None on Cura 5.13 — OpenGL /
    QQuickView timing issue. After 10 retries the crop step gives up and
    returns None. add_preview immediately bails out with
    Skipping adding screenshot.
  2. CuraEngineBackend.getLatestSnapshot() uses the same broken code
    internally
    — not a valid fallback on its own.
  3. MKSOutputDevice.requestWrite only fires its own writeStarted signal,
    not OutputDeviceManager.writeStarted, so add_preview is never
    invoked on the WiFi upload path (only local save triggers it).
  4. mks_simage / mks_gimage default to 0 for community printer
    profiles that don't declare them. int(None) never happens because
    the if ... in meta_data guard skips it — but when a profile does
    declare an invalid or zero value, an empty preview is produced.

Fix (submitted as PR)

  • MKSPreview.take_screenshot() — new fallback chain
    Snapshot.snapshot → Snapshot.isometricSnapshot → backend.getLatestSnapshot.
    Snapshot.isometricSnapshot() builds its own offscreen Camera +
    PreviewPass + QtRenderer and does not depend on viewport render state,
    so it works reliably on Cura 5.13.
  • MKSPreview.generate_preview() — sensible defaults (simage=100,
    gimage=200) and clamp non-positive values.
  • MKSOutputDevice.requestWrite() — direct MKSPreview.add_preview(self)
    call right after self.writeStarted.emit(self) so WiFi uploads inject
    the preview too.

After the fix

Cura log now contains:

DEBUG - MKSWifiPlugin.MKSPreview.take_screenshot: MKSPreview: using Snapshot.isometricSnapshot fallback

Produced gcode starts with:

;simage:...
;;gimage:...
;MKSPREVIEWPROCESSED

Thumbnail appears on the printer's LCD for both Save-to-File and
Print-over-WiFi paths. Verified on real hardware (MKS Robin Nano v1.x +
Marlin 2.0 Bluer variant).

References

Disclosure

Root-cause analysis, patch and documentation developed with AI-assisted
coding (GitHub Copilot + Claude). All patches were validated on real
hardware by the human contributor before this report was filed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

issue: bugThe described behavior is considered as wrong (bug).status: pendingWaiting for a response from the contributors

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions