googlearchive / tango-examples-java

Example projects for Project Tango [deprecated] Java API
https://developers.google.com/ar
503 stars 300 forks source link

onXyzIjAvailable() callback error #86

Closed leisipeisi closed 7 years ago

leisipeisi commented 7 years ago

Hi everyone,

I implemented an anonymous OnTangoUpdateListener() with the following code:

mPoseListener = new Tango.OnTangoUpdateListener() {
            @Override
            public void onPoseAvailable(TangoPoseData pose) {
                //do something
            }
            @Override
            public void onFrameAvailable(int cameraId) {
                //do something
            }
            @Override
            public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
                //do something
            }
            @Override
            public void onTangoEvent(TangoEvent event) {
                // do something
            }
            @Override
            public void onPointCloudAvailable(TangoPointCloudData tangoPointCloudData) {
                // do something
            }
        };

When I run the code, every time new data is avaiable, the callbacks are called. OnPoseAvaiable() is working perfectly fine, but when a new XYZIj is avaiable, the app crashes with the following error:

JNI ERROR (app bug): attempt to pass an instance of com.google.atap.tangoservice.TangoPointCloudData as argument 1 to void com.projecttango.examples.java.motiontracking.MainActivity$1.onXyzIjAvailable(com.google.atap.tangoservice.TangoXyzIjData)
11-24 10:16:18.813 28681-28697/com.projecttango.experiments.javamotiontracking A/art: art/runtime/check_jni.cc:64] JNI DETECTED ERROR IN APPLICATION: bad arguments passed to void com.projecttango.examples.java.motiontracking.MainActivity$1.onXyzIjAvailable(com.google.atap.tangoservice.TangoXyzIjData) (see above for details)
"Binder_1" prio=5 tid=12 Runnable
11-24 10:16:18.813 28681-28697/com.projecttango.experiments.javamotiontracking A/art: art/runtime/check_jni.cc:64]   | group="main" sCount=0 dsCount=0 obj=0x6486ae70 self=0x43f55008
11-24 10:16:18.813 28681-28697/com.projecttango.experiments.javamotiontracking A/art: art/runtime/check_jni.cc:64]   | sysTid=28697 nice=0 cgrp=apps sched=0/0 handle=0x471f8cb8
11-24 10:16:18.813 28681-28697/com.projecttango.experiments.javamotiontracking A/art: art/runtime/check_jni.cc:64]   | state=R schedstat=( 8498002 11716580 39 ) utm=0 stm=0 core=3 HZ=100
11-24 10:16:18.814 28681-28697/com.projecttango.experiments.javamotiontracking A/art: art/runtime/check_jni.cc:64]   | stack=0x47c0a000-0x47c0e000 stackSize=1016KB
11-24 10:16:18.814 28681-28697/com.projecttango.experiments.javamotiontracking A/art: art/runtime/check_jni.cc:64]   (no managed stack frames)

After this, numerous threads are aborted.

As far as a understand that message, the callback is called wrongly by the underlying service.

I got the code from here.

Does anybody encounter the same problem or has any suggestions on what to do to fix this?

Thanks in advance!

wirthual commented 7 years ago

Hi, someone had the same problem here: https://plus.google.com/113842118597149774006/posts/baveVMxvF8g

According to the answer you have to do the following:

Instead of just: config.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);

Now you need both:

config.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);

config.putInt(TangoConfig.KEY_INT_DEPTH_MODE, TangoConfig.TANGO_DEPTH_MODE_POINT_CLOUD);

This will resolve your issue.

leisipeisi commented 7 years ago

Thank you very much! This solution resolved my problem.