starling icon indicating copy to clipboard operation
starling copied to clipboard

Hashlink Target - Runtime Crashes Fail on Demo

Open benjamin-stern opened this issue 4 years ago • 2 comments

When trying to compile the application to the Hashlink Target as soon as the application starts it crashes.

On applications where starling is loaded in delay, the Hashlink Target operates and crashes as soon as it loads up starling.

benjamin-stern avatar Mar 04 '20 22:03 benjamin-stern

I've run into this as well. It seems to be failing to convert the string parameters to the proper enum types when using Reflection to make the function call to stage3D.requestContext3D (line 253 of RenderUtil.hx)

hunkydoryrepair avatar May 06 '20 08:05 hunkydoryrepair

specifically, we have on line 253:

executeFunc(stage3D.requestContext3D, [renderMode, currentProfile]);

On most platforms, this is expanded to : stage3D.requestContext3D(renderMode, currentProfile)

renderMode and currentProfile are strings, and the stage3D.requestContext3D method takes Int based Enums. Those enums have @:from converters to convert from string to int,

but for js and HashLink this becomes: Reflect.callMethod(stage3D.requestContext3D, [renderMode, currentProfile])

Now, stage3D.requestContext3D doesn't appear to use either of the parameters, but passing a String to an Int parameter in HashLink causes an error, enforcing the correct type is passed. The compiler knows, based on the enum, how to convert, but at runtime the function data only understand the parameter should be an Int, so it cannot convert from a string.

While the parameters don't seem to be used, one possible fix is simply:

executeFunc(stage3D.requestContext3D, [0, 0])

but a better fix is probably to convert the parameters before calling. cast doesn't work so best I can think of is:

 var rm:Context3DRenderMode = renderMode;
 var p:Context3DProfile = currentProfile;
 executeFunc(stage3D.requestContext3D, [rm, p])

hunkydoryrepair avatar May 09 '20 21:05 hunkydoryrepair