I am setting up an UIWebView
to show the contents of a web camera through a URL that retrieves an MPJEG-stream.
I found out that if I wanted to switch to a different camera, it looked smoother if I did not reset the entire contents of the UIWebView
, but instead set up a javascript function in the page I loaded into it, to replace the contents of the image, like this:
<img id='iImage' src='about:blank'>
<script type='text/javascript'>
function show(url)
{
iImage.src = url;
}
</script>
If I did not do this, every time I switched to a new url, the UIWebView
went white for a second or two until the new content was ready to be displayed, with the above code it just replaces the contents directly, no whiteout.
However, if I switch back and forth between two videostreams, at some point I get an error in the UIWebView
, and by trial and error I've found out that this happens the 4th time I show the same videostream in the view. If I try to open up 4 videostreams in browser-tabs, the 4th get stuck in a loading cycle, until I close one of the previous three.
This leads me to believe that:
- The camera in question can only serve 3 streams at the same time
- Changing the
src
attribute on the<img...>
tag does not close the previous stream
Can this be linked to keepalive? Could the webkit browser system keep the previous streams alive, even though I have stopped showing them in the <img...>
tag?
Basically, to reproduce I can do this:
- Set up the above content in a
UIWebView
- Call this 4 times:
wv.EvaluateJavascript("show(url)")
On the 4th call, I get a blue question mark in the middle.
Can keep-alive be the culprit? And if so, can I control it?