Question

I have a web view that is constantly refreshing and showing new videos and images. I suspect the objects within the HTML page are not properly deallocated because I have slowly growing memory. I also get a crash with calling a method on MPAVItem which has already been deallocated. I'm not using MPAVItem directly, its an object created and used automatically by the webview for my embedded videos. The specific crash dump is

Thread 0:
0   libobjc.A.dylib                 0x3b17c636 objc_msgSend + 22
1   Foundation                      0x30ef4aca +[NSConcreteNotification newTempNotificationWithName:object:userInfo:] + 118
2   Foundation                      0x30ef4a20 -[NSNotificationCenter postNotificationName:object:userInfo:] + 48
3   Foundation                      0x30ef9316 -[NSNotificationCenter postNotificationName:object:] + 26
4   MediaPlayer                     0x3183ff04 __53-[MPAVItem _playerItemNewAccessLogEntryNotification:]_block_invoke + 68

I have to leave the app running for a nearly an hour before it crashes. With the web page refreshing every 7 seconds it will crash either cos of too many processes, out of memory or accessing MPAVItem. I've tried everything I've found on the net such as javascript tricks like pausing the video, rewinding it, setting video src to '', clearing the whole document, setting webview to nil. Nothing is fully removing these objects. To make things more complicated I have the images and videos in an iframe. The code in the main document is actually the "player" which controls the reloading of the iframe contents. The iframe changes contents every 7 seconds and the whole page (the player) refreshes every 20 seconds.

Was it helpful?

Solution

Some time ago I had a problem with a UIWebView myself. The video was not showing all the time (sometimes it did sometimes it didn't).

This is not exactly your problem, but keep reading. ;) What I discover was that the constraints are very important for the webview. If you did not set the constraints please set them and double check them if they are set probably.

In my case the video was retrying to be played in the view. This was causing a memory leak in the program. So the constraints can be a factor in the memory leak.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top