IOS app freezes and not crash when loading video in webview

I have an iPad app developed using a third-party OpenPlug tool that converts AS3 to C ++ and from there when exporting to iOS. (I just wanted to notice that this is not a β€œnative” application using Obj-C in Xcode written by me, I wrote AS3)

I now have this iPad app that displays images and videos in a slide show. For video, I use WebView, which loads an HTML page where I change the src property of the video object to the location of the video file that was uploaded to my application store. This works fine, except that the application freezes when it runs for several hours (3-6).

I looked for this problem and tried the solution in Safari iOS memory leak when loading / unloading HTML5 <video> , but this does not seem to change anything for me.

Since the application freezes (right before the HTML page needs to load the video) and does not work, what does this mean? Do I need to destroy a video object? At first I created a new WebView for each video, but now I reuse webview and just change the src property, but that also does not help me.

Can anyone shed some light on this? OpenPlug has stopped serving it and is no longer offering any support, but nonetheless, I think this is more of a web view / video issue on the iPad (?)

It is important to note: the application freezes, but my iPad does not. The application does not generate a crash report and no longer executes any code (there are also no traces). When I click the Home button on my iPad and click the application icon, the application restarts.

Here is the code for my HTML page, which is updated every time I need to start a new video (webview.location = ...)

<html> <head> <script> function videoEndedHandler(){ var video = document.getElementById("videoPlayer"); video.src = ""; video.load(); window.location.hash = "ended"; } function videoErrorHandler(){ window.location.hash = "error"; var video = document.getElementById("videoPlayer"); video.src = ""; video.load(); } var loop; function setup(){ var video = document.getElementById("videoPlayer"); video.addEventListener("error", videoErrorHandler,false); video.addEventListener("ended", videoEndedHandler,false); video.load(); video.play(); startHashLoop(); } function startHashLoop(){ if(window.location.hash == "#touched"){ setAsPaused(); } if(window.location.hash == "#paused"){ //check image testImage("shouldResume.png?nocache=" + Math.random()); } if(window.location.hash == "#resume"){ var video = document.getElementById("videoPlayer"); video.play(); } loop = setTimeout(hashLoop,500); } function testImage(url) { var img = new Image; img.addEventListener("load",isGood); img.addEventListener("error",isBad); img.src = url; } function isGood() { window.location.hash = "resume"; } function isBad() { //alert("Image does not exist"); } function hashLoop(){ startHashLoop(); } function setAsTouched(){ window.location.hash = "touched"; } function setAsPaused(){ var video = document.getElementById("videoPlayer"); video.pause(); window.location.hash = "paused"; } </script> </head> <body onload="setup();" style="background-color:#000000;"> <a href="javascript:setAsTouched()" style="top:0;left:0;position:absolute;z-index:1;color:#FF0000;border:0px solid red;width:100%;height:100%;display:block;"></a> <video id="videoPlayer" style="top:0;left:0;position:absolute;" width="100%" height="100%" preload="auto" src="##VIDEO_URL##" autoplay="autoplay" webkit-playsinline /> </body> </html> 
+4
source share
1 answer

It would be useful if you published all your code, but I think it freezes because you are uploading video from the Internet to your main stream, which is also responsible for redrawing the user interface. By uploading a large video inside your thread, your user interface freezes as well.

I would recommend moving the code that uploads the video to a separate stream (use blocks if you're on iOS5).

0
source

All Articles