Start a new topic

Android ArchitectView seg fault

Android ArchitectView seg fault


Hello,

We're having the following issue when trying to switch from the ArchitectView before it finishes loading all the POIs:

 

10-17 13:48:33.168: E/libEGL(3072): call to OpenGL ES API with no current context (logged once per thread)

10-17 13:48:33.536: D/CameraHal(1030): stopPreview

10-17 13:48:33.536: I/HPAndroidHAL(1030): APILOG: S1Up

10-17 13:48:33.536: D/CameraHal(1030): stop preview thread

10-17 13:48:33.543: D/dalvikvm(3072): GC_FOR_MALLOC freed 552 objects / 303304 bytes in 285ms

10-17 13:48:33.575: I/HPAndroidHAL(1030): APILOG: Disable Preview

10-17 13:48:33.582: D/CameraHal(1030): stopPreview

10-17 13:48:33.582: I/HPAndroidHAL(1030): APILOG: S1Up

10-17 13:48:33.582: D/CameraHal(1030): CameraHal release

10-17 13:48:33.582: D/CameraHal(1030): deinitPvOverlay()

10-17 13:48:33.582: I/HPAndroidHAL(1030): APILOG: DeinitializePreviewMemory

10-17 13:48:33.676: I/HPAndroidHAL(1030): Exiting thread OMAPHAL_Thread (ID: 0xdaae8)

10-17 13:48:33.684: D/TIOverlay(1289): overlay_destroyOverlay:IN dev (0x126cb8) and overlay (0x2d86e8)

10-17 13:48:33.684: I/TIOverlay(1289): Destroying overlay/fd=91/obj=002d86e8

10-17 13:48:33.684: D/TIOverlay(1289): overlay_destroyOverlay:OUT

10-17 13:48:33.692: I/HPAndroidHAL(1030): APILOG: ExitHPLibraries

10-17 13:48:33.692: I/HPAndroidHAL(1030): Exiting thread CaptureDirectorThread (ID: 0xd5730)

10-17 13:48:33.692: I/HPAndroidHAL(1030): APILOG: state machine shutting down...

10-17 13:48:33.692: I/HPAndroidHAL(1030): Exiting thread HALThread (ID: 0xd5328)

10-17 13:48:33.692: I/HPAndroidHAL(1030): Exiting thread AutoExposureThread (ID: 0xd5368)

10-17 13:48:33.692: I/HPAndroidHAL(1030): Exiting thread RenderingAnalysisModule (ID: 0xd53a8)

10-17 13:48:33.692: I/HPAndroidHAL(1030): Exiting thread BoxcarThread (ID: 0xd53e8)

10-17 13:48:33.692: I/HPAndroidHAL(1030): Exiting thread S2ProcessingThread (ID: 0xd5428)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread LensThread (ID: 0xd5468)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread FocusThread (ID: 0xd54a8)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread paxelMotionThread (ID: 0xd5500)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread CallbackThread (ID: 0xd5540)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread FlickerThread (ID: 0xd56a0)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread FaceDetectThread (ID: 0xd56f0)

10-17 13:48:33.700: I/HPAndroidHAL(1030): Exiting thread S2PostProcessingThread (ID: 0xd5770)

10-17 13:48:33.700: I/HPAndroidHAL(1030): APILOG: components shutting down...

10-17 13:48:33.700: I/HPAndroidHAL(1030): APILOG: all components uninitialized.

10-17 13:48:33.762: I/HPAndroidHAL(1030): APILOG: all components destroyed.

10-17 13:48:33.762: I/HPAndroidHAL(1030): APILOG: library shutdown complete.

10-17 13:48:33.762: D/CameraHal(1030): CameraHal destructor

10-17 13:48:33.762: D/CameraHal(1030): CameraHal release

10-17 13:48:33.762: D/CameraSettings(1030): CameraSettings destructor

10-17 13:48:33.832: D/dalvikvm(3072): GC_FOR_MALLOC freed 181 objects / 269720 bytes in 147ms

10-17 13:48:33.832: D/PVRShellView(3072): View will be destroyed. Engine dead

10-17 13:48:33.832: E/libEGL(3072): call to OpenGL ES API with no current context (logged once per thread)

10-17 13:48:33.840: D/ServiceManager(3072): stopping platform service with name: sensors

10-17 13:48:33.840: D/ServiceManager(3072): stopping platform service with name: camera

10-17 13:48:33.872: D/webviewglue(3072): nativeDestroy view: 0x127ca8

10-17 13:48:33.973: I/DEBUG(3068): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

10-17 13:48:33.973: I/DEBUG(3068): Build fingerprint: 'MOTO_RTEU/umts_sholes/umts_sholes/sholes:2.2.1/SHOLS_U2_05.26.3/296482885:user/release-keys'

10-17 13:48:33.973: I/DEBUG(3068): pid: 3072, tid: 3098  >>> com.skyhookwireless.apps.arinflight <<<

10-17 13:48:33.973: I/DEBUG(3068): signal 11 (SIGSEGV), fault addr 000000d4

10-17 13:48:33.973: I/DEBUG(3068):  r0 00000000  r1 0041e570  r2 00000000  r3 000000d4

10-17 13:48:33.973: I/DEBUG(3068):  r4 8140f1c8  r5 0041e570  r6 81216e81  r7 3f2aaaab

10-17 13:48:33.973: I/DEBUG(3068):  r8 002f0050  r9 00000001  10 a87ddb80  fp 484a2750

10-17 13:48:33.973: I/DEBUG(3068):  ip 00000000  sp 484a2250  lr 81136927  pc 81120828  cpsr 00000030

10-17 13:48:33.973: I/DEBUG(3068):  d0  643a64696f72646e  d1  6472656767756265

10-17 13:48:33.973: I/DEBUG(3068):  d2  8080808080808080  d3  8080808080808080

10-17 13:48:33.973: I/DEBUG(3068):  d4  8080808080808080  d5  8080808080808080

10-17 13:48:33.973: I/DEBUG(3068):  d6  8080808080808080  d7  8080808080808080

10-17 13:48:33.973: I/DEBUG(3068):  d8  0000000000000000  d9  0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d10 0000000000000000  d11 0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d12 0000000000000000  d13 0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d14 0000000000000000  d15 0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d16 436cfd9445994148  d17 0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d18 0000000000000000  d19 0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d20 3ff0000000000000  d21 8000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d22 0000000000000000  d23 bda8fae9be8838d4

10-17 13:48:33.973: I/DEBUG(3068):  d24 40dd4c2013880000  d25 40ed4c1013880000

10-17 13:48:33.973: I/DEBUG(3068):  d26 40cd4c4013880000  d27 0000000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d28 0000000000000000  d29 3ff0000000000000

10-17 13:48:33.973: I/DEBUG(3068):  d30 0000000000000000  d31 3ff0000000000000

10-17 13:48:33.973: I/DEBUG(3068):  scr 60000013

10-17 13:48:34.168: I/DEBUG(3068):          #00  pc 00120828  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):          #01  pc 00136922  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):          #02  pc 0013398a  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):          #03  pc 0014a40e  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):          #04  pc 00216b16  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):          #05  pc 00016e74  /system/lib/libdvm.so

10-17 13:48:34.168: I/DEBUG(3068): code around pc:

10-17 13:48:34.168: I/DEBUG(3068): 81120808 9b019a02 1c111c08 f0521c1a b005fe95 

10-17 13:48:34.168: I/DEBUG(3068): 81120818 46c0bd00 b088b510 91029003 23d49a03 

10-17 13:48:34.168: I/DEBUG(3068): 81120828 9a0258d3 1c191c10 f8aef7fe 23d49a03 

10-17 13:48:34.168: I/DEBUG(3068): 81120838 1c5958d3 23d49a03 9b0350d1 9b021d1c 

10-17 13:48:34.168: I/DEBUG(3068): 81120848 f7e81c18 1c02faf7 9b02a906 1c111c08 

10-17 13:48:34.168: I/DEBUG(3068): code around lr:

10-17 13:48:34.168: I/DEBUG(3068): 81136904 001742fa 00174302 001742de b084b510 

10-17 13:48:34.168: I/DEBUG(3068): 81136914 91009001 685a9b01 1c109b00 f7e91c19 

10-17 13:48:34.168: I/DEBUG(3068): 81136924 9b01ff7b 34201c1c 1c189b00 fa84f7d2 

10-17 13:48:34.168: I/DEBUG(3068): 81136934 93031c03 1c20ab03 f0001c19 1c03fcdb 

10-17 13:48:34.168: I/DEBUG(3068): 81136944 601a9a00 1c189b00 fa76f7d2 1c181c03 

10-17 13:48:34.168: I/DEBUG(3068): stack:

10-17 13:48:34.168: I/DEBUG(3068):     484a2210  484a24c5  

10-17 13:48:34.168: I/DEBUG(3068):     484a2214  0041e5e8  

10-17 13:48:34.168: I/DEBUG(3068):     484a2218  01012274  

10-17 13:48:34.168: I/DEBUG(3068):     484a221c  8110b557  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):     484a2220  484a224c  

10-17 13:48:34.168: I/DEBUG(3068):     484a2224  0041e570  

10-17 13:48:34.168: I/DEBUG(3068):     484a2228  484a24bc  

10-17 13:48:34.168: I/DEBUG(3068):     484a222c  811332cd  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):     484a2230  40386823  

10-17 13:48:34.168: I/DEBUG(3068):     484a2234  0041e570  

10-17 13:48:34.168: I/DEBUG(3068):     484a2238  0000000b  

10-17 13:48:34.168: I/DEBUG(3068):     484a223c  811496d3  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):     484a2240  3f2aaaab  

10-17 13:48:34.168: I/DEBUG(3068):     484a2244  0041e570  

10-17 13:48:34.168: I/DEBUG(3068):     484a2248  df002777  

10-17 13:48:34.168: I/DEBUG(3068):     484a224c  e3a070ad  

10-17 13:48:34.168: I/DEBUG(3068): #00 484a2250  8140f1c8  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):     484a2254  81149085  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):     484a2258  0041e570  

10-17 13:48:34.168: I/DEBUG(3068):     484a225c  00000000  

10-17 13:48:34.168: I/DEBUG(3068):     484a2260  00000012  

10-17 13:48:34.168: I/DEBUG(3068):     484a2264  3f800000  

10-17 13:48:34.168: I/DEBUG(3068):     484a2268  00000000  

10-17 13:48:34.168: I/DEBUG(3068):     484a226c  3f800000  

10-17 13:48:34.168: I/DEBUG(3068):     484a2270  8140f1c8  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068):     484a2274  81136927  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.168: I/DEBUG(3068): #01 484a2278  0041e570  

10-17 13:48:34.168: I/DEBUG(3068):     484a227c  00439068  

10-17 13:48:34.168: I/DEBUG(3068):     484a2280  0000000b  

10-17 13:48:34.168: I/DEBUG(3068):     484a2284  8140f1c8  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.192: I/DEBUG(3068):     484a2288  8140f1c8  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.192: I/DEBUG(3068):     484a228c  8113398f  /data/data/com.skyhookwireless.apps.arinflight/libarchitect.so (deleted)

10-17 13:48:34.348: D/dalvikvm(3072): GC_FOR_MALLOC freed 3721 objects / 209248 bytes in 242ms

10-17 13:48:34.348: D/PVRShellView(3072): Stop rendering

 

After this application closes immediately. Everything works fine if the POIs finish loading by the time we decide to switch from the view however.

This happens on all of the devices we use for testing including Milestone with Froyo and Nexus S with JB. We are using Wikitude SDK 1.1.

This doesn't seem to reproduce with Wikitude application itself, probably because ArchitectView has its own activity there. In our case we're using a number of views (one of which is AR view) in the same activity. By "switching from"  I mean calling onPause and onDestroy for AR view and setting the content view to another view.

Is there a way to switch between AR view and other view in the same activity without having to destroy and recreate the AR view every time btw? I've tried some but none of it worked.

Hi there!

Please use Fragments to switch between views in same Activity.
They are supported for SDK 11+.
I recommend you to use the custom compatibility pack which allows you to use MapViews inside Fragments too.
You can then use transactions to change views on the fly.
Since MapView and Cam consume quite a lot memory I recommend you not to have both views/fragments in memory but restore fragment instead.

Find more details about the compatibility pack at Android Developer Website.
Yepp, it's a bit more to read through, but you then know you are using latest technology and can even use latest titlebar across all version using the ActionBar.

Hope that helps.
Kind regards,
Andi

Hi Andreas,

Thanks for the hint. We'll try that out and get back to you with the results.

 

Hi again,

I'm trying out the Fragments with our app atm. It looks like the seg fault doesn't happen with them but I can't switch to AR view now (switching from it and between other views works fine). I'm using the dynamic fragments.

If I start with, say, list view and then replace it with the AR view I get this:

10-25 14:47:57.942: E/AndroidRuntime(5179): FATAL EXCEPTION: GLThread 62

10-25 14:47:57.942: E/AndroidRuntime(5179): java.lang.RuntimeException: Failed to initialise PVRShell

10-25 14:47:57.942: E/AndroidRuntime(5179):  at com.wikitude.architect.PVRShell.initialise(Unknown Source)

10-25 14:47:57.942: E/AndroidRuntime(5179):  at com.wikitude.architect.PVRShellView$OurContextFactory.createContext(Unknown Source)

10-25 14:47:57.942: E/AndroidRuntime(5179):  at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:922)

10-25 14:47:57.942: E/AndroidRuntime(5179):  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1246)

10-25 14:47:57.942: E/AndroidRuntime(5179):  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)

 

I get the same if I start with AR view, then switch to list, then to AR again having ArchitectView.onDestroy() call in onDestroy() fragment method.

If I comment it out I get an empty cam view in the end of this scenario (I expect to see at least a radar). This basically looks the same to problems I had with switching to AR view using setContentView() before coming up with a solution to always destroy it when switching from and recreate from scratch when switching to it.

 

So the question is... what am I doing wrong? :) 

It would be nice to have a snippet for AR view with switching fragments.

 

 

 

Ok, I've made some progress here actually. I can switch from/to AR view using the Fragments API now... well, with some strings attached.

I had to make the following changes to achieve the desired behavior:

* Inflate AR layout only the first time and return the cached AR view on the subsequent calls to the onCreateView

* Remove AR view from it's parent view in onDetach

* don't destroy AR view in fragment onDestroy(), add a specific method that is called when activity gets destoyed

* move the AR onPostCreate and load the world code to happen right after AR onCreate in onCreateView (this way I can start with another view and then switch to AR as well as start with AR view and switch to another one)

However, this only works currently for Nexus S with JB 4.1.2 or Galaxy Nexus with JB 4.1.1 and doesn't for Milestone with Froyo 2.2.1 or i9000 with Gingerbread 2.3.5. So I suspect that it only works for android-11+ devices (there is a delay begore radar and the objects get visible however). On the older devices I get an empty cam view after switching back to AR view and it never updates even after I see my app communicates (calls the js method) with AR in logs.

I can also reproduce the seg fault using the Fragments API on JB Nexus S if I put the AR onDestroy call in fragment onDetach method and try to replace the AR view while it's still loading the objects.

Now to the funny part - I've reverted to use the setContentView instead of fragment transactions and managed to get rid of seg fault by cutting out the AR onDestroy during switching from it (I still call it when the app is destroyed) and use the cached AR view in setContentView. This works fine on JB Nexus S and JB Galaxy Nexus but I still get an empty cam view after going back to AR on older devices. So it looks like this behavior is the same regardless of using fragments and the real issue is that AR onDestroy should not be called while removing it from scene while some activity is happening there.

And I'm a bit stuck here :( 

I have a version that is working across all devices but has a seg fault and I have a seg fault free version which doesn't work on older devices.

Please advice.

Hello!

Can you tell me more about your project setup, especially are you using a ViewPager to switch between your fragments? If that's the case you could prevent that the ArchitectView is destroyed when you switch between Fragments, by overriding the destroyItem-method of the FragmentPagerAdapter class, as can be seen in this example: 

http://stackoverflow.com/questions/7951730/viewpager-and-fragments-whats-the-right-way-to-store-fragments-state

Hope that helps,

Markus

Hello Markus,

I'm not using the ViewPager, should I? Also, I've already mentioned above that I can overcome the seg fault issue with onDestroy but then the solution doesn't work with 2.2, 2.3 devices (empty cam view).

General project setup is as follows:

- min sdk is android-8

- main activity with 3 switching views/fragments (AR, list, map) which are updated with live data

- data service class (not a service) fetching data in a background thread

- other minor activities launched from the main one

Application tracks the current location and provides a feedback in form of relevant POIs displayed in form of AR markers / List entries / Map pushpins).

Relevant code for AR view (for the version using fragments):

 

public abstract class PoiView

    extends Fragment

{

...

}

 


public class ARPoiView

    extends PoiView

    implements ArchitectUrlListener

{

    public ARPoiView()

    {

        super("Augmented Reality");

    }

 

    @Override

    public void onDetach()

    {

        super.onDetach();

        ((ViewGroup)_architectView.getParent()).removeView(_architectView);

    }

 

    public View onCreateView(final LayoutInflater inflater,

                             final ViewGroup container,

                             final Bundle savedInstanceState)

    {

        _logger.debug("onCreateView");

        if (_architectView != null)

            return _architectView;

 

        final View view = inflater.inflate(R.layout.poi_ar, container, false);

 

        _architectView = (ArchitectView) view.findViewById(R.id.architectView);

        // onCreate method for setting the license key for the SDK

        if (_architectView != null)

            _architectView.onCreate(LICENSE_KEY);

 

        doPostCreate();

 

        return view;

    }

 

    @Override

    public void onPostCreate()

    {

        _logger.debug("onPostCreate");

//        doPostCreate();

    }

 

    private void doPostCreate()

    {

        _logger.debug("doPostCreate");

        if (_architectView == null)

            return;

 

        // IMPORTANT: creates ARchitect core modules

        _architectView.onPostCreate();

 

        // register as handler of "architectsdk://" urls

        _architectView.registerUrlListener(this);

 

        try

        {

            _architectView.load("world.html");

        }

        catch (final IOException e)

        {

            _logger.error("failed to load AR world", e);

        }

    }

 

    @Override

    public void onLowMemory()

    {

        if (_architectView != null)

            _architectView.onLowMemory();

    }

 

    @Override

    public void onPause()

    {

        _logger.debug("onPause");

        super.onPause();

 

        if (_architectView != null)

            _architectView.onPause();

    }

 

    @Override

    public void onResume()

    {

        _logger.debug("onResume");

        super.onResume();

 

        if (_architectView != null)

            _architectView.onResume();

    }

 

    @Override

    public void onDestroy()

    {

        _logger.debug("onDestroy");

        super.onDestroy();

 

//        if (_architectView != null)

//            _architectView.onDestroy();

    }

 

    @Override

    public void onDestroyActivity()

    {

        super.onDestroyActivity();

 

        if (_architectView != null)

            _architectView.onDestroy();

    }

...

}

Hello!

We've tested the usage of the ArchitectView in Fragments mostly using ViewPager and FragmentPagerAadapter, so maybe you wanna try out that way as well. The problem on 2.2 and 2.3 devices you mentioned is related to the Android Webkit implemententation on those devices. The ArchitectView is currently optimized for usage in activities and therefore this problem doesn't exist in those scenarios. We are working on a solution for that problem for your scenario and will include it in the upcoming release of our SDK.

Hope that helps,

Markus

Hello Markus,

Unfortunately ViewPager didn't work out for us. We have a requirement to have 2 map views available in application and it's not possible with ViewPager concept. Also it only works for old devices if we use FragmentStatePagerAdapter with destroyItem() overriden to skip destroying the item which probably keeps all the views in memory and Andreas already mentioned this as a bad practice.

We have switched to use the separate activities for our views and the problem doesn't seem to reproduce any more.

Thanks for your hints.
Login or Signup to post a comment