PDFs with form fields crash in Safari
See original GitHub issueThe following PDFs from the test/pdfs/
directory crash the viewer in Safari:
test/pdfs/160F-2019.pdf
test/pdfs/annotation-text-widget.pdf
test/pdfs/issue12963.pdf
test/pdfs/issue6127.pdf
test/pdfs/prefilled_f1040.pdf
Affected version
-
Commit: a17bd1302
-
Date: 2021-07-13
-
pdfjs.config
:{ "betaVersion": "2.9.359", "stableVersion": "2.8.335", "baseVersion": "e667c8cbcf8a8368dfab5eccb6b6f7999f1ae275", "versionPrefix": "2.10." }
Affected platforms
Safari on the following OS’s:
- MacOS 11.4 Big Sur (Safari 14.1.1)
- iPadOS 14.6
- iOS 14.6
Steps to reproduce
-
Install and then run web server:
$ git clone https://github.com/mozilla/pdf.js.git $ cd pdf.js $ npm install $ gulp server
-
Open http://localhost:8888/test/pdfs/?frame in Safari.
-
Click on top link in list, for
160F-2019.pdf
Expected result
File 160F-2019.pdf
is rendered correctly.
Actual result
The web page crashes with the error:
A problem repeatedly occurred with "localhost:8888/test/pdfs/?frame"
There are no errors logged in the JavaScript console.
Additional notes
-
Here is a .gif showing the issue:
-
These PDFs load properly and also have (some) form fields:
test/pdfs/annotation-tx.pdf
test/pdfs/annotation-tx2.pdf
test/pdfs/annotation-tx3.pdf
test/pdfs/bug1669099.pdf
test/pdfs/doc_actions.pdf
test/pdfs/evaljs.pdf
test/pdfs/issue12504.pdf
test/pdfs/issue12706.pdf
test/pdfs/issue12750.pdf
test/pdfs/issue13269.pdf
test/pdfs/issue13271.pdf
test/pdfs/issue9972-1.pdf
test/pdfs/issue9972-2.pdf
test/pdfs/issue9972-3.pdf
test/pdfs/js-authors.pdf
test/pdfs/js-buttons.pdf
test/pdfs/js-colors.pdf
test/pdfs/listbox_actions.pdf
test/pdfs/pr12828.pdf
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (2 by maintainers)
Top Results From Across the Web
ALL PDF files crash Safari! - Apple Community
2) Go into the Safari settings (very glad these are outside of the app) and Clear Cache. This immediately solves the problem because...
Read more >Fill & Sign Crashing since update
Every time I open any pdf file, select fill & sign, & select me as who is editing, within a few seconds the...
Read more >Known issues | Acrobat, Reader - Adobe Support
Forms. Problem: Fields from the dropdown menu do not get placed on the ... when PDF is launched in the Safari browser (version...
Read more >Third-Party Compatibility - PSPDFKit
Apple uses a custom PDF renderer (CGPDF) that's part of Core Graphics. It's quite capable, but it is known to crash/freeze or not...
Read more >Troubleshooting | Help Center
Mac iOS In case the file can't be opened and instead you see the message about it being corrupted, these are the first...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tracked down the cause of the crash to this line:
https://github.com/mozilla/pdf.js/blob/51f0a810851c311598748f637fb583b20b7dce03/src/display/annotation_layer.js#L900
The following PDFs from the
test/pdfs/
directory will no longer crash the viewer in Safari with that line commented out (although letter spacing is now messed up in certain cases):It seems that Safari’s CSS
calc
function can’t handlech
units inletter-spacing
.I created a minimum test for this, in case anyone with access to Safari wants to try it out:
I installed the Safari Technology Preview for Big Sur from here: https://developer.apple.com/safari/download/ and the bug is fixed there. For reference, I think this WebKit bug report and patch might be related to the crashing behavior:
I have no idea when Safari will actually see this fix. In the meantime, the crashing behavior is present across MacOS, iOS and iPadOS.
Given https://github.com/mozilla/pdf.js/issues/13726#issuecomment-929517624 let’s close this issue here, since: