[TIMOB-25680] iOS 11.2: DocumentViewer not displaying PDF files (Apple regression)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-01-23T16:44:58.000+0000 |
Affected Version/s | Release 7.0.1 |
Fix Version/s | Release 7.0.2 |
Components | iOS |
Labels | applebug, documentViewer, ios |
Reporter | Motiur Rahman |
Assignee | Hans Knöchel |
Created | 2018-01-17T02:01:12.000+0000 |
Updated | 2018-01-24T16:22:40.000+0000 |
Description
Issue
Using DocumentViewer on iOS 11.2.X is not rendering PDF files.
Steps to repro
1. Just run the following test code
2. At first, place a pdf file in the resource directory.
Expected result:
.pdf file should show in the DocumentViewer.
Actual result:
.pdf file is not being shown by the DocumentViewer.
var win = Ti.UI.createWindow();
// Create a document viewer to preview a PDF file
docViewer = Ti.UI.iOS.createDocumentViewer({
url : 'example.pdf'
});
docViewer.show();
win.open();
Attachments
File | Date | Size |
---|---|---|
example.pdf | 2018-01-17T09:45:54.000+0000 | 433994 |
*EDIT*: There seems to be a breaking change in 11.2 that developers came across (known iOS issue). Basically, iOS 11.2 required developers to copy the PDF to the temporary- or application-support directory before using. Read more about it [here](https://forums.developer.apple.com/thread/91835). We will:
File a radar at Apple to provide a fix
Provide a workaround (eventually in both JS and the SDK, so an SDK-update won't necessarily required to workaround this issue)
Tested with all possible combinations (main-thread, kroll-thread, jscore, ticore) and it works fine. My example code:I've also attached my sample PDF file that worked fine. As a side-note: We haven't touched the DocumentViewer API for years, since it's a simple interface which we completely expose already.
Update
Here is the workaround for the iOS issue, together with detailed documentation about what is happening:Basically, we create a temporary file in /tmp that will be flushed once the app is closed, so it doesn't effect the device's storage. Keeping this issue open to also provide an SDK workaround that detects the type of path provided and fixes it internally. Hopefully iOS fixes this issue in iOS 11.2.x, but let's try to keep as flexible as possible.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/9741 PR (7_0_X): https://github.com/appcelerator/titanium_mobile/pull/9742 Test-Case:
Run the above test-case and remove the comment out the
isiOS11_2()
check. Without this line, the PDF will not be displayedComment it in the line if-statement again. It should now work, even with the old SDK (master/7.0.1)
Now uninstall the app, use the PR and repeat steps 1 und 2. They should still display the file without issues
FR Passed. Workaround is working as designed. Document viewer is able to display PDF files in iOS 11.X
Verified in SDK builds 7.0.2.v20180123170142 & 7.1.0.v20180124063413