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

[Linux] DatagramSocket doesn't work in Worker #3389

Open
itlancer opened this issue Aug 1, 2024 · 0 comments
Open

[Linux] DatagramSocket doesn't work in Worker #3389

itlancer opened this issue Aug 1, 2024 · 0 comments
Labels

Comments

@itlancer
Copy link

itlancer commented Aug 1, 2024

Problem Description

DatagramSocket doesn't work in Worker for Linux platform.
Tested with DatagramSocket::send() and DatagramSocket.broadcast().
So right now there is no way to avoid UI blocking by intensive DatagramSocket usage.

Tested with multiple AIR versions, even with latest AIR 51.0.1.5 with multiple different Ubuntu 22.04 x86_64 devices and applications.
Same issue in all cases using DatagramSocket from Worker.
There is no such issue using DatagramSocket in main thread.
Also there is no such issues for Windows platform.

Related issues:
#580
https://tracker.adobe.com/#/view/AIR-4198607
https://tracker.adobe.com/#/view/AIR-4198606

Steps to Reproduce

  1. With another device launch any UDP server. You can use Windows device with UDP Test Utility https://udp-test-tool.informer.com/
    Bind port 10000 (or another one).
  2. In code below change remote IP address to IP address of device with UDP server. Also change port 10000 to another one if needed.
  3. Launch application with this code with any Linux x86_64 device in the same local network. It should launch DatagramSocket in Worker and send UDP data to specified remote device every second.

Application example with sources attached.
linux_worker_datagram_socket_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.DatagramSocketDataEvent;
	import flash.events.Event;
	import flash.net.DatagramSocket;
	import flash.system.Worker;
	import flash.system.WorkerDomain;
	import flash.utils.ByteArray;
	import flash.utils.setInterval;
 
	public class LinuxWorkerDatagramSocketBug extends Sprite {
		private var _datagramSocket:DatagramSocket;
 
		public function LinuxWorkerDatagramSocketBug() {
			if (Worker.current.isPrimordial) {
				addEventListener(Event.ADDED_TO_STAGE, init);
            } else {
				trace("worker");
				_datagramSocket = new DatagramSocket();
				_datagramSocket.bind(10000, "0.0.0.0");
				_datagramSocket.addEventListener(DatagramSocketDataEvent.DATA, datagramSocket_data);
				_datagramSocket.receive();
				setInterval(send, 1000);
            }
        }
		
		private function send():void {
			trace("send");
			
			var byteArray:ByteArray = new ByteArray();
			byteArray.writeBoolean(true);
			//Change IP address in line below according where client launched
			_datagramSocket.send(byteArray, 0, 0, "192.168.3.2", 10000);
		}
		
		private function datagramSocket_data(e:DatagramSocketDataEvent):void {
			trace("data: " + e.data.length);
		}
		
        private function init(e:Event):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
			
            var worker:Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes, true);
            worker.start();
        }
	}
}

Actual Result:
No data will be received by remote device.
In Scout we can see that data seems to be sent with no errors. But remote Windows device with UDP Test Utility didn't received it.
image

Expected Result:
Data sending via DatagramSocket from Worker works as expected. Remote device received data as with DatagramSocket usage in the main thread.
image

Known Workarounds

Use DatagramSocket in main thread but it could block UI with intensive UDP communication.

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

No branches or pull requests

1 participant