Compare commits

..
Author SHA1 Message Date
SoftFever 64267e90e2 Fix multi-device task list using a deleted network agent after plug-in reload 2026-10-14 01:58:06 +08:00
SoftFever 5501d52464 Use if/else for the empty plug-in version check 2026-10-14 01:56:02 +08:00
SoftFever 80d81ddbfe Merge branch 'main' into fix/login-crash 2026-10-14 01:16:35 +08:00
Boris Samorodov 008ee792f6 Fix DockerRun.sh failing when the host UID already exists in the image (#16373)
The ubuntu:24.04 base image has a built-in ubuntu user with UID 1000, so the Dockerfile skips creating the host user and `docker run -u "$USER"` cannot find it. Run the container with the numeric UID and GID instead, and set HOME and the working directory to the bind-mounted home.
2026-10-13 11:57:16 -05:00
peachismomo ecbcaf034d fix: directly use !config_version.empty() for the control block 2026-10-13 21:21:45 +08:00
peachismomo b6db90fdbf fix: login crash when network plugin is unavailable 2026-10-13 21:14:21 +08:00
4 changed files with 81 additions and 69 deletions
+5 -2
View File
@@ -12,8 +12,11 @@ docker run \
--net=host \
`# Some X installs will not have permissions to talk to sockets for shared memory` \
--ipc host \
`# Run as your workstations username to keep permissions the same` \
-u "$USER" \
`# Run as your workstations UID and GID to keep permissions the same.` \
`# Numeric IDs work even when the image has no user with your name` \
-u "$(id -u):$(id -g)" \
-e HOME="/home/$USER" \
-w "/home/$USER" \
`# Bind mount your home directory into the container for loading/saving files` \
-v "$HOME:/home/$USER" \
`# Pass the X display number to the container` \
+59 -61
View File
@@ -3925,81 +3925,74 @@ bool GUI_App::on_init_network(bool try_backup)
if (config_version.empty()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": no version configured, need to download";
m_networking_need_update = true;
} else {
int load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(false, config_version);
__retry:
if (!load_agent_dll) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll ok";
if (!m_device_manager)
m_device_manager = new Slic3r::DeviceManager();
if (!m_user_manager)
m_user_manager = new Slic3r::UserManager();
return false;
}
int load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(false, config_version);
__retry:
if (!load_agent_dll) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll ok";
std::string loaded_version = Slic3r::NetworkAgent::get_version();
if (app_config && !loaded_version.empty() && loaded_version != "00.00.00.00") {
// Self-heal only when a genuinely different series loaded than configured (e.g. the
// configured build was unavailable and a fallback loaded). Within a series the
// loaded build (02.08.01.53) differs from the series config (02.08.01) by design, so
// compare series, not the raw string, and store the managed series form - a custom
// config (02.08.01_custom) keeps its own name.
std::string config_version = app_config->get_network_plugin_version();
std::string loaded_series = network_plugin_series(loaded_version);
if (network_plugin_series(config_version) != loaded_series) {
std::string synced = is_series_managed_version(loaded_version) ? loaded_series : loaded_version;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": syncing config version from " << config_version
<< " to loaded " << loaded_version << " (stored as " << synced << ")";
app_config->set_network_plugin_version(synced);
app_config->save();
std::string loaded_version = Slic3r::NetworkAgent::get_version();
if (app_config && !loaded_version.empty() && loaded_version != "00.00.00.00") {
// Self-heal only when a genuinely different series loaded than configured (e.g. the
// configured build was unavailable and a fallback loaded). Within a series the
// loaded build (02.08.01.53) differs from the series config (02.08.01) by design, so
// compare series, not the raw string, and store the managed series form - a custom
// config (02.08.01_custom) keeps its own name.
std::string config_version = app_config->get_network_plugin_version();
std::string loaded_series = network_plugin_series(loaded_version);
if (network_plugin_series(config_version) != loaded_series) {
std::string synced = is_series_managed_version(loaded_version) ? loaded_series : loaded_version;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": syncing config version from " << config_version
<< " to loaded " << loaded_version << " (stored as " << synced << ")";
app_config->set_network_plugin_version(synced);
app_config->save();
}
}
}
if (check_networking_version()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, compatibility version";
auto bambu_source = Slic3r::NetworkAgent::get_bambu_source_entry();
if (!bambu_source) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": can not get bambu source module!";
m_networking_compatible = false;
if (check_networking_version()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, compatibility version";
auto bambu_source = Slic3r::NetworkAgent::get_bambu_source_entry();
if (!bambu_source) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": can not get bambu source module!";
m_networking_compatible = false;
if (should_load_networking_plugin) {
m_networking_need_update = true;
}
}
} else {
if (try_backup) {
int result = Slic3r::NetworkAgent::unload_network_module();
BOOST_LOG_TRIVIAL(info) << "on_init_network, version mismatch, unload_network_module, result = " << result;
load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(true, config_version);
try_backup = false;
goto __retry;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, version dismatch, need upload network module";
if (should_load_networking_plugin) {
m_networking_need_update = true;
}
}
} else {
if (try_backup) {
int result = Slic3r::NetworkAgent::unload_network_module();
BOOST_LOG_TRIVIAL(info) << "on_init_network, version mismatch, unload_network_module, result = " << result;
load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(true, config_version);
try_backup = false;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll failed";
// A failed install can leave the config naming a build that never made it to disk;
// fall back to the installed latest instead of dropping the user into the re-download
// flow. Only when the configured library is genuinely absent, though - a pinned series
// that is on disk but failed to load once must keep its pin, not be rewritten for good.
std::string latest = get_latest_network_version();
if (config_version != latest && !BBLNetworkPlugin::versioned_library_exists(config_version)
&& BBLNetworkPlugin::versioned_library_exists(latest)) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": falling back to installed " << latest;
config_version = latest;
app_config->set_network_plugin_version(latest);
app_config->save();
load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(false, config_version);
goto __retry;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, version dismatch, need upload network module";
if (should_load_networking_plugin) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, need upload network module";
m_networking_need_update = true;
}
}
} else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll failed";
// A failed install can leave the config naming a build that never made it to disk;
// fall back to the installed latest instead of dropping the user into the re-download
// flow. Only when the configured library is genuinely absent, though - a pinned series
// that is on disk but failed to load once must keep its pin, not be rewritten for good.
std::string latest = get_latest_network_version();
if (config_version != latest && !BBLNetworkPlugin::versioned_library_exists(config_version)
&& BBLNetworkPlugin::versioned_library_exists(latest)) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": falling back to installed " << latest;
config_version = latest;
app_config->set_network_plugin_version(latest);
app_config->save();
load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(false, config_version);
goto __retry;
}
if (should_load_networking_plugin) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, need upload network module";
m_networking_need_update = true;
}
}
}
@@ -4027,6 +4020,11 @@ bool GUI_App::on_init_network(bool try_backup)
else
m_user_manager->set_agent(m_agent);
// A hot reload deletes the agent the task manager was built with. It lives until restart, so repoint it
// even if multi-device has since been turned off.
if (m_task_manager)
m_task_manager->set_agent(m_agent);
if (this->is_enable_multi_machine()) {
if (!m_task_manager) {
m_task_manager = new Slic3r::TaskManager(m_agent);
+12 -5
View File
@@ -171,6 +171,11 @@ TaskManager::TaskManager(NetworkAgent* agent)
;
}
void TaskManager::set_agent(NetworkAgent* agent)
{
m_agent = agent;
}
int TaskManager::start_print(const std::vector<PrintParams>& params, TaskSettings* settings)
{
@@ -240,17 +245,18 @@ int TaskManager::schedule(TaskStateInfo* task)
fire_lifecycle_event(LifecycleEvent::PrintJobStarted, start_ctx);
int result = -1;
if (!m_agent) {
NetworkAgent* agent = m_agent;
if (!agent) {
BOOST_LOG_TRIVIAL(trace) << "task_manager: NetworkAgent is nullptr";
}
else {
assert(m_agent);
assert(agent);
try {
// DEBUG FOR TEST
#if 0
result = start_print_test(task->get_params(), task->update_status_fn, task->cancel_fn, task->wait_fn);
#else
result = m_agent->start_print(task->get_params(), task->update_status_fn, task->cancel_fn, task->wait_fn);
result = agent->start_print(task->get_params(), task->update_status_fn, task->cancel_fn, task->wait_fn);
#endif
} catch (const std::exception& ex) {
BOOST_LOG_TRIVIAL(error) << "task_manager: start_print threw: " << ex.what();
@@ -363,12 +369,13 @@ std::map<int, TaskStateInfo*> TaskManager::get_local_task_list()
std::map<std::string, TaskStateInfo> TaskManager::get_task_list(int curr_page, int page_count, int& total)
{
std::map<std::string, TaskStateInfo> out;
if (m_agent) {
NetworkAgent* agent = m_agent;
if (agent) {
TaskQueryParams task_query_params;
task_query_params.limit = page_count;
task_query_params.offset = curr_page * page_count;
std::string task_info;
int result = m_agent->get_user_tasks(task_query_params, &task_info);
int result = agent->get_user_tasks(task_query_params, &task_info);
BOOST_LOG_TRIVIAL(trace) << "task_manager: get_task_list task_info=" << task_info;
if (result == 0) {
try {
+5 -1
View File
@@ -16,6 +16,7 @@
#include <vector>
#include <map>
#include <mutex>
#include <atomic>
#include <wx/event.h>
@@ -158,6 +159,8 @@ public:
static int SendingInterval;
TaskManager(NetworkAgent* agent);
void set_agent(NetworkAgent* agent);
int start_print(const std::vector<PrintParams>& params, TaskSettings* settings = nullptr);
static void set_max_send_at_same_time(int count);
@@ -184,7 +187,8 @@ private:
std::vector<boost::thread*> m_sending_thread_list;
std::mutex m_scedule_mutex;
bool m_started { false };
NetworkAgent* m_agent { nullptr };
// Replaced on the main thread whenever networking is re-initialised, read by the sending threads.
std::atomic<NetworkAgent*> m_agent { nullptr };
std::chrono::system_clock::time_point last_sent_timestamp;
};