Application restarting after certain set up circumstances

I have an application that takes a picture using the device’s camera, and then saves that photo as a .jpg. I have found that on the android devices on which I have tested (Nexus 7, Galaxy S4, Galaxy Note 3) the application is restarting when I return from the camera application after having taken a picture, after 7 or more calls to the camera application. It doesn’t matter whether or not I have taken a picture or not those previous 7 times. The first time I return to my application from the camera with a photo after those previous 7 or more media.camera() calls, the application restarts. This does not happen if I have not taken a photo. For clarification, I have provided an example:

  1. go to camera, take a photo/don’t take a photo, return to application

  2. go to camera, take a photo/don’t take a photo, return to application

3. go to camera, take a photo/don’t take a photo, return to application

4. go to camera, take a photo/don’t take a photo, return to application

5. go to camera, take a photo/don’t take a photo, return to application

6. go to camera, take a photo/don’t take a photo, return to application

7. go to camera, take a photo/don’t take a photo, return to application

On the eighth try, if I take a photo and return to the application, the application restarts. If I do not take a photo, the application does not restart, and I can continue using it. However, any subsequent calls to the camera where I take a photo and return to the application will cause the application to restart. 

Unfortunately, I do not posses the knowledge/experience to diagnose this problem by scrutinizing the console log. I have provided the section of output from the console log where I believe the problem is happening below (this is using a Nexus 7):

E/mm-camera(  211): [dbgHang] - UnMap buffer >>>>> enter

E/mm-camera(  211): [dbgHang] - UnMap buffer >>>>> exit with status: 1

E/mm-camera(  211): mct_pipeline_get_stream: no children

E/mm-camera(  211): mct_pipeline_process_set:1351: Couldn’t find stream

E/mm-camera-sensor(  211): module_sensor_stop_session:429 session 1

E/mm-camera(  211): stats_module_stop_session: list =0xb8d204e8, remove port =0xb8d33a10 name=stats_sink from module=0xb8cc08a8, name=stats

E/mm-camera(  211): stats_module_stop_session: 1 port =0xb8d33a10 name=stats_sink 

E/mm-camera(  211): stats_module_stop_session: 2 port =0xb8d33a10 name=stats_sink 

E/mm-camera(  211): is_module_stop_session: Enter

E/mm-camera(  211): stats_module_stop_session: 3 port =0xb8d33a10 name=stats_sink 

E/mm-camera(  211): c2d_module_stop_session:322, info: stopping session 1 …

E/mm-camera(  211): c2d_thread_process_pipe_message:506, C2D_THREAD_MSG_ABORT: c2d_thread exiting…

E/mm-camera(  211): c2d_module_stop_session:361, info: session 1 stopped.

E/mm-camera-img(  211): module_imglib_msg_thread:99] X

E/mm-camera-img(  211): module_imglib_destroy_msg_thread:128] threadid -1193896352

E/mm-camera-img(  211): module_imglib_destroy_msg_thread:132] after msg thread exit

I/Camera2Client(  181): Camera 0: Closed

I/Camera2ClientBase(  181): Closed Camera 0

I/ActivityManager(  588): Start proc com.******.********.************* for activity com.******.********.*************/com.ansca.corona.CoronaActivity: pid=25005 uid=10081 gids={50081, 3003, 1028, 1015}

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/liblua.so 0x41ed79d0

W/linker  (25005): liblua.so has text relocations. This is wasting memory and is a security risk. Please fix.

D/dalvikvm(25005): Added shared lib /data/app-lib/com.******.********.*************-1/liblua.so 0x41ed79d0

D/dalvikvm(25005): No JNI_OnLoad found in /data/app-lib/com.******.********.*************-1/liblua.so 0x41ed79d0, skipping init

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/libjnlua5.1.so 0x41ed79d0

W/linker  (25005): libjnlua5.1.so has text relocations. This is wasting memory and is a security risk. Please fix.

D/dalvikvm(25005): Added shared lib /data/app-lib/com.******.********.*************-1/libjnlua5.1.so 0x41ed79d0

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/libjnlua5.1.so 0x41ed79d0

D/dalvikvm(25005): Shared lib ‘/data/app-lib/com.******.********.*************-1/libjnlua5.1.so’ already loaded in same CL 0x41ed79d0

I/dalvikvm(25005): threadid=1: recursive native library load attempt (/data/app-lib/com.zabace.rentals.zInspector_06-1/libjnlua5.1.so)

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/libopenal.so 0x41ed79d0

W/CAM_UI  (24814): SurfaceTexture destroyed

W/linker  (25005): libopenal.so has text relocations. This is wasting memory and is a security risk. Please fix.

I/OpenAL_SLES(25005): alc_opensles_init

D/dalvikvm(25005): Added shared lib /data/app-lib/com.******.********.*************-1/libopenal.so 0x41ed79d0

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/libmpg123.so 0x41ed79d0

W/linker  (25005): libmpg123.so has text relocations. This is wasting memory and is a security risk. Please fix.

D/dalvikvm(25005): Added shared lib /data/app-lib/com.******.********.*************-1/libmpg123.so 0x41ed79d0

D/dalvikvm(25005): No JNI_OnLoad found in /data/app-lib/com.******.********.*************-1/libmpg123.so 0x41ed79d0, skipping init

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/libvorbisidec.so 0x41ed79d0

D/dalvikvm(25005): Added shared lib /data/app-lib/com.******.********.*************-1/libvorbisidec.so 0x41ed79d0

D/dalvikvm(25005): No JNI_OnLoad found in /data/app-lib/com.******.********.*************-1/libvorbisidec.so 0x41ed79d0, skipping init

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.********.*************-1/libalmixer.so 0x41ed79d0

W/linker  (25005): libalmixer.so has text relocations. This is wasting memory and is a security risk. Please fix.

D/dalvikvm(25005): Added shared lib /data/app-lib/com.******.********.*************-1/libalmixer.so 0x41ed79d0

D/dalvikvm(25005): No JNI_OnLoad found in /data/app-lib/com.******.********.*************-1/libalmixer.so 0x41ed79d0, skipping init

D/dalvikvm(25005): Trying to load lib /data/app-lib/com.******.*******.***************-1/libcorona.so 0x41ed79d0

W/linker  (25005): libcorona.so has text relocations. This is wasting memory and is a security risk. Please fix.

D/dalvikvm(25005): Added shared lib /data/app-lib/com.zabace.rentals.zInspector_06-1/libcorona.so 0x41ed79d0

D/dalvikvm(25005): GC_CONCURRENT freed 169K, 3% free 9239K/9440K, paused 3ms+2ms, total 27ms

I/Adreno-EGL(25005): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13

D/OpenGLRenderer(25005): Enabling debug mode 0

D/dalvikvm(25005): Note: class Landroid/opengl/GLWrapperBase; has 250 unimplemented (abstract) methods

I/ActivityManager(  588): Displayed com.******.******.**************/com.ansca.corona.CoronaActivity: +318ms

V/GLSurfaceView(25005): glGetString(7937) returns Adreno ™ 320;

V/Corona  (25005): > Class.forName: network.LuaLoader

V/Corona  (25005): < Class.forName: network.LuaLoader

V/Corona  (25005): Loading via reflection: network.LuaLoader

I/Corona  (25005): Platform: Nexus 7 / ARM Neon / 4.4.2 / Adreno ™ 320 / OpenGL ES 3.0 V@53.0 AU@  (CL@)

D/dalvikvm(25005): GC_CONCURRENT freed 356K, 5% free 9314K/9704K, paused 3ms+1ms, total 15ms

I/SoundDecoder(25005): ALL MPG123 DECODERS:

I/SoundDecoder(25005):  generic

I/SoundDecoder(25005): 

I/SoundDecoder(25005): SUPPORTED MPG123 DECODERS:

I/SoundDecoder(25005):  generic

I/SoundDecoder(25005): 

I/OpenAL_SLES(25005): opensles_open_playback pDevice=0x78393008, deviceName=(null)

I/OpenAL_SLES(25005): alc_opensles_probe DEVICE_PROBE

I/OpenAL_SLES(25005): opensles_reset_playback pDevice=0x78393008

I/OpenAL_SLES(25005): bits=16, channels=2, samples=1024, size=4096, freq=44100

I/OpenAL_SLES(25005): create audio player

W/libc    (25005): pthread_create sched_setscheduler call failed: Operation not permitted

I/OpenAL_SLES(25005): playback_function started

I/OpenAL  (25005): _SC_NPROCESSORS_ONLN=4

W/linker  (25005): liblicensing.so has text relocations. This is wasting memory and is a security risk. Please fix.

V/Corona  (25005): > Class.forName: CoronaProvider.licensing.google.LuaLoader

V/Corona  (25005): < Class.forName: CoronaProvider.licensing.google.LuaLoader

V/Corona  (25005): Loading via reflection: CoronaProvider.licensing.google.LuaLoader

W/linker  (25005): libplugin.openssl.so has text relocations. This is wasting memory and is a security risk. Please fix.

D/dalvikvm(25005): GC_FOR_ALLOC freed 219K, 4% free 9459K/9784K, paused 15ms, total 15ms

I/dalvikvm-heap(25005): Grow heap (frag case) to 12.265MB for 3145744-byte allocation

D/dalvikvm(25005): GC_FOR_ALLOC freed 2K, 3% free 12529K/12860K, paused 13ms, total 13ms

D/dalvikvm(25005): GC_CONCURRENT freed 29K, 3% free 12556K/12860K, paused 2ms+2ms, total 17ms

Thanks, zabace. 

After having a similar problem I believe this happens because the device runs out of memory and “kills” your corona app while you are in the camera application.

It was happening to me in one single try to get a photo from the library. After cleaning my ram memory a bit I could see it working.

Nonetheless it would be good if someone could confirm this is the cause and ideas on how to handle it will be most welcome.

Ernest B

After having a similar problem I believe this happens because the device runs out of memory and “kills” your corona app while you are in the camera application.

It was happening to me in one single try to get a photo from the library. After cleaning my ram memory a bit I could see it working.

Nonetheless it would be good if someone could confirm this is the cause and ideas on how to handle it will be most welcome.

Ernest B