OrcaSlicer icon indicating copy to clipboard operation
OrcaSlicer copied to clipboard

2.4.x: prusaslicer:// / "open in slicer" downloads are saved as 0-byte files (2.3.5 works)

Open D3LZ-D3LZ-D3LZ opened this issue 1 month ago • 2 comments

Is there an existing issue for this problem?

  • [x] I have searched the existing issues

Snapmaker_Orca Version

2.4.1

Operating System (OS)

Linux

OS Version

CachyOS (Arch-based), KDE Plasma 6, Wayland

Additional system information

Reproduced on two separate machines

Printer

Snapmaker U1

How to reproduce

  1. Open any model link, e.g. the U1 bed model from this repo:
    flatpak run io.github.Snapmaker.Snapmaker_Orca 'prusaslicer://open?file=https%3A%2F%2Fraw.githubusercontent.com%2FSnapmaker%2FOrcaSlicer%2Fmain%2Fresources%2Fprofiles%2FSnapmaker%2FSnapmaker%2520U1_bed.stl'
    

Actual results

Evidence (strace, download thread, 2.4.1, file served from localhost)

openat(AT_FDCWD, "~/Downloads/testcube.stl.2.download", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 89
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_TCP) = 91
connect(91, {sin_port=htons(8765), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS
sendto(91, "GET /testcube.stl HTTP/1.1\r\nHost: 127.0.0.1:8765\r\nRange: bytes=0-\r\nUser-Agent: Snapmaker Orca/01.10.01.50\r\n...
recvfrom(91, "HTTP/1.0 200 OK\r\n...Content-Length: 684\r\n\r\n...", 16384, ...) = 870
recvfrom(91, "", 1024, 0, NULL, NULL) = 0
close(91)
close(89)                                  <- no write() to fd 89 at any point
rename("~/Downloads/testcube.stl.2.download", "~/Downloads/testcube.stl") = 0

The full 870-byte response (headers plus the 684-byte body) is received in one recvfrom, but no write() is made to the .download file before it is closed and renamed.

The same link on 2.3.5 shows write(78, ...) of the body, then close(78) and rename, and the file is 684 bytes.

With log_severity_level set to trace (attached log, 2.4.1, the bed model link above), there is no error. The download logs "Starting download", then 17 progress lines that all read Download 1: 1.30905e+07, and about 80 ms later load_files loads the empty file:

[info]  18:16:28.075806 Starting download from https://raw.githubusercontent.com/.../Snapmaker%20U1_bed.stl to ".../Downloads/Snapmaker%20U1_bed.stl". Temp path is ".../Snapmaker%20U1_bed.stl.2.download"
[trace] 18:16:28.155432 Download 1: 1.30905e+07      (x17, same value)
[info]  18:16:28.155497 load_files: normal_paths 1, gcode_paths 0
[debug] 18:16:28.155523 take_snapshotsnapshot name Load File: Snapmaker%20U1_bed.stl
The progress value is never a real percentage, which looks like the progress and write callbacks are getting wrong values from libcurl.

### Possibly relevant

- `src/slic3r/Utils/Downloader*.cpp` and `Http.cpp` are unchanged between `v2.3.5` and `v2.4.1`, but `deps/` changed: OpenSSL 1.1.1w -> 3.5.7, while curl stays at 7.75.0.
- The two builds' downloaders behave differently at the socket level. 2.3.5 uses blocking sockets with a TCP-loopback socketpair emulation, which looks like an older curl build. 2.4.1 uses `SOCK_CLOEXEC|SOCK_NONBLOCK` sockets, which looks like a newer curl. This suggests the libcurl the downloader actually uses changed between the builds, and the write callback no longer receives or stores the body. This is an inference from the syscalls only, not verified.


### Expected results

The downloaded file contains the model, as it does on 2.3.5.

### Project file & Debug log uploads

[snorca-2.4.1-download-log.zip](https://github.com/user-attachments/files/34073202/snorca-2.4.1-download-log.zip)

[cube-project.zip](https://github.com/user-attachments/files/34073271/cube-project.zip)

### Checklist of files to include

- [x] Log file
- [x] Project file

### Anything else?

strace, download thread, 2.4.1, file served from localhost

openat(AT_FDCWD, "~/Downloads/testcube.stl.2.download", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 89 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_TCP) = 91 connect(91, {sin_port=htons(8765), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS sendto(91, "GET /testcube.stl HTTP/1.1\r\nHost: 127.0.0.1:8765\r\nRange: bytes=0-\r\nUser-Agent: Snapmaker Orca/01.10.01.50\r\n... recvfrom(91, "HTTP/1.0 200 OK\r\n...Content-Length: 684\r\n\r\n...", 16384, ...) = 870 recvfrom(91, "", 1024, 0, NULL, NULL) = 0 close(91) close(89) <- no write() to fd 89 at any point rename("~/Downloads/testcube.stl.2.download", "~/Downloads/testcube.stl") = 0


The full 870-byte response (headers plus the 684-byte body) is received in one `recvfrom`, but no `write()` is made to the `.download` file before it is closed and renamed.

The same link on 2.3.5 shows `write(78, ...)` of the body, then `close(78)` and `rename`, and the file is 684 bytes.

Nothing about the download is logged in `Snapmaker_Orca/log/` on either version.

D3LZ-D3LZ-D3LZ avatar Oct 28 '26 10:10 D3LZ-D3LZ-D3LZ

Root cause confirmed — two real bugs in Http::priv::http_perform(): (1) the curl version test #if LIBCURL_VERSION_MAJOR >= 7 && LIBCURL_VERSION_MINOR >= 32 is false for curl 8.0–8.31, so the code takes the legacy branch; (2) that branch passes xfercb (XFERINFO signature) to CURLOPT_PROGRESSFUNCTION (legacy double signature) instead of xfercb_legacy, so the progress values are garbage — matching your log exactly.

Fix: use #if LIBCURL_VERSION_NUM >= 0x072000 and xfercb_legacy in the #else branch. Caveat: this fixes the garbage progress values, but the 0-byte file also needs the body to be delivered — please re-test on your Flatpak after this fix, as the runtime libcurl change may also be involved.

PR: https://github.com/Snapmaker/OrcaSlicer/pull/1198

creat3dworld avatar Nov 14 '26 05:11 creat3dworld

We've verified the root cause too — thanks to @D3LZ-D3LZ-D3LZ for the detailed report and strace analysis, and @creat3dworld for the analysis and #1198.

Http.cpp's curl version test (LIBCURL_VERSION_MINOR >= 32) is wrong for curl 8.x, and the legacy branch passes xfercb (the new signature) to CURLOPT_PROGRESSFUNCTION (the legacy signature), producing garbage progress values, aborting the download early and leaving a 0-byte file — exactly matching the 1.30905e+07 in the report.

Status: we'll test #1198 first (including the Flatpak runtime libcurl case), and schedule a merge if all is well. The PR switches to LIBCURL_VERSION_NUM >= 0x072000 and passes xfercb_legacy in the legacy branch.

gushanji avatar Nov 26 '26 11:11 gushanji