マイゲームがクラッシュした上で時折クラッシュをBOX2D:libgdxは、このメッセージにcreateBody
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000066bcbd0d, pid=13948, tid=12700
# [...]
#
# Problematic frame:
# C [gdx-box2d64.dll+0xbd0d]
ログファイルから:
全ログ:同様のクラッシュと他のすべての記事からhttp://pastebin.com/QjY3msYS
起こるべきではないときにはおそらく世界的な改変であろう。食品のコンストラクタで
// generateFood() - called during World.update
for (int i = 0; i < count; i++) {
float x = minX + (float) Math.random() * (maxX - minX);
float y = minY + (float) Math.random() * (maxY - minY);
Gdx.app.debug("World", "Generating food piece "+i);
this.foods.add(new Food(this, x, y, animateGrowth, this.renderable));
}
: クラッシュが新しい食品オブジェクトの作成中に発生し
// in Food(...) constructor
BodyDef bodyDef = new BodyDef(); //TODO: set to sleep on init?
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(x, y);
bodyDef.linearDamping = 0.5f;
bodyDef.angularDamping = 1f;
Gdx.app.debug("Food", "Init body with " + bodyDef + " at " + x + "," + y);
foodBody = world.box2dWorld.createBody(bodyDef); // <== HERE IS WHERE THE CRASH HAPPENS
CircleShape shape = new CircleShape();
shape.setRadius(getSizeFromEnergy());
fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = 0.5f;
fixtureDef.friction = 0.4f;
fixtureDef.restitution = 0.2f;
fixture = foodBody.createFixture(fixtureDef);
fixture.setUserData(this);
shape.dispose();
しかしgenerateFoodコードが正常に実行されたときにのみ、(時々、ゲームプレイの分後に、時折起こります何百回も)。だから私は、クラッシュは食べ物の世代の前に世界と何が起こるかとは関係があると考えました。
public void update() { // Cell.update - called during World.update
if (this.energy <= 0) {
world.cells.remove(this);
Vector2 pos = cellBody.getPosition();
Gdx.app.debug("Cell", "Destroying " + cellBody+" at "+pos.x+","+pos.y);
world.box2dWorld.destroyBody(cellBody); // -> Without this line, the crashes don't happen!
return;
}
}
ここでは、ログです:
World: Generating food piece 99
Food: Init body with [email protected] at -28.201607,-56.101532
World: Removing cell: [email protected]
Cell: Destroying [email protected] at -51.92446,-56.464954
World: Removing cell: [email protected]
Cell: Destroying [email protected] at -51.92446,-56.464954
World: Generating 100 new food pieces
World: Generating food piece 0
Food: Init body with [email protected] at 14.653984,96.249084
[...]
World: Generating food piece 21
Food: Init body with [email protected] at -15.35305,13.934067
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000066bcbd0d, pid=9792, tid=13288
#