Strange behavior using JNI on native Android extension

Someone can help me in issue identification?
Is there a connection between row when hxcpp error appair and other lines nearby?

I/traceA  ( 5676): httpGetImages started
I/traceMIL( 5676): Total trance added: 9
I/traceMIL( 5676): startLoading numberOfExecutionSent: 0 url: http://redemption.game/image_repos/Actors/PannelloIconeV2.28x28-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 1 url: http://redemption.game/image_repos/Actors/BottoneRettangolareVVerdeDef-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 2 url: http://redemption.game/image_repos/Actors/MoveCardInCollectionButton93x23-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 3 url: http://redemption.game/image_repos/Actors/NukeWaiterLarge-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 4 url: http://redemption.game/image_repos/Actors/NukeWaiterLarge.1-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 5 url: http://redemption.game/image_repos/Actors/PannelloCalendarioPremi-Definitivo(1x)470x249-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 6 url: http://redemption.game/image_repos/Actors/HelpIcon.w23.h23-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 7 url: http://redemption.game/image_repos/Actors/Bastoncino.51x46.mk2-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 8 url: http://redemption.game/image_repos/Actors/Uncommon-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 9 url: http://redemption.game/image_repos/Actors/TV1.1600-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 10 url: http://redemption.game/image_repos/Actors/Premio_Credits_006-(1x)51x46-fs8.png
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceFMU( 5676): loadBase64ImageFromURL
I/traceFMU( 5676): loadBase64ImageFromURL
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceFMU( 5676): loadBase64ImageFromURL
I/traceFMU( 5676): loadBase64ImageFromURL
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceFMU( 5676): loadBase64ImageFromURL
I/traceMIL( 5676): startLoading numberOfExecutionSent: 11 url: http://redemption.game/image_repos/Actors/TendinaAlta480x720-fs8.png
I/traceMIL( 5676): startLoading numberOfExecutionSent: 12 url: http://redemption.game/image_repos/Actors/Defeated-fs8.png
E/HXCPP   ( 5676): Critical Error: Allocating from a GC-free thread
F/libc    ( 5676): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 5676 (s.redmption.tcg)
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceFMU( 5676): loadBase64ImageFromURL
I/traceLMI( 5676): Call Haxe Ok
I/traceLMI( 5676): doInBackground LoadImageFromURL started
I/traceFMU( 5676): loadBase64ImageFromURL
I/DEBUG   (  142): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

Code generating this log aiming to load images from web using asynctask to speed up process and using 120 thread under the 128 thread limit per asynctask.

Thanks in advance.
David.

Are you using Android native extrensions, or is this all Haxe code?

Sometimes things get strange when calling Haxe code from an Android native extension, but from the wrong thread

It’s a native extension and I’ve found cause of the issue and it’s very strange. If I’m going to call haxe back, using a callback function, without pass from AsyncTask, I’ve a crash.

Crashing java code:

public static void getAbsolutePath(String path, final HaxeObject callback) {
	ContextWrapper cw = new ContextWrapper(_context);
	File directory = cw.getDir(path, Context.MODE_PRIVATE);
	if (!directory.exists()) {
		directory.mkdir();
	}
	String ret = directory.getAbsolutePath();
	callback.call("folderAbsolutePath", new Object[] {ret});
}

Non crashing java code:

public static void getAbsolutePath(String path, final HaxeObject callback) {
	ContextWrapper cw = new ContextWrapper(_context);
	File directory = cw.getDir(path, Context.MODE_PRIVATE);
	if (!directory.exists()) {
		directory.mkdir();
	}
	String ret = directory.getAbsolutePath();
	ExchangeData exchangeData = new ExchangeData(callback, _context);
	exchangeData.setFunctionToCallback("folderAbsolutePath");
	exchangeData.setStringParameterToCallback(ret);
	new AsyncCallback().execute(exchangeData);
}

Where AsyncCallback is extends AsyncTask that simply call callback.call(“folderAbsolutePath”, new Object[] {ret}) stored in ExchageData Object.

Crash happens non immediately but when thread as finish the run and exit from callback function. The run can be really long if code fire events that triggers other functions and events. But when callback.call and childs are finished code crash. This not happen using AsyncTask.

Someone has an explanation for this behavoir? It’s really strange because any example I’ve found searching in the web never concerne about AsyncTask to callback Haxe code.

Thanks in advance.
David.

PS I’m going to change title of post, I think an explanation of this strange behavior can be more useful for the community than original post.