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

Worker doesn't support classes from native extensions with ADL launch #2385

Closed
itlancer opened this issue Dec 26, 2022 · 3 comments
Closed
Labels

Comments

@itlancer
Copy link

itlancer commented Dec 26, 2022

Problem Description

Worker doesn't support classes from native extensions with ADL launch. Application just throw ReferenceError exception in run-time when you try to call or get anything from classes from native extensions using Worker. With complex AIR applications and native extensions Worker immediately terminated just after running (or even dispatch "terminated" status twice, without "running").
So AIR application that uses native extension classes inside Worker cannot be tested with IDE.

It has been tested with multiple AIR versions (even with latest AIR 50.1.1.2), different Adobe Animate and VS Code versions with different Windows devices.
Same problem in all cases.
After packaging application and launching it (without ADL) all works fine.

Related issue: https://tracker.adobe.com/#/view/AIR-4198547

Steps to Reproduce

Launch code below with any IDE. It just start Worker and trace constant from native extension class (TestANE.TEST_CONSTANT).
You should use Adobe Scout with enabled "Start sessions for ActionScript Workers" to see how it works:
image

Application example and native extension sample with sources attached.
worker_native_extension_class_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.system.Worker;
	import flash.system.WorkerDomain;
	import com.test.ane.TestANE;
	
	public class WorkerNativeExtensionBug extends Sprite {
		
		public function WorkerNativeExtensionBug() {
			if (Worker.current.isPrimordial) {
				trace(TestANE.TEST_CONSTANT);
				addEventListener(Event.ADDED_TO_STAGE, init);
			} else {
				trace(TestANE.TEST_CONSTANT);//This line cause Exception: ReferenceError
			}
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			var worker:Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes, true);
			worker.start();
		}
	}
}
package com.test.ane {
	import flash.display.Sprite;
	
	//Just a sample of native extension
	public class TestANE extends Sprite {
		public static const TEST_CONSTANT:uint = 1;
		
		public function TestANE() {
			
		}
	}
}

Actual Result:
In Worker session you will get ReferenceError exception.

Expected Result:
In Worker session you will see trace with constant value. You will see trace from it with Adobe Scout.

Known Workarounds

none

@itlancer
Copy link
Author

itlancer commented Mar 1, 2023

@ajwfrost
With latest 50.2.1.1 issue still exists. But in release notes it marked as solved.
With original sample I still get ReferenceError: Error #1065: Variable com.test.ane::TestANE is not defined.
With more comple applications it cause event application crash.

Note: For Animate I'm using "new" fdb.jar from here #399 (comment)

@ajwfrost
Copy link
Collaborator

ajwfrost commented Mar 3, 2023

Hi @itlancer - apologies, it looks like a change had been mis-flagged in our source control system as being associated with this one, when in fact it was nothing to do with it (some FBD changes, and I believe there are other open issues for that).

For this one itself, it's an interesting point: ANE definitions don't get compiled in to a SWF like a SWC file normally would, instead they're loaded in as part of the bootstrap code for the application. So the definition is in the root/primordial instance because of this bootstrap code; the Worker doesn't go through the same process so it doesn't have the definition...

In terms of getting the definitions from the SWC file (or library.swf, as this is pulled out of the SWC and put into the ANE) then this should be possible, by adding a simple bit of bootstrapping into the Worker start-up. So then I suspect it will be possible to use an ANE from a Worker, but the extension contexts would all be different between ANEs in different Workers so there may be some interesting side-effects...

thanks

@itlancer
Copy link
Author

Fixed with AIR 50.2.2.3+.
Thanks!

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

2 participants