deltaluca / nape

Haxe/AS3 Physics Engine
http://napephys.com
Other
542 stars 77 forks source link

Uncaught exception when running with OpenFL Neko #77

Open bartvanheukelom opened 10 years ago

bartvanheukelom commented 10 years ago

It appears something in Nape causes an error when running an OpenFL game with Neko.

Demo code:

class Main extends flash.display.Sprite {

 public function new () { 
 super();

 var tf = new flash.text.TextField();
 tf.text = "Hi There";
 addChild(tf);

 //var space = new nape.space.Space();
 }

}

This works fine. However, if you uncomment the var space line, the output is as follows:

$ openfl test neko
Uncaught exception - std@module_read

Am I doing something wrong or is this a Nape thing. If the latter, is it a bug or is Neko deliberately unsupported? Will it be fixed/added in the future? Thanks

deltaluca commented 10 years ago

I'd be tempted to log this to openfl instead... I cannot reproduce it in a non-openfl project with just neko + nape

class Main
{
    static function main() {
        var space = new nape.space.Space(nape.geom.Vec2.weak(0, 10));
        var b = new nape.phys.Body();
        b.shapes.add(new nape.shape.Circle(10));
        b.space = space;
        space.step(1/60);
        trace(b.position.y);
    }
}

haxe -x Main -lib nape

bartvanheukelom commented 10 years ago

As you can see I've reported the issue with OpenFL. I'll soon test your code to see if the error is gone then on my machine as well.

bartvanheukelom commented 10 years ago

Yes, your sample works here too.

gamedevsam commented 10 years ago

I get this error when trying to run with Neko target:

AL lib: (EE) alc_cleanup: 1 device not closed
Called from zpp_nape/callbacks/CbType.hx line 348
Called from nape/callbacks/CbType.hx line 179
Called from nape/callbacks/CbType.hx line 198
Called from zpp_nape/callbacks/CbType.hx line 174
Called from zpp_nape/callbacks/CbType.hx line 353
Called from zpp_nape/ID.hx line 186
Uncaught exception - Invalid operation (+)

I put these two defines in my project.xml:

<haxedef name="NAPE_RELEASE_BUILD" />
<haxedef name="NAPE_NO_INLINE" if="neko"/>
deltaluca commented 10 years ago

Could you reproduce that without using openfl and it's build tools? This seems to stem from the ID.hx file which is basicly just a bunch of 'static var X_ID = 0;' lines not ending up in the compiled code, and with the integers initialised to null (hence the invalid operationr + error).

gamedevsam commented 10 years ago

Well, here's a test project that initializes nape without openfl, it seems to work... but I need openfl and its build tools to make my games that use of Nape. So I'm still kinda sad, because Neko compiles much faster than cpp.

mrcdk commented 10 years ago

It might be a neko issue https://github.com/HaxeFoundation/neko/pull/14

R32 commented 10 years ago

It works. hehe..

<haxeflag name="-dce full" />

<!-- Optional -->
<haxedef name="NAPE_RELEASE_BUILD" />
haxe [3.1.3]
lime [0.9.7]
openfl-native [1.4.0]
nape [2.0.16]
galundin commented 10 years ago

As I mentioned in openfl/openfl#158, that flag doesn't resolve the issue for me, using all the same versions.

@deltaluca do you know why the static variables in ID.hx are included in the compiled code for all other targets, but not Neko? Can you think of why OpenFL would cause this to happen?

deltaluca commented 10 years ago

There's no point investigating any further unless you build the latest neko with the lifted opcode limit as that is the reason for this problem. (OpenFL + Nape triggers it by being so damn huge paired together)

MartinDelille commented 9 years ago

It doesn't work for me:

haxe [3.1.0]
lime [2.0.0]
open-fl [2.1.6]
nape [2.0.16]

I'm in the middle of a coding jam so I will do it with flash and loose all the neko debugging facility...

starburst997 commented 9 years ago

Just pointing out that I compile Neko from the GIT source and this does fix it for the example in the first post, however testing it on my game, the same error still occured.

Here my build of neko: http://test.failsafevault.com/files/neko-2.0.1-win.zip don't forget to replace the neko.dll in the bin folder

deltaluca commented 9 years ago

@starburst997, raise it with haxe/neko, if it's the exact same issue it may still be something on the lines of not having a large enough opcode size since presumably your game is more than a few lines of code ^^

starburst997 commented 9 years ago

Thanks, I'll try tweaking the values to allow more size