libgdx native crash jni_create_fixture()

时间:2017-05-24 11:51:38

标签: android libgdx box2d

我使用libgdx和box2d来模拟物理世界。但是我的应用程序很可能在启动时崩溃,而日志如下。我通常只使用box2d的api。请帮忙

--------- beginning of crash
05-24 07:13:25.755 F/libc    (19459): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x58 in tid 19459 (lex.com.gdxdemo)
05-24 07:13:25.756 W/        (  255): debuggerd: handling request: pid=19459 uid=10087 gid=10087 tid=19459
05-24 07:13:25.823 F/DEBUG   (19496): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-24 07:13:25.823 F/DEBUG   (19496): Build fingerprint: 'android/aosp_shamu/shamu:7.1.2/N2G47O/ajdink05211137:userdebug/release-keys'
05-24 07:13:25.823 F/DEBUG   (19496): Revision: '0'
05-24 07:13:25.823 F/DEBUG   (19496): ABI: 'arm'
05-24 07:13:25.823 F/DEBUG   (19496): pid: 19459, tid: 19459, name: lex.com.gdxdemo  >>> alex.com.gdxdemo <<<
05-24 07:13:25.823 F/DEBUG   (19496): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x58
05-24 07:13:25.823 F/DEBUG   (19496):     r0 00000000  r1 beac7490  r2 00000000  r3 00000000
05-24 07:13:25.823 F/DEBUG   (19496):     r4 00000000  r5 beac78a8  r6 beac7620  r7 beac75e0
05-24 07:13:25.823 F/DEBUG   (19496):     r8 000091d4  r9 b4285400  sl beac7500  fp beac7488
05-24 07:13:25.823 F/DEBUG   (19496):     ip 9aa6ba60  sp beac7470  lr 9aa61f2c  pc 9aa4fe20  cpsr 60070010
05-24 07:13:25.857 F/DEBUG   (19496): 
05-24 07:13:25.857 F/DEBUG   (19496): backtrace:
05-24 07:13:25.857 F/DEBUG   (19496):     #00 pc 0001ae20  /data/app/alex.com.gdxdemo-2/lib/arm/libgdx-box2d.so (_ZN6b2Body13CreateFixtureEPK12b2FixtureDef+16)
05-24 07:13:25.857 F/DEBUG   (19496):     #01 pc 0002cf28  /data/app/alex.com.gdxdemo-2/lib/arm/libgdx-box2d.so (Java_com_badlogic_gdx_physics_box2d_Body_jniCreateFixture__JJFFFZSSS+116)
05-24 07:13:25.857 F/DEBUG   (19496):     #02 pc 000af999  /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
05-24 07:13:25.857 F/DEBUG   (19496):     #03 pc 000aafc1  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
05-24 07:13:25.857 F/DEBUG   (19496):     #04 pc 00407d09  /system/lib/libart.so (art_quick_invoke_stub+232)
05-24 07:13:25.857 F/DEBUG   (19496):     #05 pc 000b2271  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+136)
05-24 07:13:25.858 F/DEBUG   (19496):     #06 pc 001ef52b  /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+198)
05-24 07:13:25.858 F/DEBUG   (19496):     #07 pc 001ea8bb  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb1ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+334)
05-24 07:13:25.858 F/DEBUG   (19496):     #08 pc 00401ba3  /system/lib/libart.so (MterpInvokeDirectRange+262)
05-24 07:13:25.858 F/DEBUG   (19496):     #09 pc 0009e214  /system/lib/libart.so (ExecuteMterpImpl+15252)
05-24 07:13:25.858 F/DEBUG   (19496):     #10 pc 001ccd3f  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
05-24 07:13:25.858 F/DEBUG   (19496):     #11 pc 001d189f  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
05-24 07:13:25.858 F/DEBUG   (19496):     #12 pc 001e9ad7  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+450)
05-24 07:13:25.858 F/DEBUG   (19496):     #13 pc 003ff72f  /system/lib/libart.so (MterpInvokeVirtual+422)
05-24 07:13:25.858 F/DEBUG   (19496):     #14 pc 0009de14  /system/lib/libart.so (ExecuteMterpImpl+14228)
05-24 07:13:25.858 F/DEBUG   (19496):     #15 pc 001ccd3f  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
05-24 07:13:25.859 F/DEBUG   (19496):     #16 pc 001d189f  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
05-24 07:13:25.859 F/DEBUG   (19496):     #17 pc 001e9ad7  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+450)
05-24 07:13:25.859 F/DEBUG   (19496):     #18 pc 003ff72f  /system/lib/libart.so (MterpInvokeVirtual+422)
05-24 07:13:25.859 F/DEBUG   (19496):     #19 pc 0009de14  /system/lib/libart.so (ExecuteMterpImpl+14228)
05-24 07:13:25.859 F/DEBUG   (19496):     #20 pc 001ccd3f  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
05-24 07:13:25.859 F/DEBUG   (19496):     #21 pc 001d1809  /system/lib/libart.so (_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameE+92)
05-24 07:13:25.859 F/DEBUG   (19496):     #22 pc 003f71f1  /system/lib/libart.so (artQuickToInterpreterBridge+716)
05-24 07:13:25.859 F/DEBUG   (19496):     #23 pc 000afa13  /system/lib/libart.so (art_quick_to_interpreter_bridge+34)
05-24 07:13:25.859 F/DEBUG   (19496):     #24 pc 745425f7  /data/dalvik-cache/arm/system@framework@boot.oat (offset 0x2821000)
05-24 07:13:26.264 W/        (  255): debuggerd: resuming target 19459
05-24 07:13:26.266 I/BootReceiver( 1325): Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE)
05-24 07:13:26.279 W/ActivityManager( 1325):   Force finishing activity alex.com.gdxdemo/.Box2dActivity
05-24 07:13:26.288 W/ContextImpl( 1325): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:877 com.android.server.am.AppErrors.crashApplicationInner:375 com.android.server.am.AppErrors.crashApplication:309 com.android.server.am.ActivityManagerService$19.run:13615 java.lang.Thread.run:761 

它显示本机方法崩溃

`_ZN6b2Body13CreateFixtureEPK12b2FixtureDef`

`Java_com_badlogic_gdx_physics_box2d_Body_jniCreateFixture__JJFFFZSSS`

我的碰撞夹具代码

    FixtureDef fd = new FixtureDef();
    fd.shape = shape;
    fd.density = 1.5f;
    fd.friction = 0.3f;
    fd.restitution = 0.5f; // Make it bounce a little bit
    starBody.createFixture(fd);

任何人都知道为什么?

1 个答案:

答案 0 :(得分:1)

正在锁定世界的上下文中调用正文的create-fixture方法。这是基于Box2D 2.3.2 C ++源代码的猜测b2Assert(m_world->IsLocked() == false);的断言陈述。

例如,如果你从碰撞回调中调用create fixture方法,那么你就会遇到这个问题。在未在世界步骤方法中运行时,可以调用创建夹具。