Skip to content

Android: Crash with NullpointerException when attempting to init call #533

Open
@komaxx

Description

@komaxx

On my Samsung A15 device, when I attempt to init an audio-only SIP call, I run into this exception:

03-21 16:31:05.647 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List org.webrtc.PeerConnection.getTransceivers()' on a null object reference
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.PeerConnectionObserver.getTransceiversTrack(SourceFile:13)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.MethodCallHandlerImpl.getTrackForId(SourceFile:65)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.MethodCallHandlerImpl.getNextTrackUUID(SourceFile:10)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.GetUserMediaImpl.getUserAudio(SourceFile:66)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.GetUserMediaImpl.getUserMedia(SourceFile:17)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.GetUserMediaImpl.access$100(SourceFile:1)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.GetUserMediaImpl$2.invoke(SourceFile:14)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.GetUserMediaImpl.lambda$requestPermissions$0(SourceFile:66)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.GetUserMediaImpl.a(SourceFile:1)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.c.invoke(SourceFile:1)
03-21 16:31:05.647 E AndroidRuntime: 	at com.cloudwebrtc.webrtc.utils.PermissionUtils$1.onReceiveResult(SourceFile:15)
03-21 16:31:05.647 E AndroidRuntime: 	at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50)
03-21 16:31:05.647 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:958)
03-21 16:31:05.647 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 16:31:05.647 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:230)
03-21 16:31:05.647 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:319)
03-21 16:31:05.647 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8919)
03-21 16:31:05.647 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-21 16:31:05.647 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
03-21 16:31:05.647 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Up until that point, everything looks good, the WebSocket connection is established, there are no warnings.
Here's the log up until the point of crash:

03-21 16:31:05.515 I org.webrtc.Logging: PeerConnectionFactory: PeerConnectionFactory was initialized without an injected Loggable. Any existing Loggable will be deleted.
03-21 16:31:05.515 D SemWifiApAdvancedAutohotspotService: prev history :10
03-21 16:31:05.528 D AudioFlinger: ro.audio.silent is ignored since no output device is set
03-21 16:31:05.528 D AudioFlinger: ro.audio.silent is ignored since no output device is set
03-21 16:31:05.542 I org.webrtc.Logging: WebRtcAudioManagerExternal: Sample rate is set to 48000 Hz
03-21 16:31:05.543 I org.webrtc.Logging: WebRtcAudioManagerExternal: Sample rate is set to 48000 Hz
03-21 16:31:05.543 I org.webrtc.Logging: JavaAudioDeviceModule: createAudioDeviceModule
03-21 16:31:05.543 I org.webrtc.Logging: JavaAudioDeviceModule: HW NS will be used.
03-21 16:31:05.543 I org.webrtc.Logging: JavaAudioDeviceModule: HW AEC will be used.
03-21 16:31:05.544 I org.webrtc.Logging: JavaAudioDeviceModule: Low latency mode will be used.
03-21 16:31:05.544 I org.webrtc.Logging: WebRtcAudioEffectsExternal: ctor@[name=main, id=2]
03-21 16:31:05.544 I org.webrtc.Logging: WebRtcAudioRecordExternal: ctor@[name=main, id=2]
03-21 16:31:05.544 I org.webrtc.Logging: WebRtcAudioTrackExternal: ctor@[name=main, id=2]
03-21 16:31:05.545 I org.webrtc.Logging: JavaAudioDeviceModule: setNoiseSuppressorEnabled: true
03-21 16:31:05.545 W org.webrtc.Logging: WebRtcAudioRecordExternal: SetNoiseSuppressorEnabled(true)
03-21 16:31:05.545 E org.webrtc.Logging: WebRtcAudioEffectsExternal: Attempting to enable or disable nonexistent NoiseSuppressor.
03-21 16:31:05.546 W AudioALSACaptureDataProviderNormal: readThread, latency_in_s,0.000000,0.039166,0.000034, totalTime 0.039200 > logTimeout 0.022000 TIMEOUT!!
03-21 16:31:05.547 D libMEOW : meow new tls: 0xb400007177e72a00
03-21 16:31:05.547 D libMEOW : applied 1 plugins for [ch.newvoice.mobicall.ng]:
03-21 16:31:05.547 D libMEOW :   plugin 1: [libMEOW_gift.so]: 0xb400007409b2da80
03-21 16:31:05.548 D libMEOW : rebuild call chain: 0xb400007177daafc0
03-21 16:31:05.548 I org.webrtc.Logging: EglBase14Impl: Using OpenGL ES version 2
03-21 16:31:05.586 W AudioALSACaptureDataProviderNormal: readThread, latency_in_s,0.000001,0.039607,0.000038, totalTime 0.039646 > logTimeout 0.022000 TIMEOUT!!
03-21 16:31:05.591 I GestureDetector: handleMessage TAP
03-21 16:31:05.592 I GestureDetector: handleMessage TAP
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/x-ima
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/mpeg-L1
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/mpeg-L2
03-21 16:31:05.597 W VideoCapabilities: Unsupported mime video/wvc1
03-21 16:31:05.597 W VideoCapabilities: Unsupported mime video/x-ms-wmv
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/x-adpcm-dvi-ima
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/x-adpcm-dvi-ima
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/x-adpcm-ms
03-21 16:31:05.597 W AudioCapabilities: Unsupported mime audio/x-adpcm-ms
03-21 16:31:05.599 W VideoCapabilities: Unrecognized profile/level 32768/256 for video/mp4v-es
03-21 16:31:05.600 W VideoCapabilities: Unsupported mime image/vnd.android.heic
03-21 16:31:05.600 W VideoCapabilities: Unsupported mime image/vnd.android.heic
03-21 16:31:05.600 W VideoCapabilities: Unsupported mime image/vnd.android.heic
03-21 16:31:05.600 W VideoCapabilities: Unsupported mime image/vnd.android.heic
03-21 16:31:05.601 W VideoCapabilities: Unrecognized profile/level 32768/256 for video/mp4v-es
03-21 16:31:05.601 W VideoCapabilities: Unrecognized profile/level 32768/256 for video/mp4v-es
03-21 16:31:05.623 I org.webrtc.Logging: WebRtcAudioRecordExternal: enableBuiltInAEC(true)
03-21 16:31:05.623 I org.webrtc.Logging: WebRtcAudioEffectsExternal: setAEC(true)
03-21 16:31:05.623 I org.webrtc.Logging: WebRtcAudioRecordExternal: enableBuiltInNS(true)
03-21 16:31:05.623 I org.webrtc.Logging: WebRtcAudioEffectsExternal: setNS(true)
03-21 16:31:05.624 I org.webrtc.Logging: PeerConnectionFactory: onSignalingThreadReady
03-21 16:31:05.624 I org.webrtc.Logging: PeerConnectionFactory: onWorkerThreadReady
03-21 16:31:05.625 I org.webrtc.Logging: PeerConnectionFactory: onNetworkThreadReady
03-21 16:31:05.626 W AudioALSACaptureDataProviderNormal: readThread, latency_in_s,0.000000,0.039345,0.000032, totalTime 0.039377 > logTimeout 0.022000 TIMEOUT!!
03-21 16:31:05.627 I hbox:interactor: Explicit concurrent mark compact GC freed 7587KB AllocSpace bytes, 0(0B) LOS objects, 49% free, 11MB/22MB, paused 374us,4.159ms total 227.482ms
03-21 16:31:05.627 W hbox:interactor: Reducing the number of considered missed Gc histogram windows from 166 to 100
03-21 16:31:05.640 I flutter : 16:31:05_640 D  SIP | emit "peerconnection" 
03-21 16:31:05.640 I flutter : 16:31:05_640 D  SIP | newRTCSession() 
03-21 16:31:05.640 I flutter : 16:31:05_640 D  SIP | newRTCSession => Instance of 'EventNewRTCSession' 
03-21 16:31:05.640 I flutter : 16:31:05_640 D  call: r31fjp5wnjzfa7ot2ttv8673216766: CallStateEnum.CALL_INITIATION. app -(OUTGOING)-> , state: CallStateEnum.CALL_INITIATION
03-21 16:31:05.644 I FlutterWebRTCPlugin: getUserMedia(audio): mandatory: [], optional: [googNoiseSuppression: true, googEchoCancellation: true, echoCancellation: true, googEchoCancellation2: true, googDAEchoCancellation: true]
03-21 16:31:05.644 D AndroidRuntime: Shutting down VM

To Reproduce
Not sure yet. Right now this only happens with my (rather complex) app and a not publicly reachable SIP / ICE server. I'll attempt to reproduce with a minimal project and see if I can make the server publicly available somehow.

My method to init the call seems straight-forward enough (at least to me) - but maybe there's something wrong here already?

    final settings = UaSettings();

    final url = 'wss://<redacted>';

    settings.transportType = TransportType.WS;
    settings.register = false;
    // No idea why this is required, there's no documentation. Some calls fail
    // though without setting this
    settings.sessionTimers = false;

    settings.webSocketUrl = url;

    settings.iceTransportPolicy = IceTransportPolicy.RELAY;
    settings.iceServers = _configuration.iceServers
        .map((ice) => {
              'urls': ice.url,
              'username': ice.username ?? '',
              'credential': ice.credential ?? '',
            })
        .toList(growable: false);
    settings.sessionTimersRefreshMethod = SipMethod.INVITE;

    settings.webSocketSettings.allowBadCertificate = true;

    settings.uri = 'sip:[email protected]';
    settings.authorizationUser = 'authUser';
    settings.password = 'password';
    settings.displayName = '<redacted>.App';

    settings.userAgent = 'Dart SIP Client v1.0.0';
    settings.dtmfMode = DtmfMode.RFC2833;

    _sipHelper.start(settings);

Expected behavior
Not crash ;)

Platform information

  • Flutter version:
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.2 24D81 darwin-arm64, locale en-US) [475ms]
    • Flutter version 3.29.2 on channel stable at /Users/matthiasschicker/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c236373904 (8 days ago), 2025-03-13 16:17:06 -0400
    • Engine revision 18b71d647a
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [1,585ms]
    • Android SDK at /Users/matthiasschicker/Library/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [943ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [8ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [7ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.98.2) [7ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (5 available) [10.0s]
    • Pixel 8a (mobile)               • 49271JEKB10094            • android-arm64  • Android 15 (API 35)
    • MattPhone (wireless) (mobile)   • 00008030-000C551914E3802E • ios            • iOS 18.3.2 22D82
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 15.3.2 24D81 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 15.3.2 24D81 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 134.0.6998.118

[✓] Network resources [610ms]
    • All expected network resources are available.

• No issues found!
  • Plugin version: sip_ua: 1.0.1, flutter_webrtc: 0.12.9
  • OS: Android
  • OS version: 13, 14, 15

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions