• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android physics_joint issues - CRASH in Android YYC

C

CruelBus

Guest
I'm not sure if this is a bug that I need to report, and I have not made a test project yet because my current project has MANY moving parts, literally, and it could very well be something I'm not doing "just right" within Box 2d.

So, we have a physics world, multiple fixtures, many sensors and complex physics objects. What do I mean by complex? Here is an example:

Process for the creation of a SHEEP:
A sheep instance is created.
In the create event of the sheep, a fixture (kept in a controller object) is bound to the sheep.
A "FALL CHECK" object instance is created, that binds a sensor fixture (kept in a controller object) to itself.
A revolute joint is created to attach the FALLCHK_OBJ to the SHEEP
Code:
FIXbound=physics_fixture_bind(FLOCK_MANAGER.PF_SHstd,id);
//=== make 5x5 sensor OBJ and attach to sheep
FALLCHK_OBJ=instance_create_depth(x,y,0,PF_COLL5sheep);
FALLCHK_OBJ.PARENT_ID=id;
FALL_PIVOT=physics_joint_revolute_create(self,FALLCHK_OBJ,x,y,0,0,true,0,0,false,false);
As far as I can tell, it must happen this way in order to check collisions on the fall sensor by itself.

In the step event:
Should the sheep catch on fire, a fire object is created, with an embedded fixture, and attached to the sheep with a pivot in the same way the FALLCHK_OBJ is:
Code:
if(ABLAZE){
    if(!HAS_FLAME){
        FLAMER=instance_create_depth(x,y+1,-(y+1),OBJ_FXfire1);
        FLpivot=physics_joint_revolute_create(self,FLAMER,x,y,0,0,true,0,0,false,false);
        HAS_FLAME=1;
    }
}
In GMS 1.4.9999, no crash occurred on any platform tested.
In GMS 2.3.1.409 ( I have not updated yet), the app will crash to the home screen with no message on Android. The crash does not occur in Windows VM.
NOTE: The crash to "desktop" in Android only occurs when exiting the room. The room is not persistent. The exit can be either via player death, level end, or "backspace." All will result in the crash which is a brief black screen, and then returns to the home screen of the Android device. I am fairly certain this is a Box 2d physics thing, maybe my doing, maybe not.

I was not deleting any revolute joints, since the documentation states that such joints are automatically deleted if either fixture they are bound to is deleted. The bound fixtures, as far as I know, are destroyed when the object is destroyed. All fixtures that reside in controller objects are destroyed in their cleanup events.

I narrowed the crash down to the joints themselves, as I began to replace the attach-by-joint method with rather cumbersome code inside each instance to perform the frame, scale and opacity of the flame sprite, then drawing the flame in the draw event of the object instead of a self-contained flame object.

Once I removed all such pivots, the crash no longer appears. I have the FALLCHK_OBJ follow it's "PARENT" (not a true parent-child relationship) around every frame. This now happens for every single object in its step event and I can't tell if it's better this way, processor time, or by using physics joints.

Is there anything ... extraordinary with the implementation of box 2d physics in GMS2 vs GMS 1.4?

ALSO: Do you think having a physics subforum would be useful here?

As always, thank you for your time.
 
Last edited by a moderator:

Nocturne

Friendly Tyrant
Forum Staff
Admin
First thing I'd do (and shouldn't take more than a couple of minutes to set up) is simply create a test project that has a couple of fixtures and a revolute joint then test it on Android using the YYC. If it breaks, it's a bug with the joint!

Also, one thing that GLARES at me from your code is the use of "self". Self should NEVER be used as a replacement for the ID of an instance. It is NOT the ID value, it is a special constant that "points" to the self instance/struct. If you must use self then it should be "self.id", but personally I'd just use the "id" variable. Using self as you are could potentially be the issue too, as it's not meant to be used this way at all.
 
C

CruelBus

Guest
@Nocturne , you can see I've bounced back and forth with self and id. Thank you. It'll be id from now on. Well, actually, you can't see that here. heh.

So I wonder if using "self" was creating the crash...
 
C

CruelBus

Guest
Replacing "self" with "id" in all locations still results in a crash. Making a test project now.
 
Top