I’m trying to load a bitmap from a URL using the OpenFL display.Loader class, but on the Neko target on Linux, random crashes start happening after calling Loader.load. I have tried to isolate the issue to a minimal test app (it downloads and displays the OpenFL logo). I am using OpenFL 8.1.1 with Lime 6.3.1 on Linux (Ubuntu 16.04 64-bit) and Windows (Windows 7 32-bit). I’ve tested the cpp and neko targets on Linux and the neko target on Windows, and this issue appears only on the Linux Neko target.
package;
import openfl.display.Sprite;
import openfl.net.URLRequest;
import openfl.events.Event;
import openfl.events.IOErrorEvent;
import openfl.display.LoaderInfo;
import openfl.display.Loader;
import openfl.display.Bitmap;
class Main extends Sprite
{
private var loader:Loader;
public function new ()
{
super ();
loadURL();
}
private function loadURL()
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.load(new URLRequest("http://www.openfl.org/images/logo.png"));
}
private function onComplete(event:Event):Void
{
trace(onComplete, event);
var target:LoaderInfo = cast event.target;
var loader:Loader = cast target.loader;
var bitmap = new Bitmap(cast(loader.content, Bitmap).bitmapData.clone());
addChild(bitmap);
}
private function onIOError(event:IOErrorEvent):Void
{
trace("ioErrorHandler: " + event);
}
}
On Linux, the test app runs fine on CPP, but on Neko crashes randomly (6 times out of 20 runs in my tests). The crashes happen after Loader.load has been called, but in a semi-random fashion. Most commonly the program crashes simply with a segmentation fault, but sometimes there are stack traces. I’ve collected here examples of the errors shown by the test program:
Segmentation fault (core dumped)
Called from openfl.utils.Endian.Endian_Impl::$statics line 1
Called from ApplicationMain::main line 84
Called from ApplicationMain::create line 116
Called from lime.app.Application::exec line 269
Called from lime._backend.native.NativeApplication::exec line 160
Called from a C function
Called from lime._backend.native.NativeApplication::handleRenderEvent line 452
Called from lime.graphics.Renderer::render line 61
Uncaught exception - Invalid field access : render
Segmentation fault (core dumped)
Called from openfl.utils.Endian.Endian_Impl::$statics line 1
Called from ApplicationMain::main line 84
Called from ApplicationMain::create line 116
Called from lime.app.Application::exec line 269
Called from lime._backend.native.NativeApplication::exec line 160
Called from a C function
Called from lime._backend.native.NativeApplication::handleApplicationEvent line 201
Called from lime.app._Event_Int_Void::dispatch line 101
Called from lime.system.ThreadPool::__update line 219
Called from lime.app._Event_haxe_Function_Void::dispatch line 101
Called from lime._backend.native.NativeHTTPRequest::threadPool_onProgress line 558
Uncaught exception - Invalid call
Called from openfl.utils.Endian.Endian_Impl::$statics line 1
Called from ApplicationMain::main line 84
Called from ApplicationMain::create line 116
Called from lime.app.Application::exec line 269
Called from lime._backend.native.NativeApplication::exec line 160
Called from a C function
Called from lime._backend.native.NativeApplication::handleApplicationEvent line 201
Called from lime.app._Event_Int_Void::dispatch line 101
Called from openfl.display.Stage::update line 990
Uncaught exception - Invalid field access : __deltaTime
Called from openfl.utils.Endian.Endian_Impl::$statics line 1
Called from ApplicationMain::main line 84
Called from ApplicationMain::create line 116
Called from lime.app.Application::exec line 269
Called from lime._backend.native.NativeApplication::exec line 160
Called from a C function
Called from lime._backend.native.NativeApplication::handleWindowEvent line 653
Called from lime.app._Event_Void_Void::dispatch line 101
Called from openfl.display.Stage::addWindow line 352
Called from line 1
Uncaught exception - Reading Outside Env
It would appear to me that there is some difference in how Neko and CPP do URL requests, but this goes so deep into the target implementation that I have unfortunately no idea how to proceed from here. Any help would be appreciated!