Fix LAN printing crashes and hangs on Bambu H2D (#13296)

Two related fixes for LAN printing with newer Bambu networking plugins:

1. FileTransferUtils: guard against missing ft_tunnel_* symbols

   The eMMC tunnel constructor calls ft_tunnel_create / ft_tunnel_set_status_cb
   without checking if the plugin exported them. Older plugins (e.g.
   01.10.01.01) don't have these symbols, so the calls dereference null and
   crash when sending a print. Now throw a clear exception so callers can
   fall back gracefully.

2. PrintJob: disable eMMC print path by default

   Plugin 02.03.00.62's eMMC tunnel code hangs indefinitely at the upload
   phase (30%) on Bambu H2D, blocked inside the plugin waiting on a future
   that never resolves. Cancel doesn't work because the plugin doesn't
   check cancel_fn during the wait. The plain FTP path works reliably.

   Default to try_emmc_print=false; opt-in via AppConfig setting
   "disable_emmc_print" = "0". Also wrap the eMMC tunnel creation in
   try/catch so a missing-plugin exception cleanly falls back to FTP
   instead of killing the worker thread.

Co-authored-by: hyiger <hyiger@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Hyiger
2026-05-14 10:06:52 -07:00
committed by GitHub
parent d14819e58f
commit ecc53d9415
2 changed files with 27 additions and 4 deletions

View File

@@ -39,9 +39,17 @@ FileTransferModule::FileTransferModule(ModuleHandle networking_module, int requi
FileTransferTunnel::FileTransferTunnel(FileTransferModule &m, const std::string &url) : m_(&m)
{
// Guard against missing symbols in older Bambu networking plugins.
// These symbols were added in a newer plugin ABI; if the installed
// plugin predates them, ft_tunnel_create/ft_tunnel_set_status_cb
// will be null and calling them crashes.
if (!m_->ft_tunnel_create || !m_->ft_tunnel_set_status_cb) {
throw std::runtime_error("Bambu networking plugin is too old: missing ft_tunnel_* symbols. "
"Please update the networking plugin.");
}
FT_TunnelHandle *h{};
if (m_->ft_tunnel_create(url.c_str(), &h) != 0 || !h) {
throw std::runtime_error("ft_tunnel_create failed");
}
h_ = h;