shogo4405 / HaishinKit.dart

Camera and Microphone streaming library via RTMP for Flutter.
https://pub.dev/packages/haishin_kit
BSD 3-Clause "New" or "Revised" License
32 stars 20 forks source link

Sigsev on dispose #11

Closed Wicpar closed 1 year ago

Wicpar commented 1 year ago

Describe the bug

Segfault in OplusCCodec when closing or disposing the connection or stream.

To Reproduce

@override void dispose() { super.dispose(); _connection?.close(); }

Expected behavior

it doesn't crash the app.

Version

haishin_kit: 0.9.2

Smartphone info.

Additional context

any attempt to close or dispose the resource ends in a segfault.

Screenshots

No response

Relevant log output

D/RtmpStream(16158): current=PUBLISHING, change=CLOSED
D/AudioRecord(16158): stop(2625): mActive:1
D/AudioRecord(16158): mAudioRecord->stop()
D/AudioRecord(16158): AudioRecordThread pause()
D/AudioRecord(16158): stop() end
D/OplusCCodec(16158): initiateShutdown [386]: (0xb4000075e0a15340) keepComponentAllocated=1
D/CCodecBufferChannel(16158): [c2.android.aac.encoder#630] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(16158): [c2.android.aac.encoder#630] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(16158): [c2.android.aac.encoder#630] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(16158): [c2.android.aac.encoder#630] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(16158): [c2.android.aac.encoder#630] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(16158): [c2.android.aac.encoder#630] MediaCodec discarded an unknown buffer
D/OplusCCodec(16158): initiateShutdown [386]: (0xb4000075e0a15340) keepComponentAllocated=0
F/libc    (16158): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7703fde000 in tid 16596 (odec.AudioCodec), pid 16158 (com.partaga.app)
Process name is com.partaga.app, not key_process
keyProcess: 0
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'OnePlus/OnePlus8Pro_EEA/OnePlus8Pro:12/RKQ1.211119.001/Q.GDPR.202210170945:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2022-11-22 04:27:17.263872176+0100
Process uptime: 0s
Cmdline: com.partaga.app
pid: 16158, tid: 16596, name: odec.AudioCodec  >>> com.partaga.app <<<
uid: 10607
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7703fde000
    x0  0000007703fde000  x1  00000076ead176f0  x2  00000000000006f8  x3  0000000000000000
    x4  0000000000000008  x5  0000000000000000  x6  0000007703fde000  x7  0004000400040004
    x8  0004000400040004  x9  1e050955096496b5  x10 0000000000000700  x11 0000000000000000
    x12 0000000000033680  x13 00000076ead170e8  x14 0000000000000002  x15 0000007593376000
    x16 00000076e776bae8  x17 00000076ec686940  x18 0000007576e00000  x19 b4000075e0b69400
    x20 0000000000000800  x21 0000000000000000  x22 0000007703fde000  x23 00000076e76ce260
    x24 0000000000000700  x25 0000007593376000  x26 00000076e7769978  x27 0000007593374e18
    x28 0000007593374e50  x29 0000007593374ca0
    lr  00000076e7703730  sp  0000007593374c70  pc  00000076ec6869f4  pst 0000000000001000
backtrace:
      #00 pc 00000000000759f4  /apex/com.android.runtime/lib64/bionic/libc.so (memcpy_opt+180) (BuildId: bbbdeb7c87c74f1491f92c6e605095b0)
      #01 pc 000000000005d72c  /system/lib64/libaudioclient.so (android::AudioRecord::read(void*, unsigned long, bool)+380) (BuildId: 3cd928556fc187c2febdb332bc052fa9)
      #02 pc 0000000000172864  /system/lib64/libandroid_runtime.so (android_media_AudioRecord_readInDirectBuffer(_JNIEnv*, _jobject*, _jobject*, int, unsigned char)+248) (BuildId: 0a3f50eaf6daea7090ba06720efb1840)
      #03 pc 000000000033b1c0  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+128)
Wicpar commented 1 year ago

proper code to dispose

  @override
  void dispose() async {
    super.dispose();
    await _stream?.attachAudio(null);
    await _stream?.attachVideo(null);
    await _stream?.dispose();
    _connection?.dispose();
  }