47

I develop Android apps now with PhoneGap. Lately when I try to switch between HTML pages, the application closed, and in the LogCat the following error appears:

12-24 15:43:39.237: A/libc(23631): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 23631 (.example.app)

I searched a bit on Google about this error, and what I understand is that it is related to the device's memory. I found some solutions, but not so much that I realized how I implement them in PhoneGap.

Has anyone here encountered this error before? What can I do to solve the problem?

Thank you :)

Yehuda
  • 1,382
  • 3
  • 18
  • 25
  • 9
    This could also be caused by more than one thread calling the same native method on the same object at once. See: http://stackoverflow.com/a/11812665/1172181. So, the answer would be to synchronize and make sure that your code is thread safe. – Luis Mar 14 '13 at 14:56

9 Answers9

44

If you have written (or are using) a plugin that in turn uses native C/C++ code through the NDK, this may indicate a bug in that native code.

Otherwise, this is a bug in the firmware of the device or emulator you are testing upon.

If you can reproduce this in an emulator, on a Nexus device with the original ROM, or on a variety of devices from different manufacturers, it is probably a bug in Android itself. In that case, please create a sample project that can reproduce the error, and post it along with the entire stack trace to http://b.android.com, the Android OS issue tracker.

If you are only encountering this on one device or one third-party ROM, it is probably a more specific bug -- your best bet is to contact the device manufacturer or ROM publisher with your symptoms.

Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    Thank you, you helped me a lot. I'll try to get another device to check on him and I will update later if necessary. :) – Yehuda Dec 24 '12 at 19:58
  • Thanks. That solved my problem. Why don't android provide the correct error message ? That's too bad. – Bagusflyer Aug 18 '13 at 12:27
16

I was getting a similar error on the xhdpi Nexus 7 but things worked fine on my old phone. My problem occurred while updating a large GridView with lots of small buttons.

A/libc(7410): Fatal signal 11 (SIGSEGV) at 0xbe8a8000 (code=1), thread 7410

I don't think this is your problem because your PC was 0 and mine was at 0xbe8a8000 but it's easy to try and it fixed my problem so I'm going to post it in case someone else comes here looking for a SEGV solution.
There was a discussion on https://github.com/MasDennis/Rajawali/issues/313 about a similar problem and someone mentioned that they had the same problem and turning off hardware acceleration fixed it for them. It's easy to try and it fixed my problem.
In the Android manifest application add:

android:hardwareAccelerated="false"

Hope this helps someone else...

steven smith
  • 1,519
  • 15
  • 31
  • Yep thanks, in the emulator this was the cause. Set hardwareAccelerated to false and it doesn't crash anymore but now I get: "eglMakeCurrent(917): error 0x3001 (EGL_NOT_INITIALIZED)" – marco Jan 12 '15 at 11:34
  • @steven smith i am using android:hardwareAccelerated="false", but i have not solve my problem still my application is crashed. Have you any other idea to solve this error "Fatal signal 11 (SIGSEGV), code 1, fault addr 0xa5156d60 in tid 21028 (lfontpro.source)". Thank you – patel135 Jan 11 '16 at 05:44
11

I just had the same problem on a project I was working on. It turned out that I was loading a lot of images and sounds and causing the app to run out of memory while trying to instantiate an Activity. Does your program use a lot of memory-intensive assets? Can you reduce their sizes at all?

In my case, the LogCat had a stack trace in green (INFO-level logging) immediately before the Fatal signal 11 (SIGSEGV) line. The stack trace was an OutOfMemoryException while the app was loading assets for an Activity I was starting up. So I pulled up my drawables (my program had a lot of them), edited them to reduce their file size, and tried again. The bug went away. You can see if your LogCat output looks like mine to see if you have a similar issue:

01-15 05:20:40.462: E/dalvikvm-heap(4513): Out of memory on a 3145744-byte allocation.
01-15 05:20:40.462: I/dalvikvm(4513): "main" prio=5 tid=1 RUNNABLE
01-15 05:20:40.462: I/dalvikvm(4513):   | group="main" sCount=0 dsCount=0 obj=0x4158b6a0 self=0x41001a60
01-15 05:20:40.462: I/dalvikvm(4513):   | sysTid=4513 nice=0 sched=0/0 cgrp=apps handle=1074673744
01-15 05:20:40.462: I/dalvikvm(4513):   | schedstat=( 0 0 0 ) utm=41 stm=20 core=1
01-15 05:20:40.462: I/dalvikvm(4513):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-15 05:20:40.462: I/dalvikvm(4513):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:592)
01-15 05:20:40.462: I/dalvikvm(4513):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
01-15 05:20:40.462: I/dalvikvm(4513):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
01-15 05:20:40.462: I/dalvikvm(4513):   at android.content.res.Resources.loadDrawable(Resources.java:1963)
01-15 05:20:40.462: I/dalvikvm(4513):   at android.content.res.Resources.getDrawable(Resources.java:672)
01-15 05:20:40.462: I/dalvikvm(4513):   at com.kbi.speeddraw.lite.game.drawables.character.ExplodingCharacterDrawable.<init>(ExplodingCharacterDrawable.java:27)
<!-- snip -->
01-15 05:20:40.462: I/dalvikvm(4513):   at com.kbi.gameengine.api.gameactivity.GameActivity.onCreate(GameActivity.java:80)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.Activity.performCreate(Activity.java:5048)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2052)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.ActivityThread.access$700(ActivityThread.java:139)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.os.Handler.dispatchMessage(Handler.java:99)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.os.Looper.loop(Looper.java:137)
01-15 05:20:40.472: I/dalvikvm(4513):   at android.app.ActivityThread.main(ActivityThread.java:4918)
01-15 05:20:40.472: I/dalvikvm(4513):   at java.lang.reflect.Method.invokeNative(Native Method)
01-15 05:20:40.472: I/dalvikvm(4513):   at java.lang.reflect.Method.invoke(Method.java:511)
01-15 05:20:40.472: I/dalvikvm(4513):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
01-15 05:20:40.472: I/dalvikvm(4513):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
01-15 05:20:40.472: I/dalvikvm(4513):   at dalvik.system.NativeStart.main(Native Method)
01-15 05:20:40.472: A/libc(4513): Fatal signal 11 (SIGSEGV) at 0x00000be0 (code=1), thread 4513 (.speeddraw.lite)
01-15 05:20:40.472: A/libc(4513): Fatal signal 11 (SIGSEGV) at 0x00180500 (code=1), thread 4527 (.speeddraw.lite)
Kevin
  • 14,655
  • 24
  • 74
  • 124
  • 1
    One more thing that might have been causing the bug for me: The app ran out of memory inside of a second thread, not the main UI thread. I don't know if this worsened the situation or not. I'm developing on a Galaxy S3. – Kevin Jan 15 '13 at 11:42
  • By how much did you reduce your images? Mine are only 720x720 (same width as a Galaxy S3). I just reduced them by 25% and it didn't make a difference. Obviously I don't want to go too far or they'll start looking bad. – MSpeed Sep 02 '13 at 13:42
  • I don't remember. I can let you know that the current size of my `res` folder, which contains all of the images (and sounds) that I used and loaded, is 709 KB. Before I edited them, my res folder was several MB in size. I was loading nearly all of these resources at once in the activity that was failing for me, so I'm guessing my S3 can handle roughly 1 MB being loaded in a single activity. – Kevin Sep 02 '13 at 18:42
  • Wow, thanks. So would you say the quality of the images we noticeably worse in the final app? I reduced mine to a size where the crashing has stopped but the images are now smaller than I would have liked. – MSpeed Sep 03 '13 at 13:14
  • I didn't have that many assets, so I was able to keep them pretty large. Most of my assets are currently 10-100 KB in size, and I can't notice an loss in quality. That said, my app used an art style that was already "stylistic suck," so their might be some degradation that isn't noticeable because it's not supposed to look polished. – Kevin Sep 03 '13 at 19:22
  • There are ways to decrease file size without decreasing your images' dimensions. Does your image editing software show you a quality setting when you save? – Kevin Sep 03 '13 at 19:25
  • not when loaded a native bitmap - the compression used in the images software wont make a diff - you can load as differnt encodings though like ARGB_8888 or RGB_565 ect – Dori Dec 13 '13 at 11:05
5

Check for OutofMemory issues in my case I got this error on Samsung S3 and was for managing a lot of images on startup Activity. I googled a lot of responses without a solution because I didn't have an EditText or an input at all (actually, I don't know why the error show the spannable string zero lenght..... and not another thing like OutOfMemory, etc), then I realize the images ordered by resolution were in the wrong folders and oversized, and the Heap up in the skies. Good Luck

recnac
  • 3,744
  • 6
  • 24
  • 46
Ciclids
  • 51
  • 1
  • 2
5

The following Google Plus post fixed my problem:

Basically the problem is related to optical bounds in 9 patches files. In my case I was using newer 9patches copied from the Holo Theme. This new patches are invalid in older versions of android as explained in the link

GVillani82
  • 17,196
  • 30
  • 105
  • 172
unify
  • 6,161
  • 4
  • 33
  • 34
3

Make sure you have all the resources images under assets directory. I had this problem and it turns out that one of my images is missing. Once I put the image back under assets directory, everything is fine.

Emmy
  • 3,949
  • 5
  • 28
  • 30
1

use this one... options.headers = { "Connection":"close" };

mahi
  • 41
  • 1
  • 5
1

The following worked for me to get rid of the error in the webview:

webView.freeMemory();

or

webView.clearCache(true);

The second option will slow down your app.

buczek
  • 2,011
  • 7
  • 29
  • 40
user3727574
  • 136
  • 1
  • 8
0

For me issue is in chrome webview. I disable chrome & enable Android webview. It works fine for me.

Rajan Kashiyani
  • 891
  • 7
  • 11