Open SPopenko opened 10 years ago
@SPopenko Thanks reporting. I'll check that website.
@SPopenko I've tried several times to access Toysrus site, and problem happened only one time. I'm looking for condition what caused this problem. Do you know how to represent it?
@ninjinkun I think that it happens when page has error in load and system trigger didFailLoadWithError
Most probably it could be when block executed twice for the same page. On error and on start load triggers.
if (interactive) {
_interactive = YES;
NSString *waitForCompleteJS = [NSString stringWithFormat:@"window.addEventListener('load',function() { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = '%@'; document.body.appendChild(iframe); }, false);", completeRPCURL];
[webView stringByEvaluatingJavaScriptFromString:waitForCompleteJS];
}
@SPopenko Thanks to your suggestion. It represented under bad network with Network Link Conditioner. I'll try to solve it.
I'm noticing an issue like this as well where sometimes a page doesn't reach 100%. Some will get about half way, some will only reach 10%.
If you attempt to view a github.com page, this can happen. Could this be related to history API?
I can confirm the problem for me is related to your JS on load event listener. The iframe never loads so the completeRPCURL is never requested.
A small change I made that is looking reliable, instead of using an iframe, just using a window.location:
[NSString stringWithFormat:@"window.addEventListener('load',function() { window.location = '%@'; }, false);", completeRPCURL];
Hey @ninjinkun, do you think solution suggested by @stevemckenzie good enough to integrate it in the new release? :)
@stevemckenzie window.location =
causes to override UIWebView referred URL.
But your suggestion was big hint. I found incomplete problem is caused by Content Security Policy. They refused iframe from other domain.
I'm planning that fall back to window.location
when iframe is refused, or change PRC URL scheme and domain to content URL.
@ninjinkun this sounds like a good plan. Could you let us know please when you make new release?
@ninjinkun but because you return NO in the shouldStartLoadWithRequest delegate method, isn't it fine? I've used this method to relay info back to the delegate before.
@stevemckenzie You are right. I even thought window.location
affects current URL. But I can't find any problem with shouldStartLoadWithRequest
returns NO as your suggestion.
I research two methods again.
window.location
or location.href
NJKWebViewProgress can use both two methods for single complete request.
However, I don't want to change method for conservative reason. Currently IFrame works fine without the site using Content Security Policy. And this CSP problem can avoid with #27. I want to go using proven IFrame method.
Do you have any reason to use window.location
?
@SPopenko I made pull request with new RPC URL for avoid Content Security Policy. Please try this version. https://github.com/ninjinkun/NJKWebViewProgress/pull/27
@ninjinkun thanks for this pull, it looks like it works for me! :+1:
@SPopenko Thank you!
@ninjinkun I'm sorry so long time for issue. I use new source NJKWebViewProgress on GIT. but this issue still happen. Can you support me how to fix it. thanks!
On such web sites like: http://www.toysrus.com/ the component has issue with detecting load completion. It means that it never get 100% load indicator. Please take a look on the screenshot.