Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Switching Wi-Fi connection with RTMFP usage in Worker cause crash #96

Open
itlancer opened this issue Aug 30, 2019 · 2 comments
Open

Comments

@itlancer
Copy link

@itlancer itlancer commented Aug 30, 2019

Problem Description

Switching Wi-Fi connection with RTMFP usage in Worker on Android devices cause application crash.
It has been tested with many different AIR versions even with latests AIR 32.0.0.144 beta and AIR 33.0.1.228 with different Android devices. With armv7 and armv8 build targets.
Same problem in all cases.
It works fine with Windows, macOS and iOS.
Also it works fine if you use RTMFP functionality in the main thread (not Worker).

Steps to Reproduce

Launch code below with any Android device with Wi-Fi connection. Switch (disable) Wi-Fi connection on device with quick settings menu (may be few times).
Application example with sources attached.
rtmfp_worker_crash.zip

package  {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.NetConnection;
	import flash.system.Worker;
	import flash.utils.ByteArray;
	import flash.system.WorkerDomain;
	
	public class RTMFPWorkerCrash extends Sprite {
		private var _netConnection:NetConnection;
		
		public function RTMFPWorkerCrash() {
			if (Worker.current.isPrimordial) {
				addEventListener(Event.ADDED_TO_STAGE, init);
			} else {
				trace("worker");
				
				_netConnection = new NetConnection();
				_netConnection.connect("rtmfp:");
			}
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			var worker:Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
			worker.start();
			
			addEventListener(Event.ENTER_FRAME, enterFrame);
		}
		
		//Every frame changing color rectangle just to "see" hang/crash
		private function enterFrame(e:Event):void {
			graphics.clear();
			graphics.beginFill(uint.MAX_VALUE * Math.random());
			graphics.drawRect(0, 0, 100, 100);
			graphics.endFill();
		}
	}
}

Actual Result:
Application hangs (crash). Square in top-left corner don't change it color anymore (just to "see" hang/crash).

Expected Result:
Application shouldn't crash.

Known Workarounds

none (use RTMFP in the main thread but it cause performance issues ang lags)

@ajwfrost

This comment has been minimized.

Copy link
Collaborator

@ajwfrost ajwfrost commented Dec 10, 2019

Hi

I thought I'd responded here yesterday but I guess not...

One of the guys has investigated this and found the cause for the hang - basically to do with threads (workers) vs the asynchronous callback mechanism used in Android. We can adjust the code so that this uses the appropriate instance for the thread but there is a risk that we're then affecting the RTMFP behaviour within the background worker.

Given our test cases are often doing things in isolation, I wondered whether you had a real-world application that uses RTMFP in a Worker and could test out a build for us to see if our fix is suitable or whether it introduces any knock-on issues? If that's a possibility, please contact us at adobe.support@harman.com and mention this issue reference..

thanks
Andrew

@itlancer

This comment has been minimized.

Copy link
Author

@itlancer itlancer commented Jan 28, 2020

Issue fixed with AIR 33.1.0.16 beta. Tested with armv7, armv8, x86 and x86_64 builds.
Waiting for production release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.