开发者

MPMoviePlayerController Thread lock problem - Iphone development

开发者 https://www.devze.com 2023-01-29 17:44 出处:网络
My app main thread is displaying a movie at the beginning , while other thread are doing background tasks.

My app main thread is displaying a movie at the beginning , while other thread are doing background tasks. Some however, are using PerformSelectorInMainThread to do some stuff. What happens is that sometimes the movie just get stuck indefinitely , sometimes not , and sometimes get free after a couple seconds. I'm trying to debug it, however when I'm pausing XCode while the app is stuck all I see is assembly code and I can't really understand anything from it. (I guess something like "symbols" on windo开发者_开发问答ws would be cool) Is there a way to analyze more thoroughly what is running on the main thread and might stuck my video while it's playing ? Moreover, how come the video get stuck anyway, if i'm playing a video from the main thread while other thread calls PerformSelectorInMainThread , what is really happening (I assumed it would add the selector as an event but won't disturb the movie from playing till the end) ?

Thanks for your help!!


Have you tried using Shark (one of the Instruments tools) to analyze samples?

When things are getting "stuck", it likely means the CPU is churning. Shark samples the CPU every so often (well, in human terms, VERY frequently) during a short burst (I would keep it under 5-10 seconds) and tells you what percentage of the time the CPU is spending on what tasks.

It does exactly what you mention - reverse engineers all the assembly code to look more like the debugger (well, not 100%, but enough).

That would be the first step - identifying the processor-heavy task that your performSelectorOnMainThread: code is calling that causes the video to gum up. Then, once you know what it is - the answer will either be obvious - or you'll have to change your architecture :)

0

精彩评论

暂无评论...
验证码 换一张
取 消