Xcode AVPlayer崩溃iPhone 5 - Titanium iOS模块

时间:2015-09-12 22:05:14

标签: objective-c iphone titanium titanium-modules

我已经为流媒体音频编写了一个Titanium iOS模块。 在iPhone 5s及以上的应用程序和模块运行良好。

问题是每次在iPhone 5或我的应用程序中调用stopStream函数时,应用程序崩溃。

我认为存在内存泄漏或其他问题,但我找不到解决该问题的方法。

这是我的模块代码:

//这个功能开始了流。 IPHONE 5上没有问题

-(id)startStream:(id)args
{
    ENSURE_SINGLE_ARG(args,NSString);

    NSURL *url = [NSURL URLWithString:args];

    playerItem = [AVPlayerItem playerItemWithURL:url];

    [playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil];

    player = [[AVPlayer playerWithPlayerItem:playerItem] retain];
    [player addObserver:self forKeyPath:@"status" options:0 context:nil];
    [player play];

    [self fireEvent:@"START" withObject:nil];

    NSLog(@"[INFO] player item error : %@", playerItem.error.description);
    NSLog(@"[INFO] player error : %@", player.error.description);

    return args;
}

//这是我的应用程序在IPHONE 5上崩溃的功能

-(id)stopStream:(id)args
{
     NSLog(@"[INFO]AVPlayer STOP");
    [player pause];
    [playerItem removeObserver:self forKeyPath:@"timedMetadata" context:nil];
    [player removeObserver:self forKeyPath:@"status" context:nil];

    player=nil;
}

这是设备日志的一部分。

296 00:43:40 W TestApp[3487] <Warning>: [INFO]AVPlayer STOP 
297 00:43:40 E ReportCrash[3490] <Error>: task_set_exception_ports(B07,    400, D03, 0, 0) failed with error (4: (os/kern) invalid argument) 
301 00:43:40 W mediaserverd[37] <Warning>: 00:43:40.969 [0x3257000] CMSession retain count > 1! 
306 00:43:41 W SpringBoard[43] <Warning>: [MPUSystemMediaControls] Updating supported commands for now playing application. 
307 00:43:41 W SpringBoard[43] <Warning>: [MPUSystemMediaControls] Updating supported commands for now playing application. 
308 00:43:41 W SpringBoard[43] <Warning>: Unable to get short BSD proc info for 3483: No such process 
309 00:43:41 W SpringBoard[43] <Warning>: Unable to get short BSD proc info for 3487: No such process 
310 00:43:41 W SpringBoard[43] <Warning>: Unable to get short BSD proc info for 3487: No such process 
311 00:43:41 W SpringBoard[43] <Warning>: Unable to get short BSD proc info for 3487: No such process 
312 00:43:41 E ReportCrash[3490] <Error>: Not saving crash log because we have reached the limit for logs to store on disk.  Sync or otherwise clear logs from /var/mobile/Library/Logs/CrashReporter to save new logs. 
313 00:43:41 E ReportCrash[3490] <Error>: Could not save crash report to disk! 
314 00:43:41 W SpringBoard[43] <Warning>: Application 'UIKitApplication:com.fpmsoft.isa.TestApp[0x476c]' crashed. 
315 00:43:41 W assertiond[58] <Warning>: pid_suspend failed for <BKNewProcess: 0x14d90e90; com.fpmsoft.isa.TestApp; pid: 3487; hostpid: -1>: Unknown error: -1, Unknown error: -1 
316 00:43:41 W assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x14d90e90; com.fpmsoft.isa.TestApp; pid: 3487; hostpid: -1> to 2, priority: No such process 
317 00:43:41 W assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x14d90e90; com.fpmsoft.isa.TestApp; pid: 3487; hostpid: -1> to 4096, priority: No such process 
318 00:43:41 W UserEventAgent[17] <Warning>: id=com.fpmsoft.isa.TestApp pid=3487, state=0 
319 00:43:41 E ReportCrash[3490] <Error>: Incident Identifier: 5CF594F7-3628-4EAE-88D6-B6AA4DC4C028 
320 00:43:41 E ReportCrash[3490] <Error>: CrashReporter Key:   509d7f4d78bbd031f5bf1a6ef122f14f5be24f8b 
321 00:43:41 E ReportCrash[3490] <Error>: Hardware Model:      iPhone5,2 
322 00:43:41 E ReportCrash[3490] <Error>: Process:             TestApp [3487] 
323 00:43:41 E ReportCrash[3490] <Error>: Path:                /private/var/mobile/Containers/Bundle/Application/78A7A4DB-3377-4875-B86F-217F1B8DFF9E/TestApp.app/TestApp 
324 00:43:41 E ReportCrash[3490] <Error>: Identifier:          TestApp 
325 00:43:41 E ReportCrash[3490] <Error>: Version:             ??? 
326 00:43:41 E ReportCrash[3490] <Error>: Code Type:           ARM (Native) 
327 00:43:41 E ReportCrash[3490] <Error>: Parent Process:      launchd [1] 
328 00:43:41 E ReportCrash[3490] <Error>: Date/Time:           2015-09-13 00:43:40.855 +0200 
329 00:43:41 E ReportCrash[3490] <Error>: Launch Time:         2015-09-13 00:43:34.825 +0200 
330 00:43:41 E ReportCrash[3490] <Error>: OS Version:          iOS 8.3 (12F70) 
331 00:43:41 E ReportCrash[3490] <Error>: Report Version:      105 
332 00:43:41 E ReportCrash[3490] <Error>: Exception Type:  EXC_BAD_ACCESS (SIGSEGV) 
333 00:43:41 E ReportCrash[3490] <Error>: Exception Subtype: KERN_INVALID_ADDRESS at 0x9805ac14 
334 00:43:41 E ReportCrash[3490] <Error>: Triggered by Thread:  6 
335 00:43:41 E ReportCrash[3490] <Error>: Thread 0 name:  Dispatch queue: com.apple.main-thread 
336 00:43:41 E ReportCrash[3490] <Error>: Thread 0: 
337 00:43:41 E ReportCrash[3490] <Error>: 0   libsystem_kernel.dylib         0x359b1474 0x359b0000 + 5236 
338 00:43:41 E ReportCrash[3490] <Error>: 1   libsystem_kernel.dylib         0x359b1268 0x359b0000 + 4712 
339 00:43:41 E ReportCrash[3490] <Error>: 2   CoreFoundation                 0x2708256e 0x26fb5000 + 841070 
340 00:43:41 E ReportCrash[3490] <Error>: 3   CoreFoundation                 0x27080b14 0x26fb5000 + 834324 
341 00:43:41 E ReportCrash[3490] <Error>: 4   CoreFoundation                 0x26fcd1fc 0x26fb5000 + 98812 
342 00:43:41 E ReportCrash[3490] <Error>: 5   CoreFoundation                 0x26fcd00e 0x26fb5000 + 98318 
343 00:43:41 E ReportCrash[3490] <Error>: 6   GraphicsServices               0x2e8ac1fc 0x2e8a3000 + 37372 
344 00:43:41 E ReportCrash[3490] <Error>: 7   UIKit                          0x2a771a54 0x2a702000 + 457300 
345 00:43:41 E ReportCrash[3490] <Error>: 8   TestApp                         0x00024ca2 0x20000 + 19618 
346 00:43:41 E ReportCrash[3490] <Error>: 9   libdyld.dylib                  0x358faaac 0x358f9000 + 6828 
347 00:43:41 E ReportCrash[3490] <Error>: Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager 
348 00:43:41 E ReportCrash[3490] <Error>: Thread 1: 
349 00:43:41 E ReportCrash[3490] <Error>: 0   libsystem_kernel.dylib         0x359b1224 0x359b0000 + 4644 
350 00:43:41 E ReportCrash[3490] <Error>: 1   libdispatch.dylib              0x358e60ec 0x358d8000 + 57580 
351 00:43:41 E ReportCrash[3490] <Error>: 2   libdispatch.dylib              0x358dad36 0x358d8000 + 11574 
352 00:43:41 E ReportCrash[3490] <Error>: Thread 2 name:  Dispatch queue: com.appcelerator.anlaytics.databaseQueue 
353 00:43:41 E ReportCrash[3490] <Error>: Thread 2: 
354 00:43:41 E ReportCrash[3490] <Error>: 0   libsystem_kernel.dylib         0x359b14c4 0x359b0000 + 5316 
355 00:43:41 E ReportCrash[3490] <Error>: 1   libdispatch.dylib              0x358e45da 0x358d8000 + 50650 
356 00:43:41 E ReportCrash[3490] <Error>: 2   CFNetwork                      0x26b50c6c 0x26aef000 + 400492 
357 00:43:41 E ReportCrash[3490] <Error>: 3   CFNetwork                      0x26b6bd3a 0x26aef000 + 511290 
358 00:43:41 E ReportCrash[3490] <Error>: 4   TestApp                         0x00374bbc 0x20000 + 3492796 
359 00:43:41 E ReportCrash[3490] <Error>: 5   TestApp                         0x0036c1d2 0x20000 + 3457490 
360 00:43:41 E ReportCrash[3490] <Error>: 6   libdispatch.dylib              0x358e0a38 0x358d8000 + 35384 
361 00:43:41 E ReportCrash[3490] <Error>: 7   TestApp                         0x0036bdaa 0x20000 + 3456426 
362 00:43:41 E ReportCrash[3490] <Error>: 8   libdispatch.dylib              0x358d92cc 0x358d8000 + 4812 

2 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法。 我必须在函数中添加一个返回值。 现在它适用于iPhone5及更低版本

-(id)stopStream:(id)args
{
     NSLog(@"[INFO]AVPlayer STOP");
    [player pause];

    [playerItem removeObserver:self forKeyPath:@"timedMetadata" context:nil];
    [player removeObserver:self forKeyPath:@"status" context:nil];

    return args;
}

答案 1 :(得分:0)

你也过度保留了这名球员。您应[player release];stopStream中的startStream仅在实例化新player时才会显示。{/ p>