Our iOS app has a Web View that is rendering pages from file: URLs. When the user touches an <A> element to switch pages, about 20% of the time, it gets stuck as follows:
- User taps
<A>link - We get WebView.shouldStartLoadWithRequest callback
- We get WebView.webViewDidStartLoad callback
- nothing happens after this
The screen still shows the original page with the link on it. We can break the logjam in two ways:
- Rotate the device
- Tap the screen
At that point, the page will immediately finish loading.
We used the recipe from here:
Javascript console.log() in an iOS UIWebView
to allow us some insight into the page load. We put the javascript-side stuff right in the first script file we load on the page, and it doesn’t print its message until after we do the rotate-or-tap workaround.
So it appears that it is getting stuck somewhere between starting to load the page, and starting to evaluate the stuff on the page.
We have tried a number of work-around, none of which helped:
- Setting location.href instead of using the tag
- Setting location.href from javascript timeout
- In the didStartLoad callback, created a thread that called setNeedDisplay on the webView over and over
Any idea what we might be doing wrong?
You could use gdb within XCode to debug the problem. I think canidates for messages that could have break points are:
I’d also add a break in whatever UIViewController is showing your UIWebView for:
Then you could step through and hopefully catch what’s wrong with your UIWebView subclass.
If you don’t want to add breakpoints you could just run your app in the XCode debugger and hit the “pause execution” button above the console window when your app becomes unresponsive while loading.
It’s hard to know what’s going on without any code to go off of but I bet Xcode can help you find the issue quickly.
Good luck!