0

My application crashes immediately after return START_STICKY.

I have a foreground service in my application :

public class MyService extends Service {

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (intent != null) {
            if (intent.getAction().equals(STARTFOREGROUND_ACTION)) {
                // Code to create/update notification and start processing goes here
            } else if (intent.getAction().equals(ANOTHER_ACTION)) {             
                // Code to create/update notification and do another processing
            } else if (null != intent && intent.getAction().equals(STOPFOREGROUND_ACTION)) {
            stopForeground(true);
            stopSelf();
        }
        }   

        return START_STICKY; // Last reference point in debugger after which application crashes 
    }

    }

I tried debugging only last point of debug is return START_STICKY; specially for STOPFOREGROUND_ACTION signal after which it crashes.

No error, warning is shown in application logs can't figure out what may have gone wrong.

What can I do to solve this is my way of stopping foreground service is wrong, what else I can to do get more app specific logs.

I have checked my code everywhere I am catching exceptions and logging them as below :

try {
           // Code expected to throw error or exception
        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
        }

No place in the app where I am bypassing exception they are cached and logged everywhere.

Some of the errors I see when I disable all filters and select verbose option on log cat :

1] `A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x10 in tid 32152 (Thread-1910)`

2] com.my.test.MyActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9

3] [Application Error: com.my.test](this:0xb28d3c00,id:809,api:1,p:933,c:252) new GraphicBuffer needed

4] I/WindowState: WIN DEATH: Window{41e99c5 u0 com.my.test.MyActivity}

Prashant
  • 4,474
  • 8
  • 34
  • 82

1 Answers1

0

As nobody responded and I have managed to figure out the problem, the problem was

A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x10 in tid 32152 (Thread-1910)

Caused due to A Thread running out of service which has reference to MediaRecorder. I was stopping my service as below :

stopForeground(true);
stopSelf();

Which ( Above) is proper way of stopping service. But before stopping service I was releasing and stopping the MediaRecorder. As MediaRecorder object can still be accessed by the thread outside service after release() any of the MediaRecorder method call caused above error to be thrown and it is related with native code not java code hence hard to track down. There are other reasons for this error check below question :

Android Fatal signal 11 (SIGSEGV) at 0x636f7d89 (code=1). How can it be tracked down?

My problem solved because of comment made by personne3000 on this question.

Prashant
  • 4,474
  • 8
  • 34
  • 82