Bug 238393 - PDF save button saves currently loaded data - incomplete PDF saved
Summary: PDF save button saves currently loaded data - incomplete PDF saved
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: PDF (show other bugs)
Version: Safari 15
Hardware: Mac (Apple Silicon) macOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-25 14:53 PDT by mabianfu
Modified: 2022-03-28 12:41 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mabianfu 2022-03-25 14:53:20 PDT
When a PDF is only partially loaded in the built-in PDF viewer, and you click the Save button, an incomplete copy of the PDF is saved immediately to disk. 

The saved PDF has the same file size as the complete one would have, so if the first page has loaded, you get what *looks* like a complete PDF complete with thumbnail image - but it is actually not the complete file.

I'm unsure if this is a regression (I don't recall the behaviour in the past) or if it is just something that needs improvement.

I believe the issue is indeed webkit (and not Safari-specific), because I use another webkit-based browser (Orion) which has the same issue.

If it was up to me, I'd design the UI like this - just an idea:

The Save button can be clicked at any time. If PDF is not fully loaded when the button is clicked, the button changes to display a loading indicator, and when finished loading the PDF is saved to disk. This indicates to the user that saving will happen, and when it will happen. While the loading indicator is visible, hovering the cursor over it displays an "X" or similar to indicate clicking it will cancel the pending future Save action, and clicking it does just that.

For testing purposes, here is large PDF: https://docs.qgis.org/3.22/pdf/en/QGIS-3.22-DesktopUserGuide-en.pdf
(47MB user guide for open-source geospatial software QGIS)

To compare to other browsers:
Firefox's behaviour is not great. The Save button can always be clicked, but it does nothing at all if the PDF is not fully loaded. It doesn't defer a save action until it is loaded - it's just an apparently clickable button that does nothing in that situation. 

I'm not sure what Chromium does.

Thanks for your time and I apologise if my first report here is not up to snuff.
Comment 1 Radar WebKit Bug Importer 2022-03-28 06:40:25 PDT
<rdar://problem/90919383>
Comment 2 Tim Horton 2022-03-28 12:41:54 PDT
>Thanks for your time and I apologise if my first report here is not up to snuff.

Nah, it's a great first report, thank you for filing!

The problem makes sense to me (and you're right, it would be WebKit, not Safari, this is a bug in PDFPlugin). I think this even got a bit worse a few years ago when we introduced incremental PDF rendering; before you wouldn't see the first page of the PDF until the whole thing was loaded (so were less likely to click the download button button) but now you totally can.