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

TypeError: null is not an object 2 times - evaluating 'WebRTCModule.enumerateDevices' and evaluating 'WebRTCModule.getUserMedia' #274

Closed rexcode closed 2 years ago

rexcode commented 2 years ago

error 1 - TypeError: null is not an object (evaluating 'WebRTCModule.enumerateDevices')

error 2 - Possible Unhandled Promise Rejection (id: 4): TypeError: null is not an object (evaluating 'WebRTCModule.getUserMedia')

When I start call I get the above 2 errors

app packages used - "react-native": "0.63.2", "react-native-connectycube": "^3.12.0"

I already have done ConnectyCube.init and ConnectyCube.createSession method calls before starting the call

my session object - from - ConnectyCube.videochat.createNewSession(ids, type, options) {"ID": "0eca5070-0654-43eb-a85b-48af78573ffb", "acceptCallTime": 0, "answerTimer": null, "bandwidth": 256, "callType": 1, "currentUserID": 4815200, "initiatorID": 4815200, "localStream": null, "mediaParams": null, "onCallStatsReport": undefined, "onRemoteStreamListener": [Function anonymous], "onSessionCloseListener": undefined, "onSessionConnectionStateChangedListener": undefined, "onUserNotAnswerListener": [Function anonymous], "opponentsIDs": [4815195], "peerConnections": {}, "signalingProvider": {"signalingConnection": {"Parser": [Function FramedParser], "Socket": [Function Socket], "Transport": [Function ConnectionWebSocket], "_events": [Object], "_eventsCount": 10, "_maxListeners": undefined, "connect": [Function connect], "entity": [Circular], "hookOutgoing": [Function anonymous], "iqCallee": [Object], "iqCaller": [IQCaller], "jid": [JID], "mechanisms": [Array], "middleware": [Object], "options": [Object], "parser": [FramedParser], "parserListeners": [Object], "reconnect": [Reconnect], "resolve": undefined, "resourceBinding": undefined, "root": [Element], "sasl": [Object], "sessionEstablishment": undefined, "socket": [Socket], "socketListeners": [Object], "status": "online", "streamFeatures": [Object], "timeout": 2000, "transports": [Array], "websocket": undefined}}, "startCallTime": 0, "state": 1}

Please guide

ccvlad commented 2 years ago

WebRTCModule is unavailable. Did you complete installation for Android/iOS by the React Native WebRTC guide?

rexcode commented 2 years ago

I have already installed react-native-connectycube so react-native-webrtc is already installed as a dependency correct ? or I have to install this separately ?

ccvlad commented 2 years ago

The RN WebRTC included as NPM module. But you should configure RN WebRTC for Android and iOS projects Guides:

rexcode commented 2 years ago

I have done changes in configuration for Android - as given in the above link

image

I have made all changes for manual installation -

  1. changes in settings.gradle
  2. android/app/build.gradle
  3. added missing permissions in androidmanifest.xml

But how I do make changes for MainApplicaiton.java as code there is different from what is given in instructions I do not understand Java

image

I have made the above stated 3 changes and tested again - still getting same 2 errors TypeError: null is not an object 2 times - evaluating 'WebRTCModule.enumerateDevices' and evaluating 'WebRTCModule.getUserMedia'

Please guide

ccvlad commented 2 years ago

Like as in example - packages.add(new WebRTCModulePackage())

Снимок экрана 2021-09-30 в 11 13 55
rexcode commented 2 years ago

Hi, thanks for your quick reply

I have made change as given by you and added packages.add(new WebRTCModulePackage());

I have also added - packages.add(new com.oney.WebRTCModule.WebRTCModulePackage()); as inferred from react-native-webrtc documentation - shown below

image

but both times app build failed for first-line as given by you - the app does not build at all for second-line - my changes - app builds built fails on open and just crashes

my changes - commented out image

Please guide do I need to install webrtc package manually again?

app packages used - "react-native": "0.63.2", "react-native-connectycube": "^3.12.0"

ccvlad commented 2 years ago

Add import com.oney.WebRTCModule.WebRTCModulePackage; at the top of MainApplicaiton.java file and use packages.add(new WebRTCModulePackage()).

Please try this.

Do you have some logs in Metro's console?

rexcode commented 2 years ago

I have made changes in MainApplication.java as you have given, app is building now but crashes on opening

image

-------------------------------package details----------------------------------------------------- react-native-picker - is already installed as a separate dependency "@react-native-picker/picker": "^1.9.10",

packages for background task "react-native-background-task": "^0.2.1", "react-native-background-timer": "^2.4.1",

"react-native-push-notification": "^8.1.0",


-------------------------------server console log-----------------------------------------------------

warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB. info Reloading app... [Thu Sep 30 2021 16:56:35.824] BUNDLE ./index.js

[Thu Sep 30 2021 16:56:42.801] BUNDLE ./index.js

[Thu Sep 30 2021 16:56:50.709] BUNDLE ./index.js

[Thu Sep 30 2021 16:56:54.619] ERROR Warning: Picker has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/picker' instead of 'react-native'. See https://github.com/react-native-community/react-native-picker [Thu Sep 30 2021 16:56:54.620] WARN Require cycle: node_modules\react-native-maps\lib\components\MapView.js -> node_modules\react-native-maps\lib\components\MapPolygon.js -> node_modules\react-native-maps\lib\components\MapView.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. [Thu Sep 30 2021 16:56:54.620] WARN Require cycle: node_modules\react-native-maps\lib\components\MapView.js -> node_modules\react-native-maps\lib\components\Geojson.js -> node_modules\react-native-maps\lib\components\MapView.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. [Thu Sep 30 2021 16:56:54.623] WARN console.disableYellowBox has been deprecated and will be removed in a future release. Please use LogBox.ignoreAllLogs(value) instead.[Thu Sep 30 2021 16:56:54.623] WARN Require cycle: node_modules\rn-fetch-blob\index.js -> node_modules\rn-fetch-blob\polyfill\index.js -> node_modules\rn-fetch-blob\polyfill\Blob.js -> node_modules\rn-fetch-blob\index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. [Thu Sep 30 2021 16:56:54.624] WARN Require cycle: node_modules\rn-fetch-blob\index.js -> node_modules\rn-fetch-blob\polyfill\index.js -> node_modules\rn-fetch-blob\polyfill\XMLHttpRequest.js -> node_modules\rn-fetch-blob\index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. [Thu Sep 30 2021 16:56:54.634] WARN Require cycle: node_modules\rn-fetch-blob\index.js -> node_modules\rn-fetch-blob\polyfill\index.js -> node_modules\rn-fetch-blob\polyfill\Fetch.js -> node_modules\rn-fetch-blob\index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. [Thu Sep 30 2021 16:56:54.635] LOG Running "pdmc" with {"rootTag":1} [Thu Sep 30 2021 16:56:54.636] LOG promptForPushNotificationsWithUserResponse: this function is not supported on Android [Thu Sep 30 2021 16:56:54.636] LOG ------------HOST set ---------- null [Thu Sep 30 2021 16:56:54.636] LOG TOKEN: {"os": "android", "token": "cXgdwha0SyuLsa_CHlpNOq:APA91bFPP_I6XDZYmeBBbGv6J5QZAUxQ38BZFKLcxilfg8DyNHM4KIYbrLFNUvXwiwII4ag1KlmlO2sl_vx6j_LSPOaudDHopGh_Unf0fPVQ33-oX2AmS44W4A6Em6lzsxN_b5KTAGN0"} [Thu Sep 30 2021 16:56:54.637] ERROR Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. in NavigationContainer (at src/index.js:239) in Provider (at src/index.js:238) in RCTView (at View.js:34) in View (at Root.js:14) in Root (at connectStyle.js:392) in Styled(Root) (at src/index.js:237) in App (at renderApplication.js:45) in RCTView (at View.js:34) in View (at AppContainer.js:106) in RCTView (at View.js:34) in View (at AppContainer.js:132) in AppContainer (at renderApplication.js:39)

image

Please guide

ccvlad commented 2 years ago

There isn't crash info. Could you check logs via AndroidStudio?

  1. Open AndroidStudio
  2. Create or select any simple project
  3. Choose 'Logcat'
  4. Select your Android device
  5. Select app
Снимок экрана 2021-09-30 в 15 39 14
rexcode commented 2 years ago

Hi there,

searching logcat as instructed, was able to find this error

--------- beginning of crash

FATAL EXCEPTION: pool-13-thread-1 java.lang.NoSuchMethodError: No static method createEgl14([I)Lorg/webrtc/EglBase14; in class Lorg/webrtc/EglBase; or its super classes (declaration of 'org.webrtc.EglBase' appears in......................DftwlkWzOf87J3tpWGchSA==/base.apk!classes4.dex) at com.oney.WebRTCModule.EglUtils.getRootEglBase(EglUtils.java:35) at com.oney.WebRTCModule.EglUtils.getRootEglBaseContext(EglUtils.java:62) at com.oney.WebRTCModule.WebRTCModule.initAsync(WebRTCModule.java:114) at com.oney.WebRTCModule.WebRTCModule.lambda$new$0$WebRTCModule(WebRTCModule.java:84) at com.oney.WebRTCModule.-$$Lambda$WebRTCModule$CnyHZvkjDxq52UReGHUZlY0JsVw.run(Unknown Source:4) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)

have solved the issue by adding below line in android/gradle.properties

image

Thanks for all your help

ccvlad commented 2 years ago

Great! Thanks for the feedback

ccvlad commented 2 years ago

Closed due to inactivity. Please create a new issue if needed.