A/libc: Fatal signal 11 (SIGSEGV) at 0x00000005 (code=1), thread 26834 Android app crash

0

I checked this and this links for this problem but couldn't find any solution.

I am implementing an RTSP player in android and I have used Easy Player for this. Using this player I have implementd my demo application and entered an rtsp:// URL.

PROBLEM: When I enter the same URL in library sample code it is working fine, but when I try with my demo app the app crashes with following stacktrace.

04-20 16:13:57.189 26834-26834/com.easydrawindemo A/libc: Fatal signal 11 (SIGSEGV) at 0x00000005 (code=1), thread 26834 (.easydrawindemo)
    04-20 16:13:57.219 1163-1163/? D/BubblePopupHelper: isShowingBubblePopup : false
    04-20 16:13:57.289 292-292/? I/DEBUG: [04-20 16:13:57.295]
    04-20 16:13:57.289 292-292/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    04-20 16:13:57.289 292-292/? I/DEBUG: Build fingerprint: 'lge/g3_global_com/g3:4.4.2/KVT49L.D85510i/D85510i.1403169216:user/release-keys'
    04-20 16:13:57.289 292-292/? I/DEBUG: Revision: '10'
    04-20 16:13:57.289 292-292/? I/DEBUG: pid: 26834, tid: 26834, name: .easydrawindemo  >>> com.easydrawindemo <<<
    04-20 16:13:57.289 292-292/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000005
    04-20 16:13:57.289 971-1151/? D/WifiStateMachine: handleMessage: E msg.what=131155
    04-20 16:13:57.289 971-1151/? D/WifiStateMachine: processMsg: ConnectedState
    04-20 16:13:57.289 971-1151/? D/WifiStateMachine: processMsg: L2ConnectedState
    04-20 16:13:57.289 971-1151/? D/WifiNative-wlan0: doString: SIGNAL_POLL
    04-20 16:13:57.289 971-1182/? W/NativeCrashListener: Couldn't find ProcessRecord for pid 1529885741

And here is my fragment class:

public class PlayerFragment extends Fragment implements TextureView.SurfaceTextureListener, PhotoViewAttacher.OnMatrixChangedListener {

    private TextureView videoSurfaceView;
    private ProgressBar pBarVideo;
    private String videoUrl;
    private int transType;
    protected EasyRTSPClient mStreamRender;
    protected ResultReceiver mResultReceiver;
    private MediaScannerConnection mScanner;
    private int mWidth, mHeight;
    private PhotoViewAttacher mAttacher;
    private static final String TAG = "PlayerFragment";
    public static final int RESULT_REND_STARTED = 1;
    public static final int RESULT_REND_VIDEO_DISPLAYED = 2;
    public static final int RESULT_REND_STOPED = -1;
    private ResultReceiver mRR;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setLandscapeOrientation();

        Log.i(TAG, "onCreate called");

        if (getArguments() != null) {
            Log.i(TAG, "onCreate if called");
            videoUrl = getArguments().getString(Constants.KEY_VIDEO_URL);
            transType = getArguments().getInt(Constants.KEY_PROTOCOL_TYPE);
            mRR = getArguments().getParcelable(Constants.KEY_RESULT_RECEIVER);
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_player, container, false);
        Log.i(TAG, "onCreateView called");
        videoSurfaceView = (TextureView) view.findViewById(R.id.videoSurfaceView);
        videoSurfaceView.setOpaque(false);
        videoSurfaceView.setSurfaceTextureListener(this);
        pBarVideo = (ProgressBar) view.findViewById(R.id.pBarVideo);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Log.i(TAG, "onViewCreated called");

        mResultReceiver = new ResultReceiver(new Handler()) {
            @Override
            protected void onReceiveResult(int resultCode, Bundle resultData) {
                super.onReceiveResult(resultCode, resultData);
                PlayerActivity activity = (PlayerActivity) getActivity();
                if (activity == null)return;
                if (resultCode == EasyRTSPClient.RESULT_VIDEO_DISPLAYED) {
                    Log.i(TAG, "ResultReceiver RESULT_VIDEO_DISPLAYED called");
//                    onVideoDisplayed();
                }
                else if (resultCode == EasyRTSPClient.RESULT_VIDEO_SIZE) {
                    Log.i(TAG, "ResultReceiver RESULT_VIDEO_SIZE called");
                    mWidth = resultData.getInt(EasyRTSPClient.EXTRA_VIDEO_WIDTH);
                    mHeight = resultData.getInt(EasyRTSPClient.EXTRA_VIDEO_HEIGHT);
//                    onVideoSizeChange();
                }
                else if (resultCode == EasyRTSPClient.RESULT_TIMEOUT) {
                    Log.i(TAG, "ResultReceiver RESULT_TIMEOUT called");
                    new AlertDialog.Builder(getActivity()).setMessage("Timeout").setTitle("SORRY").setPositiveButton(android.R.string.ok, null).show();
                }
                else if (resultCode == EasyRTSPClient.RESULT_UNSUPPORTED_AUDIO) {
                    Log.i(TAG, "ResultReceiver RESULT_UNSUPPORTED_AUDIO called");
                    new AlertDialog.Builder(getActivity()).setMessage("Unsupported Audio").setTitle("SORRY").setPositiveButton(android.R.string.ok, null).show();
                }
                else if (resultCode == EasyRTSPClient.RESULT_UNSUPPORTED_VIDEO) {
                    Log.i(TAG, "ResultReceiver RESULT_UNSUPPORTED_VIDEO called");
                    new AlertDialog.Builder(getActivity()).setMessage("Unsupported Video").setTitle("SORRY").setPositiveButton(android.R.string.ok, null).show();
                }
                else if (resultCode == EasyRTSPClient.RESULT_EVENT){
                    Log.i(TAG, "ResultReceiver RESULT_EVENT called");
                    int errorcode = resultData.getInt("errorcode");
                    if (errorcode != 0){
                        stopRendering();
                    }
//                    activity.onEvent(PlayFragment.this, errorcode,resultData.getString("event-msg"));
                }
//                else if (resultCode == EasyRTSPClient.RESULT_RECORD_BEGIN){
//                    activity.onRecordState(1);
//                }
//                else if (resultCode == EasyRTSPClient.RESULT_RECORD_END){
//                    activity.onRecordState(-1);
//                }
            }
        };

        if (mAttacher != null) {
            mAttacher.cleanup();
        }

        mAttacher = new PhotoViewAttacher(videoSurfaceView, mWidth, mHeight);
        mAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP);
        mAttacher.setOnMatrixChangeListener(PlayerFragment.this);
        mAttacher.update();
    }

    public static PlayerFragment getInstance(String URL, int type, ResultReceiver rr) {
        Log.i(TAG, "getInstance called");
        PlayerFragment playerFragment = new PlayerFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Constants.KEY_VIDEO_URL, URL);
        bundle.putInt(Constants.KEY_PROTOCOL_TYPE, type);
        bundle.putParcelable(Constants.KEY_RESULT_RECEIVER, rr);
        playerFragment.setArguments(bundle);
        return playerFragment;
    }

    private void setLandscapeOrientation() {
        Log.i(TAG, "setLandscapeOrientation called");
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    @Override
    public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) {
        Log.i(TAG, "onSurfaceTextureAvailable called");
        startRendering(surfaceTexture);
    }

    @Override
    public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i1) {
        Log.i(TAG, "onSurfaceTextureSizeChanged called");
    }

    @Override
    public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
        Log.i(TAG, "onSurfaceTextureDestroyed called");
        stopRendering();
        return true;
    }

    @Override
    public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
        Log.i(TAG, "onSurfaceTextureUpdated called");

    }

    private void startRendering(SurfaceTexture surface) {

        Log.i(TAG, "startRendering called");

        mStreamRender = new EasyRTSPClient(getActivity(), "79393674363536526D343241654D7859707A4F484A655A76636D63755A57467A65575268636E64706269356C59584E356347786865575679567778576F502B6C34456468646D6C754A6B4A68596D397A595541794D4445325257467A65555268636E6470626C526C5957316C59584E35", surface, mResultReceiver);
//        boolean autoRecord = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("auto_record", false);

//        File f = new File(TheApp.sMoviePath);
//        f.mkdirs();

        try {
            mStreamRender.start(videoUrl, transType, RTSPClient.EASY_SDK_VIDEO_FRAME_FLAG | RTSPClient.EASY_SDK_AUDIO_FRAME_FLAG, "", "", null);
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
        }
//        mStreamRender.start2(mUrl, mType);
        mRR.send(RESULT_REND_STARTED, null);
    }

    private void stopRendering() {
        Log.i(TAG, "stopRendering called");
        if (mStreamRender != null) {
            mRR.send(RESULT_REND_STOPED, null);
            mStreamRender.stop();
            mStreamRender = null;
        }
    }

    @Override
    public void onMatrixChanged(RectF rectF) {
        Log.i(TAG, "onMatrixChanged called");
    }
}

I have tried almost everything but couldn't find solution for this. Please correct me if I have done anything wrong and provide me a solution.

Thanks in advance.

android
android-ndk
rtsp-client
asked on Stack Overflow Apr 20, 2017 by Megha Maniar • edited May 23, 2017 by Community

1 Answer

-1

I found my mistake, in Easy player, a unique key is generated for every package name and in my case that key was incorrect. I don't know why it is giving memory leakage error for an invalid key!! Replacing package name and key solved this problem. Strange but true.

answered on Stack Overflow Apr 21, 2017 by Megha Maniar

User contributions licensed under CC BY-SA 3.0