I'm building a PvP Android shooter game utilizing NodeJS for my server. Everything until the bullet updates has been working great. I've spent days trying to debug unsuccessfully.
My problem is that after one of the player shoots anywhere from 1 to >30 bullets, the other phone crashes.
Here is my tombstone log:
06-03 23:39:15.720 9710-9710/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-03 23:39:15.720 9710-9710/? A/DEBUG: Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:7.1.1/NYC/3756122:userdebug/test-keys'
06-03 23:39:15.720 9710-9710/? A/DEBUG: Revision: '0'
06-03 23:39:15.720 9710-9710/? A/DEBUG: ABI: 'x86'
06-03 23:39:15.720 9710-9710/? A/DEBUG: pid: 9026, tid: 9709, name: EventThread >>> com.mygdx.game <<<
06-03 23:39:15.720 9710-9710/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x58
06-03 23:39:15.720 9710-9710/? A/DEBUG: eax 00000000 ebx 9347c980 ecx 92467590 edx 924675d0
06-03 23:39:15.721 9710-9710/? A/DEBUG: esi aa0ea968 edi 92467808
06-03 23:39:15.721 9710-9710/? A/DEBUG: xcs 00000073 xds 0000007b xes 0000007b xfs 0000003b xss 0000007b
06-03 23:39:15.721 9710-9710/? A/DEBUG: eip 93454bdb ebp 92467578 esp 92467540 flags 00010292
06-03 23:39:15.726 9710-9710/? A/DEBUG: backtrace:
06-03 23:39:15.726 9710-9710/? A/DEBUG: #00 pc 0001cbdb /data/app/com.mygdx.game-2/lib/x86/libgdx-box2d.so (_ZN6b2Body13CreateFixtureEPK12b2FixtureDef+27)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #01 pc 00034f36 /data/app/com.mygdx.game-2/lib/x86/libgdx-box2d.so (Java_com_badlogic_gdx_physics_box2d_Body_jniCreateFixture__JJFFFZSSS+134)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #02 pc 0010f2d7 /system/lib/libart.so (art_quick_generic_jni_trampoline+71)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #03 pc 00109262 /system/lib/libart.so (art_quick_invoke_stub+338)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #04 pc 00112d9d /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+237)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #05 pc 0031d596 /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+294)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #06 pc 00316630 /system/lib/libart.so (_ZN3art11interpreter6DoCallILb1ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+480)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #07 pc 0067e3bd /system/lib/libart.so (MterpInvokeDirectRange+461)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #08 pc 000fb921 /system/lib/libart.so (artMterpAsmInstructionStart+15137)
06-03 23:39:15.726 9710-9710/? A/DEBUG: #09 pc 002e5e98 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #10 pc 002ed6e0 /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+192)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #11 pc 0031541b /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+587)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #12 pc 0067a93e /system/lib/libart.so (MterpInvokeVirtual+718)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #13 pc 000fb521 /system/lib/libart.so (artMterpAsmInstructionStart+14113)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #14 pc 002e5e98 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #15 pc 002ed6e0 /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+192)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #16 pc 0031541b /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+587)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #17 pc 0067c110 /system/lib/libart.so (MterpInvokeDirect+464)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #18 pc 000fb621 /system/lib/libart.so (artMterpAsmInstructionStart+14369)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #19 pc 002e5e98 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #20 pc 002ed5f0 /system/lib/libart.so (_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameE+176)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #21 pc 0066cf79 /system/lib/libart.so (artQuickToInterpreterBridge+1049)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #22 pc 0010f39d /system/lib/libart.so (art_quick_to_interpreter_bridge+77)
06-03 23:39:15.727 9710-9710/? A/DEBUG: #23 pc 00006bb1 /dev/ashmem/dalvik-jit-code-cache (deleted)
My code structure is essentially:
On the client side, I have a method in the render() loop that sends velocity of bullets and "shootOption" (basically position) to server.
public void updateBulletPosOnOppScreen(float dt) {
JSONObject data = new JSONObject();
timerB+=dt;
if(timerB > updateTimeB && player1.hasShot) {
try{
if(!player1.bulletList.isEmpty()) {
Bullet bullet = player1.bulletList.get(player1.bulletList.size()-1);
data.put("vx", bullet.getVx());
data.put("vy", bullet.getVy());
data.put("shootOption", bullet.getShootOption());
socket.emit("playerShot", data);
}
} catch (JSONException e) {
e.printStackTrace();
}
player1.hasShot = false;
timerB = 0;
}
}
Afterwards, the server side emits the data to the client:
socket.on('playerShot', function(data) {
data.id = socket.id;
socket.broadcast.emit('playerShot', data);
});
And finally, the client takes in the data and creates a bullet/adds the bullet to the opposing player's bullet list:
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
Gdx.app.log("SocketIO", "Connected");
}
}).on("playerShot", new Emitter.Listener() {
@Override
public void call(Object... args) {
JSONObject data = (JSONObject) args[0];
try {
String id = data.getString("id");
double vx = data.getDouble("vx");
double vy = data.getDouble("vy");
int shootOption = data.getInt("shootOption");
Bullet newBullet = new Bullet(shootOption, oppPlayers.get(id).getPlayerSprite(), world);
newBullet.setBulletSprite(bulletSprite, oppPlayers.get(id).getPlayerSprite());
newBullet.setVx((float)vx); newBullet.setVy((float)vy);
oppPlayers.get(id).bulletList.add(newBullet);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
To update the bullets and to display them, I basically loop through the opposing player's bullet list in the render() loop.
My bullets shoot flawlessly if I'm not implementing the server, and they are also disposed of flawlessly. Tracking movement for the opposing player across the server also works, albeit with a bit of lag. Right now, my server is only using my local wifi network. I'm testing on a Nexus 5 emulator and a Motorola Moto G3, although I've tried using different emulators across different Android versions, and the crashes are consistent. I'm not sure if it's a memory problem or a server problem or something else, but I'm extremely frustrated.
Any takers?
via Kane
No comments:
Post a Comment