iOS app crashes if a NetStream is referenced by a class variable when app is brought to foreground
Consistently happens on AIR 32 (tried also 27 and 31), iOS 12 and 8.
A video of this happening on both iOS8 and iOS12: airiosbug.mp4 - Google Drive
Just create a NetConnection and a NetStream.
If class has a variable referncing the NetStream, if app is brought to background and then to foreground, it crashes immediately.
If NetStrean is not referenced, app doesn't crash.
Crash log infact reports a null pointer.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Note that app works perfectly and for a long time if not brought to background and back to foreground again. Crashes only when brought back to foreground.
You can download source code here: https://drive.google.com/open?id=1s92-Wv99dechTZgqRxNMpf-C1SabxBNh
Here is the only code:
Commenting: "_ns = ns;" application does not crash.
package
{
import flash.display.MovieClip;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.text.TextField;
/**
* ...
* @author Pippo Gregoretti
*/
public class MainAppDebug extends MovieClip
{
private var _tf:TextField;
private var _ns:NetStream;
public function MainAppDebug()
{
super();
trace("Debugging AIR application.");
//(_debugConsole as DebugConsole).show();
_tf = new TextField();
_tf.border = true;
_tf.width = stage.stageWidth;
_tf.height = stage.stageHeight;
_tf.multiline = true;
addChild(_tf);
addText("Debugging AIR Application");
addText("Creating NetStreams...");
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
/* THIS IS THE CULPRIT. COMMENT "_ns = ns" AND APP WILL NOT CRASH */
_ns = ns;
}
private function addText(t:String):void {
_tf.appendText(t + "\n");
}
}
}
