Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thread is being killed by the OS

I'm currently programming an app that extracts frames from a movie clip. I designed it so that the extraction will be done on a separate thread to prevent the application from freezing. The extraction process itself is taking a lot of resources, but works fine when used in the simulator. However, there are problems when building it for the iPad. When I perform another action (I'm telling my AV player to play while I extract frames), the thread unexpectedly stops working, and I believe it's being killed.

I assume it's becauase I'm using a lot of resources, but not entirely sure.

Here are my questions: 1. How can I tell if/why my thread stopping? 2. If it's really from over processing what should I do? I really need this action to be implemented.

Heres some code im using: To create the thread:

[NSThread detachNewThreadSelector:@selector(startReading) toTarget:self withObject:nil];

I'll post any information you need, Thanks so much!

Update I'm using GCD now and it populates the threads for me. However the OS still kills the threads.

I know exactly when is it happening. when i tell my [AVplayer play]; it kills the thread.

This issue is only happening in the actual iPad and not on the simulator

like image 816
Or Ron Avatar asked Nov 07 '11 21:11

Or Ron


1 Answers

It sounds to me like you are trying to decode two video clips at the same time. Due to the hardware based decoding nature of the iPad, it can only support one decode process at a time. When you play a new item the old will be cancelled. This would explain why it works in the simulator, but not on the device.

As for a solution, you can switch to a pure software decoder like libav (GPL) or the CoreAVC SDK (commercial). That way you won't interfere with the HW decoder for playback.

like image 58
Gil Avatar answered Oct 11 '22 05:10

Gil