-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disable range request in iPhone #7824
Conversation
Better way but NOT necessarily best way to solve the IOS webview APP error: Unexpected server response (206) while retrieving PDF... Details: 1. At the beginning, I only found the Error in IOS WeChat APP, so I solved it by checking WeChat: 9ad57d4 2. But I found this error in other IOS app, so I checked UA details of them as follow: a) iPhone WeChat APP UserAgent (Fail): Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Mobile/14B100 MicroMessenger/6.3.30 NetType/WIFI Language/zh_CN b) iPhone Other APP UserAgent (Fail): Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1 like Mac X) AppleWebKit/602.2.14 (KHTML, like Gecko) Mobile/14B100 QYZone Maybe all webview app in IOS 10 have this problem, and since Safari & Chrome in IOS also does NOT support range request in IOS, so I think it's a better way to disable range request in iPhone by this regex: var isIPhone = /iPhone/.test(navigator.userAgent); if (isIPhone) { PDFJS.disableRange = true; PDFJS.disableStream = true; } solve issues: mozilla#7815 mozilla#7754 mozilla#7800
@@ -469,8 +469,10 @@ if (typeof PDFJS === 'undefined') { | |||
|
|||
// Range requests are broken in Chrome 39 and 40, https://crbug.com/442318 | |||
var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace on this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the same problem apply to e.g. iPad
s as well?
Also, as mentioned in http://stackoverflow.com/questions/9038625/detect-if-device-is-ios: just checking for iPhone
can incorrectly match some versions of Internet Explorer too, which we should avoid.
I tested on iPad & iPhone respectively with following result: -- iPad test UserAgentiPad Safari (OK) iPad Chrome (OK) iPad QQ APP (Fail) iPad WeChat APP (Fail) -- iPhone test UserAgentiPhone WeChat APP (Fail): iPhone Other APP (Fail): |
@godwin668 how about |
Since http://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885 mentions var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(navigator.userAgent); Edit: Updated, since the |
I don't think we need window.MSStream The about does not match: |
Superseded by #7841. |
Better way but NOT necessarily best way to solve the IOS webview APP error: Unexpected server response (206) while retrieving PDF...
Details:
At the beginning, I only found the Error in IOS WeChat APP, so I solved it by checking WeChat:
godwin668@9ad57d4
But I found this error in other IOS app, so I checked UA details of them as follow:
a) iPhone WeChat APP UserAgent (Fail):
Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Mobile/14B100 MicroMessenger/6.3.30 NetType/WIFI Language/zh_CN
b) iPhone Other APP UserAgent (Fail):
Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1 like Mac X) AppleWebKit/602.2.14 (KHTML, like Gecko) Mobile/14B100 QYZone
Maybe all webview app in IOS 10 have this problem, and since Safari & Chrome in IOS also does NOT support range request in IOS, so I think it's a better way to disable range request in iPhone by this regex:
var isIPhone = /iPhone/.test(navigator.userAgent);
if (isIPhone) {
PDFJS.disableRange = true;
PDFJS.disableStream = true;
}
solve issues:
#7815
#7754
#7800