From a2b1a2f3e7ea48d44b70c3a9b1e1a770ff12f868 Mon Sep 17 00:00:00 2001 From: Kris Austin Date: Mon, 19 Oct 2026 16:21:59 -0500 Subject: [PATCH] Keep an offline Moonraker printer from freezing startup (#16668) Moonraker discovery asked the printer for its name before announcing it, on the GUI thread, with a 5 s connect timeout. When the selected printer was off, the window ignored input for 5 s after every launch and the Home page stayed white. The request never produced a name. It read machine_name or hostname from /server/info, and Moonraker sends neither there. Discovery now announces the preset model name without asking the printer. --- src/slic3r/Utils/MoonrakerPrinterAgent.cpp | 12 ++---------- tests/slic3rutils/test_moonraker_printer_agent.cpp | 5 +++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp index 8494eb5cfd..025f0ba918 100644 --- a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp +++ b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp @@ -1415,16 +1415,8 @@ void MoonrakerPrinterAgent::announce_printhost_device() } } - // Try to fetch actual device name from Moonraker - // Priority: 1) Moonraker hostname, 2) Preset model name, 3) Generic fallback - std::string dev_name; - MoonrakerDeviceInfo info; - std::string fetch_error; - if (fetch_device_info(device_info.base_url, device_info.api_key, info, fetch_error) && !info.dev_name.empty()) { - dev_name = info.dev_name; - } else { - dev_name = device_info.model_name.empty() ? "Moonraker Printer" : device_info.model_name; - } + // Never asks the printer, since discovery runs on the GUI thread and an unreachable printer would freeze it + const std::string dev_name = device_info.model_name.empty() ? "Moonraker Printer" : device_info.model_name; const std::string model_id = device_info.model_id; diff --git a/tests/slic3rutils/test_moonraker_printer_agent.cpp b/tests/slic3rutils/test_moonraker_printer_agent.cpp index d3559cea1f..d3d61903fb 100644 --- a/tests/slic3rutils/test_moonraker_printer_agent.cpp +++ b/tests/slic3rutils/test_moonraker_printer_agent.cpp @@ -420,12 +420,13 @@ TEST_CASE("Moonraker discovery waits for a complete device identity", "[Moonrake agent.device_info.dev_id = "127.0.0.1:7125"; agent.device_info.dev_ip = agent.device_info.dev_id; agent.device_info.base_url = "http://127.0.0.1:7125"; + agent.device_info.model_name = "Test model"; agent.start_discovery(true, false); REQUIRE(announcements == 1); - REQUIRE(agent.fetch_count == 1); + REQUIRE(agent.fetch_count == 0); REQUIRE(announcement.at("dev_id") == agent.device_info.dev_id); REQUIRE(announcement.at("dev_ip") == agent.device_info.dev_ip); - REQUIRE(announcement.at("dev_name") == "Test printer"); + REQUIRE(announcement.at("dev_name") == "Test model"); } TEST_CASE("Stopping the status stream gives a silent printer no more than its timeouts", "[MoonrakerPrinterAgent][StatusStream]")