apache / apache/cordova-plugin-inappbrowser
PDF blobs no longer load in v5.0.0 on iOS 14.4.2
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
# Bug Report
## Problem
I'm not sure if this should have worked to begin with but I was hoping to use the in app browser to display in memory PDFs. In v4.1.0 this seemed to work just fine however in v5.0.0 this no longer renders the PDF. I verified this by switching the plugin between versions and noticing the change in behaviour.
### What is expected to happen?
In v4.1.0 the PDF would render in the in app browser window.
Stack trace:
```
2021-04-08 20:26:30.078627+0100 [656:46453] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2021-04-08 20:26:30.078706+0100 [656:46453] WF: _WebFilterIsActive returning: NO
2021-04-08 20:26:30.087310+0100 [656:46453] THREAD WARNING: ['InAppBrowser'] took '19.270752' ms. Plugin should use a background thread.
2021-04-08 20:26:30.172211+0100 [656:46453] No
2021-04-08 20:26:30.183759+0100 [656:46453] didStartProvisionalNavigation
2021-04-08 20:26:30.633742+0100 [656:46453] Unbalanced calls to begin/end appearance transitions for .
```
### What does actually happen?
In v5.0.0 displays a blank in app browser window. From reading the stack trace what jumps out at me is WebKitBlobResource (code 1).
Stack trace:
```
2021-04-08 20:17:19.278086+0100 [637:43483] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2021-04-08 20:17:19.278183+0100 [637:43483] WF: _WebFilterIsActive returning: NO
2021-04-08 20:17:19.281601+0100 [637:43483] THREAD WARNING: ['InAppBrowser'] took '12.166016' ms. Plugin should use a background thread.
2021-04-08 20:17:19.362538+0100 [637:43483] No
2021-04-08 20:17:19.362796+0100 [637:43483] didStartProvisionalNavigation
2021-04-08 20:17:19.372718+0100 [637:43483] [Process] 0x13c08f018 - [pageProxyID=22, webPageID=23, PID=642] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = WebKitBlobResource, code = 1
2021-04-08 20:17:19.373055+0100 [637:43483] webView:didFailProvisionalNavigation - 1: The operation couldn’t be completed. (WebKitBlobResource error 1.)
2021-04-08 20:17:19.823854+0100 [637:43483] Unbalanced calls to begin/end appearance transitions for .
2021-04-08 20:17:45.559624+0100 [637:43483] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
```
## Information
I think the below code should be all thats needed. You'll need to grab the contents of a PDF and initialise `pdf` with that.
### Command or Code
```js
const blob = new Blob([pdf], {type:'application/pdf'});
const url = URL.createObjectURL(blob);
window.cordova.InAppBrowser.open(url, '_blank');
```
From reading around https://github.com/mozilla/pdf.js/issues/8152#issue-213375356 it seems that using blobs is unreliable in iOS safari and I guess the in app browser was using wkwebview before which is why this wasn't exhibited before?
Hopefully thats enough info to go on but if you need any more info let me know. I did try and find what was going on myself but I'm a bit out of my depth here 😓
### Environment, Platform, Device
iOS 14.4.2
### Version information
cordova-plugin-inappbrowser: 5.0.0
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Start with the JavaScript reproduction using window.cordova.InAppBrowser.open and compare the in-app browser behavior between plugin v4.1.0 and v5.0.0 on iOS 14.4.2. Investigate the WebKitBlobResource failure and verify the PDF blob renders in the in-app browser when the issue is fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100