ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
124 stars 111 forks source link

Runtime Errors on both iOS and Android #295

Closed LiamInJapan closed 1 year ago

LiamInJapan commented 2 years ago

Hi Connectycube!

We're super grateful for your hard work on this. Unfortunately we've been having quite a hard time getting all parts of this working on both platforms via react native. We have already had some exchange by email regarding this issue, and have taken the advice of:

1) Upgrading connectycube npm 2) Removing react-native-webrtc 3) Downloading the bitcode version of webrtc

We've had quite a few problems with step 3. Basically we inherited this code-base from another company and I have a feeling they were using some old/incompatible versions between react/connectycube/webrtc which is getting us into this funk, and as we're coming in half-way, it's proving quite difficult to solve.

We received the project at "react-native-connectycube": "^3.7.8" and with guidance over the support email we changed this to "react-native-connectycube": "^3.10.0" and removed react-native-webrtc

A small problem with this is that the advice in 2 and 3 is a little contradictory! The reason for this is the script to download the bitcode version of webrtc first of all contains a link to a non-existant file. Secondly, if we remove react-native-webrtc we also remove this script!

However we managed to solve this by incorporating this script into our build process independent of react-native-webrtc as well as pointing it to a valid webrtc.tar.gz link (we are using this page and this tar. We also tried this tar with the same result)

Now it seems we can get the project to build and I think its using this bitcode version, and we can also remove react-native-webrtc from the package.json

The problem now is that the call functionality still doesn't work on either iOS or Android at real-time.

On iOS, we get a react-native error before we even get to the users screen:

IMG_6998

(I'm attaching the xcode logs too as that might give more insight. It seems that it is communicating with Connectycube because I can see the user list allLogs.log)

On Android we manage to get to the user-list screen, but then we get this warning and the call doesn't work:

XRecorder_17042022_152641 1

In any case, we're starting to get to the end of our ideas for what this might be. It would be massively appreciated if you could give us some advice on how to proceed with this!

LiamInJapan commented 2 years ago

The other thing we have tried is reverting back to a state earlier in the project that the calls were working. Let me share this state with you:

"react-native-connectycube": "3.7.8", "react-native-webrtc": "^1.84.1" < include this - it wasn't included in the above case

Set all bitcode settings to NO

When we roll right back to that point in the project, the calling works... But when we integrate these changes into our newest commit, it doesn't with the following errors on the caller and receiver:

IMG_0115 IMG_7008

(We can open the call screen, we just can't make the calls. The error happens on the outgoing call device at the point of making the call, the warning appears on the receiver at the point that the caller cancels the (unsuccessful) call

LiamInJapan commented 2 years ago

Note actually in relation to that last comment if I do a complete reclean, npm install and pod install it works.

However the calls only work when the video screen is open. If it's not, I can hear the call come through, but I can't see the incoming call popup. I also get this warning on the receivers side:

IMG_0116

Any insight would be greatly appreciated!

DaveLomber commented 2 years ago

@LiamInJapan

first of all, please ignore ConnectyCube fork of WebRTC lib

we always use the original one, e.g. this https://github.com/react-native-webrtc/react-native-webrtc/blob/master/tools/downloadBitcode.sh

Here is how the overall configuration looks like:

package.json

{
  "name": "com.myapp",
  "version": "1.0",
  "scripts": {
    "postinstall": "run-script-os && npx jetify",
    "postinstall:nix": "npx jetify",
    "postinstall:darwin": "cd ios && pod install &&  sh ../node_modules/react-native-webrtc/tools/downloadBitcode.sh",

    "dependencies": {
       "react-native-connectycube": "^3.17.0",  
        ...
    }

    ...
}

ios/Podfile

...

  pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'

All the above configuration hints were taken from https://github.com/react-native-webrtc/react-native-webrtc/tree/master/Documentation

So it's more about proper configuration

Anyway I see it's solved here https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/295#issuecomment-1102743932

LiamInJapan commented 2 years ago

I'm afraid it's still broken. In fact, rolling back to a earlier commit where it was working is now broken...

Our dev Reegesh (dizzy-why) is going to share his findings shortly.

dizzy-why commented 2 years ago

Here is our Package.json , AndroidManifest.xml and settings.gradle snapshot package-jsonfile-1 package-jsonfile-2 manifest1 manifest2 settings-gradle-file [

dizzy-why commented 2 years ago

The problem were are having currently is with Android build. IOS build works fine with above suggestion. Currently what we get on console log whenever we try to initiate a call on android build we get following warning and cannot connect to call.

TypeError: Cannot read property 'enumerateDevices' of null TypeError: Cannot read property 'enumerateDevices' of null at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:123246:47) at tryCallTwo (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27700:9) at doResolve (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27864:25) at Promise (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27723:14) at enumerateDevices (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:123245:27) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:128261:42) at tryCallTwo (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27700:9) at doResolve (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27864:25) at Promise (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27723:14) at getMediaDevices (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:128257:27) at setMediaDevices (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:260584:74) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:260482:30) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:262512:42) at _performTransitionSideEffects (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:56202:22) at _receiveSignal (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:56144:45) at onResponderRelease (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:56053:34) at apply (native) at invokeGuardedCallbackImpl (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:9811:21) at apply (native) at invokeGuardedCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:9905:42) at apply (native) at invokeGuardedCallbackAndCatchFirstError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:9909:36) at executeDispatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:9981:48) at executeDispatchesInOrder (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:10001:26) at executeDispatchesAndRelease (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11076:35) at executeDispatchesAndReleaseTopLevel (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11085:43) at forEach (native) at forEachAccumulated (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:10143:22) at runEventsInBatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11100:27) at runExtractedPluginEventsInBatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11179:25) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11155:42) at batchedUpdates$1 (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21804:20) at batchedUpdates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11062:36) at _receiveRootNodeIDEvent (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11154:23) at receiveTouches (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:11207:34) at apply (native) at callFunction (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3371:36) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3103:31) at guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3325:15) at callFunctionReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3102:21) [Wed May 04 2022 12:18:34.775] WARN Possible Unhandled Promise Rejection (id: 1): TypeError: Cannot read property 'getUserMedia' of null TypeError: Cannot read property 'getUserMedia' of null at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:123445:34) at tryCallOne (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27691:16) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27792:27) at apply (native) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31343:26) at _callTimer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31231:17) at _callImmediatesPass (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31270:17) at callImmediates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31487:33) at callImmediates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3342:35) at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3128:34) at guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3325:15) at flushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3127:21) at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3120:33) XRecorder_05052022_133442 XRecorder_05052022_133504

DaveLomber commented 2 years ago

ok this is very strange

I suggest to do the following

1) can you go into node_modules/react-native-connectycube/lib/cubeDependencies.js and put the following logs:

try {
  ReactNativeWebRTC = require('react-native-webrtc')
  console.log("connect react-native-webrtc OK")
} catch(e) {
 console.log("connect react-native-webrtc Error", e)
  ReactNativeWebRTC = {};
}

Also

2) can you go into node_modules/react-native-connectycube/lib/cubeInternalUtils.js and put the following logs:

static isRNWebRTCAvailble() {
    console.log("IS_RN_ENV", IS_RN_ENV)

    if (IS_RN_ENV && typeof Expo === 'undefined') {
      const {
        RTCView,
        RTCPeerConnection,
        RTCIceCandidate,
        RTCSessionDescription,
        MediaStream, 
        mediaDevices
      } = require('./cubeDependencies')

    console.log("isRNWebRTCAvailble", RTCView && RTCPeerConnection && RTCIceCandidate && RTCSessionDescription && MediaStream && mediaDevices)

      return RTCView && RTCPeerConnection && RTCIceCandidate && RTCSessionDescription && MediaStream && mediaDevices
    }

    return false;
  }

so we could get more info what's going on there

Thank you

LiamInJapan commented 2 years ago

console log

[Mon May 09 2022 21:43:26.358]  LOG      IS_RN_ENV true
[Mon May 09 2022 21:43:26.364]  LOG      connect react-native-webrtc OK
[Mon May 09 2022 21:43:26.365]  LOG      isRNWebRTCAvailble {}
[Mon May 09 2022 21:43:26.366]  DEBUG    [bugsnag] Loaded!
[Mon May 09 2022 21:43:26.367]  LOG      Running "main" with {"rootTag":21}
[Mon May 09 2022 21:43:27.574]  LOG      IS_RN_ENV true
[Mon May 09 2022 21:43:27.613]  LOG      isRNWebRTCAvailble {}
[Mon May 09 2022 21:43:31.816]  LOG      [enable][stream]
LiamInJapan commented 2 years ago

@DaveLomber Is there any more on this issue please? It's really blocking us from finalising a project and getting it released

DaveLomber commented 2 years ago

@LiamInJapan according to this log https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/295#issuecomment-1121051850 everything is connected properly

Could you do 2 things:

1) make sure you use Calls API after ConnectyCube.init and chat connect is done 2) please share the code snippet everything related to calls, we will review

DaveLomber commented 2 years ago

@LiamInJapan please contact at support@connectycube.com it might be easier to jump on a call and resolve it