VideoTexture sequence unpredictable crash on iOS
Hi all,
We are trying to play several clips sequence with VideoTextures but code is crashing unpredictably on iOS devices from time to time.
I have created sample codebase for it, so one can try it. Sources are here https://www.dropbox.com/s/wdnf5q2zrq73f1l/VideoTextureTest.zip?dl=0 Here is full logic of what is happening:
package videotexturetest.views.application
{
import feathers.controls.ImageLoader;
import flash.events.NetStatusEvent;
import flash.net.NetConnection;
import flash.net.NetStream;
import starling.display.Sprite;
import starling.events.Event;
import starling.textures.Texture;
public class ApplicationView extends Sprite
{
private var _currentIndex = 1;
private var _numVideos = 8;
private var _image:ImageLoader;
private var _connection:NetConnection;
private var _currentStream:NetStream;
private var _currentTexture:Texture;
private var _nextStream:NetStream;
private var _nextTexture:Texture;
public function ApplicationView()
{
addEventListener(Event.ADDED_TO_STAGE, function(event:Event):void
{
initialize();
});
}
private function prepareNextStream():void
{
if (_currentIndex == _numVideos)
{
_nextStream = null;
_nextTexture = null;
return;
}
trace("Preparing next texture:", "videos/clip_" + (_currentIndex + 1) + ".mp4");
// Second NetStream connection
_nextStream = new NetStream(_connection);
_nextStream.client = { onMetaData : function(infoObject:Object) {} };
Texture.fromNetStream(_nextStream, 1, function(texture:Texture):void
{
trace("Video texture is ready:", "videos/clip_" + (_currentIndex + 1) + ".mp4");
_nextTexture = texture;
_nextStream.togglePause();
});
_nextStream.play("videos/clip_" + (_currentIndex + 1) + ".mp4");
}
private function initialize():void
{
_image = new ImageLoader();
_image.setSize(stage.stageWidth, stage.stageHeight);
addChild(_image);
_connection = new NetConnection();
_connection.connect(null);
// First NetStream connection
_currentStream = new NetStream(_connection);
_currentStream.client = { onMetaData : function(infoObject:Object) {} };
_currentStream.addEventListener(NetStatusEvent.NET_STATUS, function(event:NetStatusEvent):void
{
if (event.info.code == 'NetStream.Play.Stop' && _nextStream)
{
var stream:NetStream = event.target as NetStream;
stream.removeEventListener(NetStatusEvent.NET_STATUS, arguments.callee);
_currentIndex++;
_nextStream.addEventListener(NetStatusEvent.NET_STATUS, arguments.callee);
_image.source = _nextTexture;
_nextStream.togglePause();
_currentTexture.dispose();
_currentStream.close();
_currentTexture = _nextTexture;
_currentStream = _nextStream;
prepareNextStream();
}
});
Texture.fromNetStream(_currentStream, 1, function(texture:Texture):void
{
trace("Video texture is ready:", "videos/clip_" + _currentIndex + ".mp4");
_currentTexture = texture;
_image.source = _currentTexture;
});
prepareNextStream();
_currentStream.play("videos/clip_" + _currentIndex + ".mp4");
}
}
}
Two streams exist as same time. One for current video and second one for next one. It allows us to switch videos without flickering. Code works fine on desktop (air simulator) but when I try to launch it in real ios device app is crashing and I have the following error in device logs:
May 29 07:41:57 iPhone-Alexey ReportCrash[3541] <Notice>: ReportCrash acting against PID 3540
May 29 07:41:57 iPhone-Alexey ReportCrash[3541] <Notice>: Formulating crash report for process VideoTextureTest[3540]
May 29 07:41:57 iPhone-Alexey com.apple.launchd[1] (UIKitApplication:VideoTextureTest[0x917b][3540]) <Warning>: (UIKitApplication:VideoTextureTest[0x917b]) Job appears to have crashed: Segmentation fault: 11
May 29 07:41:57 iPhone-Alexey mediaserverd[3071] <Warning>: 07:41:57.609 [0x3f31000] CMSession retain count > 1!
May 29 07:41:57 iPhone-Alexey backboardd[28] <Warning>: Application 'UIKitApplication:VideoTextureTest[0x917b]' exited abnormally with signal 11: Segmentation fault: 11
May 29 07:41:57 iPhone-Alexey mediaserverd[3071] <Warning>: Encountered an XPC error while communicating with backboardd: <error: 0x3c8d7744> { count = 1, contents =
"XPCErrorDescription" => <string: 0x3c8d79dc> { length = 22, contents = "Connection interrupted" }
}
May 29 07:41:57 iPhone-Alexey mediaserverd[3071] <Error>: 07:41:57.670 [0x4035000] sessionID = 0xbff6e4: cannot get ClientInfo
May 29 07:41:57 iPhone-Alexey mediaserverd[3071] <Error>: 07:41:57.673 ERROR: [0x4035000] 150: AudioQueue: Error 'ini?' from AudioSessionSetClientPlayState(0xbff6e4)
Could anyone suggest something about this issue? Is it a problem in NetStream or it somehow connected to VideoTexture?
Same information was published in Starling forum VideoTexture « Starling Forum
