react native

Am using mediasoup for video conferencing, but on the connection stages, where transport.produce() invokes transport.on('connect' event when i execute callback from transport.on('connect the application crashes

producerTransport.on(
  'connect',
  async function ({dtlsParameters}, callback, errback) {
    await Request('connectTransport', {
      dtlsParameters,
      transport_id: data.id,
    })
      .then(data => {
        callback();//crashes the application when called, 
      })
      .catch(errback);
  },
);

This is just a guess, but make sure that your native build is using the same version of react-native-webrtc that your javascript bundle is using.

There’s not enough information here for anyone to properly diagnose this.

What do you mean by “crash”? Is it a Javascript exception? Is there an exception in the native code? Is this on ios or Android? Are there errors in the console when it crashes?

If this happens every time, it should be easy to debug. Run it in a debugger and look at the stack trace.

For what it’s worth, I’m using mediasoup with react-native and don’t have any crashes like this.

1 Like

Am using mediasoup on react native the crashes happens on android devices
no errors, app just closes down,
if i comment out callback method, the app is not crashing but you now its not progressing to next stage of connection. my package.json is as below

{

  "name": "JackDoors",

  "version": "0.0.1",

  "private": true,

  "scripts": {

    "android": "react-native run-android",

    "ios": "react-native run-ios",

    "start": "react-native start",

    "test": "jest",

    "lint": "eslint ."

  },

  "dependencies": {

    "@babel/preset-env": "^7.1.6",

    "@react-native-async-storage/async-storage": "^1.15.17",

    "@react-navigation/native": "^6.0.6",

    "@react-navigation/native-stack": "^6.2.5",

    "mediasoup-client": "^3.6.50",

    "react": "17.0.2",

    "react-native": "0.67.1",

    "react-native-permissions": "^3.2.0",

    "react-native-safe-area-context": "^3.3.2",

    "react-native-screens": "^3.10.2",

    "react-native-vector-icons": "^9.0.0",

    "react-native-webrtc": "^1.94.1",

    "socket.io-client": "^4.4.1"

  },

  "devDependencies": {

    "@babel/core": "^7.12.9",

    "@babel/runtime": "^7.12.5",

    "@react-native-community/eslint-config": "^2.0.0",

    "babel-jest": "^26.6.3",

    "eslint": "7.14.0",

    "jest": "^26.6.3",

    "metro-react-native-babel-preset": "^0.66.2",

    "react-test-renderer": "17.0.2"

  },

  "jest": {

    "preset": "react-native"

  }

What is in the logcat when it crashes?

I crashes without showing any debug error not on metro bundler terminal , not even its red screen of error is not showing up, just crashes and close down

maybe if there is any suggestion on how to capture errors before application closes

Like I said, run it inside of the Android Studio debugger, or inspect the output of logcat. Native crashes won’t show up in metro.

android studio debugger logs as below
2022-01-28 02:15:04.861 16235-16235/com.smartchurch D/TextView: setTypeface with style : 0
2022-01-28 02:15:04.879 16235-16235/com.smartchurch D/TextView: setTypeface with style : 0
2022-01-28 02:15:56.308 16235-16235/com.smartchurch D/ViewRootImpl@4630fd4[MainActivity]: ViewPostImeInputStage processPointer 0
2022-01-28 02:15:56.370 16235-16235/com.smartchurch D/ViewRootImpl@4630fd4[MainActivity]: ViewPostImeInputStage processPointer 1
2022-01-28 02:15:56.372 16235-16241/com.smartchurch I/art: Do partial code cache collection, code=124KB, data=113KB
2022-01-28 02:15:56.372 16235-16241/com.smartchurch I/art: After code cache collection, code=123KB, data=112KB
2022-01-28 02:15:56.372 16235-16241/com.smartchurch I/art: Increasing code cache capacity to 512KB
2022-01-28 02:15:57.312 16235-17828/com.smartchurch I/ReactNativeJS: 'Media constraints ', { audio: false,
video:
{ width: { min: 640, ideal: 1920 },
height: { min: 400, ideal: 1080 } } }

2022-01-28 02:15:57.420 16235-16235/com.smartchurch D/ViewRootImpl@4630fd4[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2022-01-28 02:15:57.431 16235-16235/com.smartchurch D/SensorManager: unregisterListener ::
2022-01-28 02:15:57.664 16235-16235/com.smartchurch D/ViewRootImpl@4630fd4[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2022-01-28 02:15:57.686 16235-16235/com.smartchurch D/SensorManager: registerListener :: 0, K6DS3TR Acceleration Sensor, 66667, 0,
2022-01-28 02:15:57.692 16235-18468/com.smartchurch D/com.oney.WebRTCModule.WebRTCModule: getUserMedia(video): { NativeMap: {“deviceId”:“1”,“facingMode”:“user”,“width”:640,“frameRate”:30,“height”:480} }
2022-01-28 02:15:57.693 16235-18468/com.smartchurch D/CameraCaptureController: Create user-specified camera 1 succeeded
2022-01-28 02:15:57.696 16235-18566/com.smartchurch I/org.webrtc.Logging: EglBase14Impl: Using OpenGL ES version 2
2022-01-28 02:15:57.703 16235-18468/com.smartchurch I/org.webrtc.Logging: CameraCapturer: startCapture: 640x480@30
2022-01-28 02:15:57.707 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Create new camera2 session on camera 1
2022-01-28 02:15:57.707 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: start
2022-01-28 02:15:57.708 16235-18468/com.smartchurch D/com.oney.WebRTCModule.WebRTCModule: MediaStream id: d32b789b-54e6-4cba-b982-37c3e88b5de2
2022-01-28 02:15:57.710 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Available preview sizes: [2592x1944, 2592x1458, 2560x1440, 2048x1536, 1936x1936, 1920x1440, 1920x1080, 1440x1080, 1088x1088, 1072x1072, 1280x720, 1056x704, 960x720, 800x450, 736x736, 720x480, 640x480, 352x288, 320x240, 256x144, 176x144]
2022-01-28 02:15:57.710 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Available fps ranges: [[15.0:15.0], [24.0:24.0], [10.0:30.0], [15.0:30.0], [30.0:30.0]]
2022-01-28 02:15:57.711 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Using capture format: 640x480@[10.0:30.0]
2022-01-28 02:15:57.711 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Opening camera 1
2022-01-28 02:15:57.712 16235-18566/com.smartchurch D/com.oney.WebRTCModule.WebRTCModule: CameraEventsHandler.onCameraOpening: cameraName=1
2022-01-28 02:15:57.783 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Camera opened.
2022-01-28 02:15:57.818 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Camera capture session configured.
2022-01-28 02:15:57.821 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Stabilization not available.
2022-01-28 02:15:57.821 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Auto-focus is not available.
2022-01-28 02:15:57.842 16235-18566/com.smartchurch I/org.webrtc.Logging: Camera2Session: Camera device successfully started.
2022-01-28 02:15:57.842 16235-18566/com.smartchurch I/org.webrtc.Logging: CameraCapturer: Create session done. Switch state: IDLE
2022-01-28 02:15:57.843 16235-18566/com.smartchurch I/org.webrtc.Logging: SurfaceTextureHelper: Setting listener to org.webrtc.-$$Lambda$Camera2Session$CaptureSessionCallback$_XbqUL6ihfYRgME_EfDLZtLmkGA@397e855
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.116 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.119 16235-17824/com.smartchurch W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2022-01-28 02:15:58.141 16235-17823/com.smartchurch I/org.webrtc.Logging: NetworkMonitor: Start monitoring with native observer 485808076192
2022-01-28 02:15:58.149 16235-17823/com.smartchurch W/System.err: java.lang.SecurityException: ConnectivityService: Neither user 10236 nor current process has android.permission.ACCESS_NETWORK_STATE.
2022-01-28 02:15:58.149 16235-17823/com.smartchurch W/System.err: at android.os.Parcel.readException(Parcel.java:1693)
2022-01-28 02:15:58.149 16235-17823/com.smartchurch W/System.err: at android.os.Parcel.readException(Parcel.java:1646)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:1579)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:874)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at org.webrtc.NetworkMonitorAutoDetect$ConnectivityManagerDelegate.getNetworkState(NetworkMonitorAutoDetect.java:171)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at org.webrtc.NetworkMonitorAutoDetect.(NetworkMonitorAutoDetect.java:581)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at org.webrtc.NetworkMonitor$1.create(NetworkMonitor.java:50)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at org.webrtc.NetworkMonitor.createNetworkChangeDetector(NetworkMonitor.java:181)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at org.webrtc.NetworkMonitor.startMonitoring(NetworkMonitor.java:108)
2022-01-28 02:15:58.150 16235-17823/com.smartchurch W/System.err: at org.webrtc.NetworkMonitor.startMonitoring(NetworkMonitor.java:129)

There you go!

You might want to review the react-native-webrtc installation instructions for Android. https://github.com/react-native-webrtc/react-native-webrtc/blob/master/Documentation/AndroidInstallation.md

1 Like

Thanks so much for your time and effort,
They say This is not needed with React Native >= 0.60. on docs,
on that installation guide looks like i can just do npm install react-native-webrtc only
or am getting it wrong somewhere or i should do linking manually ?

See the part about “Declaring permissions”. This applies to all version of react-native.

1 Like

Thanks @jbaudanza , you’re the hero men!.. let me check that

1 Like

Thanks so much @jbaudanza it works on my part