10000 Null pointer dereference in Android · Issue #831 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content
8000

Null pointer dereference in Android #831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HoangPhamThai opened this issue Jan 13, 2022 · 9 comments
Closed

Null pointer dereference in Android #831

HoangPhamThai opened this issue Jan 13, 2022 · 9 comments

Comments

@HoangPhamThai
Copy link
HoangPhamThai commented Jan 13, 2022

Describe the bug

I used 3 Android devices (Android 11) to test group call with mediasoup. I saw that sometimes the app was crashed after pressing the end call button.

I also tested the app with 2 Android devices and 1 iOS device, the crash always occurred on the Android devices.

Here is the logcat:

--------- beginning of crash
01-10 15:07:41.859 18028 21014 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 21014 (Thread-11), pid 18028 (example.example)
01-10 15:07:42.024 21019 21019 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-10 15:07:42.024 21019 21019 F DEBUG : Build fingerprint: 'samsung/gta4xlwifieea/gta4xlwifi:11/RP1A.200720.012/P610XXU2DUK1:user/release-keys'
01-10 15:07:42.024 21019 21019 F DEBUG : Revision: '7'
01-10 15:07:42.024 21019 21019 F DEBUG : ABI: 'arm64'
01-10 15:07:42.025 21019 21019 F DEBUG : Processor: '4'
01-10 15:07:42.027 21019 21019 F DEBUG : Timestamp: 2022-01-10 15:07:42+0700
01-10 15:07:42.027 21019 21019 F DEBUG : pid: 18028, tid: 21014, name: Thread-11 >>> com.example.example <<<
01-10 15:07:42.027 21019 21019 F DEBUG : uid: 10012
01-10 15:07:42.027 21019 21019 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
01-10 15:07:42.027 21019 21019 F DEBUG : Cause: null pointer dereference
01-10 15:07:42.027 21019 21019 F DEBUG : x0 0000000000000000 x1 0000007748098a28 x2 0000007748098260 x3 0000000000000006
01-10 15:07:42.027 21019 21019 F DEBUG : x4 00000077bea9c300 x5 00000077bea9c4b0 x6 0000000000000002 x7 0000007748097fd0
01-10 15:07:42.027 21019 21019 F DEBUG : x8 15cb795669a283b7 x9 15cb795669a283b7 x10 0000000000000015 x11 0000007780000000
01-10 15:07:42.028 21019 21019 F DEBUG : x12 00000000000cf8c0 x13 0000000000000001 x14 000000007ffbffff x15 0000000000000012
01-10 15:07:42.028 21019 21019 F DEBUG : x16 00000078bf59d9b8 x17 00000078bf591f7c x18 0000007743550000 x19 00000077be9d7a00
01-10 15:07:42.028 21019 21019 F DEBUG : x20 0000132918d66678 x21 00000077be9d7a18 x22 0000000000000001 x23 000000774809a000
01-10 15:07:42.028 21019 21019 F DEBUG : x24 0000000063ed98b4 x25 000000774809a000 x26 00000000000005e3 x27 0000000000000003
01-10 15:07:42.028 21019 21019 F DEBUG : x28 0000007748098ce0 x29 0000007748098c50
01-10 15:07:42.028 21019 21019 F DEBUG : lr 0000007829fa9548 sp 0000007748098260 pc 0000007829fa9554 pst 0000000060000000
01-10 15:07:42.217 21019 21019 F DEBUG : backtrace:
01-10 15:07:42.217 21019 21019 F DEBUG : #00 pc 0000000000516554 /data/app/~~6Bdsngb3Ra3xcsytbZxmEA==/com.example.example-kU1gMBP6cLqd40pC14l3tA==/lib/arm64/libjingle_peerconnection_so.so (BuildId: bc662912e660ccb2)
01-10 15:07:42.217 21019 21019 F DEBUG : #1 pc 00000000005163dc /data/app/~~6Bdsngb3Ra3xcsytbZxmEA==/com.example.example-kU1gMBP6cLqd40pC14l3tA==/lib/arm64/libjingle_peerconnection_so.so (Java_org_webrtc_VideoEncoderWrapper_nativeOnEncodedFrame+32) (BuildId: bc662912e660ccb2)
01-10 15:07:42.217 21019 21019 F DEBUG : #2 pc 000000000013eed4 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.217 21019 21019 F DEBUG : #3 pc 00000000001357e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.217 21019 21019 F DEBUG : #4 pc 00000000001aaa94 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #5 pc 000000000032229c /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #6 pc 00000000003185c8 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #7 pc 000000000068a230 /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+548) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #8 pc 000000000012f994 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #9 pc 00000000002a96c0 [anon:dalvik-classes.dex extracted in memory from /data/app/~~6Bdsngb3Ra3xcsytbZxmEA==/com.example.example-kU1gMBP6cLqd40pC14l3tA==/base.apk] (org.webrtc.VideoEncoderWrapper.lambda$createEncoderCallback$0)
01-10 15:07:42.218 21019 21019 F DEBUG : #10 pc 000000000068a4d4 /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+1224) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #11 pc 000000000012f994 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #12 pc 000000000028f8d8 [anon:dalvik-classes.dex extracted in memory from /data/app/~~6Bdsngb3Ra3xcsytbZxmEA==/com.example.example-kU1gMBP6cLqd40pC14l3tA==/base.apk] (org.webrtc.-$$Lambda$VideoEncoderWrapper$V7w9xAx2svrNbdf3v5wgQjncQ24.onEncodedFrame+4)
01-10 15:07:42.218 21019 21019 F DEBUG : #13 pc 0000000000688fb0 /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1808) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #14 pc 000000000012fa14 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #15 pc 000000000029ca1a [anon:dalvik-classes.dex extracted in memory from /data/app/~~6Bdsngb3Ra3xcsytbZxmEA==/com.example.example-kU1gMBP6cLqd40pC14l3tA==/base.apk] (org.webrtc.HardwareVideoEncoder.deliverEncodedImage+554)
01-10 15:07:42.218 21019 21019 F DEBUG : #16 pc 0000000000687578 /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.218 21019 21019 F DEBUG : #17 pc 000000000012f814 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #18 pc 000000000029b1b0 [anon:dalvik-classes.dex extracted in memory from /data/app/~~6Bdsngb3Ra3xcsytbZxmEA==/com.example.example-kU1gMBP6cLqd40pC14l3tA==/base.apk] (org.webrtc.HardwareVideoEncoder$1.run+20)
01-10 15:07:42.219 21019 21019 F DEBUG : #19 pc 000000000030fbc4 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.16619280533006879875)+268) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #20 pc 0000000000675d5c /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #21 pc 000000000013eff8 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #22 pc 0000000000135564 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #23 pc 00000000001aaa78 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #24 pc 000000000055f278 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValuesart::ArtMethod*(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #25 pc 00000000005aea3c /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1308) (BuildId: e6ec6e98496fc31eee712d0c54dbde3b)
01-10 15:07:42.219 21019 21019 F DEBUG : #26 pc 00000000000eb7a8 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: 698b6aef520f034a9d40736d477f7a96)
01-10 15:07:42.219 21019 21019 F DEBUG : #27 pc 000000000008bc8c /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 698b6aef520f034a9d40736d477f7a96)

In MethodCallHandlerImpl.java, I replaced the code inside ensureInitialized() with the following code:

PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(context).createInitializationOptions());

PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
EglBase.Context eglContext = EglUtils.getRootEglBaseContext();
getUserMediaImpl = new GetUserMediaImpl(this, context);

audioDeviceModule = JavaAudioDeviceModule.builder(context)
        .setUseHardwareAcousticEchoCanceler(true)
        .setUseHardwareNoiseSuppressor(true)
        .setSamplesReadyCallback(getUserMediaImpl.inputSamplesInterceptor)
        .createAudioDeviceModule();

DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(
        eglContext,  /* enableIntelVp8Encoder */true,  /* enableH264HighProfile */true);
DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(eglContext);

mFactory = PeerConnectionFactory.builder()
        .setVideoEncoderFactory(defaultVideoEncoderFactory)
        .setVideoDecoderFactory(defaultVideoDecoderFactory)
        .setOptions(options)
        .setAudioDeviceModule(audioDeviceModule)
        .createPeerConnectionFactory();

and tested again several times, the bug disappeared. So it seems that there is something wrong with the SimulcastVideoEncoderFactoryWrapper().

To Reproduce

Run mediasoup in 3 Android devices. Hardcode the room id so you don't need to enter the room url whenever you start a call.

Start video call several times (e.g. 15 times).

Expected behavior
All the devices should end call normally in all the test.

Platform information

Flutter version**:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19042.1415], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.63.2)
[√] Connected device (3 available)

• No issues found!

Dart SDK version: 2.15.1 (stable) (Tue Dec 14 13:32:21 2021 +0100) on "windows_x64"

  • Plugin version: flutter_webrtc: ^0.8.1
  • OS: Android 11
  • OS version:
@MinhCuongIT
Copy link

Any update for this? :D

@ghost
Copy link
ghost commented Jan 18, 2022

Experiencing the same thing. The solution proposed works for me also.

@thammaknot
Copy link

Thank you so much for sharing this solution.
I tried it and it seems to have fixed the issue.

What I did was I modified the MethodCallHandlerImpl.java found under the flutter/.pub-cached/pub.dartlang.org/flutter_webrtc-0.8.0/ folder.

Is this the right way to do it? It feels a bit hacky.

@FeleConvo
Copy link

Same happening over here, Android hangup throws and error 40%ish time we hangup.

@davidliu @hiroshihorie You guys think we should go ahead and just create a PR with the proposed fix?

@davidliu
Copy link
Contributor
davidliu commented Feb 26, 2022

This might be the same issue I saw over here:

livekit/client-sdk-android#52

This was fixed by the upgrade to WebRTC M97, which we've also recently merged in here. Can I ask you all to try out the latest build and see if it's resolved there?

dependencies {
    implementation 'com.github.flutter-webrtc:flutter-webrtc:95be5f0090'
}

@FeleConvo
Copy link

This might be the same issue I saw over here:

livekit/client-sdk-android#52

This was fixed by the upgrade to WebRTC M97, which we've also recently merged in here. Can I ask you all to try out the latest build and see if it's resolved there?

dependencies {
    implementation 'com.github.flutter-webrtc:flutter-webrtc:95be5f0090'
}

@gabeconvo could you confirm issue is fixed in new version?

@FeleConvo
Copy link

@davidliu @hiroshihorie

Issue is still present in 0.8.2

 flutter_webrtc: 0.8.2

but fixed when:

 flutter_webrtc:
    git:
      url: git@github.com:flutter-webrtc/flutter-webrtc.git
      ref: 95be5f0090

@hiroshihorie
Copy link
Member

@FeleConvo that's good to know it's fixed with M97 !

@davidliu
Copy link
Contributor

Closing since this seems to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
0