react-native-webrtc: Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome.

I updated to version 1.92.0 from 1.89.1 (working on iOS) and I am getting following warning when I debug react-native app

index.bundle?platform=ios&dev=true&minify=false:48831 0 Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome.

 Consider providing alternative methods to expose this method in debug mode, e.g. by exposing constants ahead-of-time.
    at invariant (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:1899:17)
    at MessageQueue.callNativeSyncHook (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3030:11)
    at Object.nonPromiseMethodWrapper [as peerConnectionInit] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2724:32)
    at new RTCPeerConnection (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:109188:20)
    at getNativeRtpCapabilities$ (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:167274:22)
    at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26662:19)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26835:24)
    at Generator.next (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26705:23)
    at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26662:19)
    at invoke (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26735:22)

Expected behavior

I shouldn’t not be getting this warning.

Ps: It works fine if you aren’t debugging

What have I tried to fix it

  1. Removed node_modules and installed again
  2. Remove pods folder and podlock file
  3. npm reset cache

Platform information

  • React Native version: 0.62.2
  • Plugin version: 1.92.0
  • OS: Tested on iOS
  • OS version:

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Hi @irohitb,

Improving data channel communication cause this issue.

As there are not so important updates and not so significant improvements I would recommend you to downgrade to react-native-webrtc@1.89.1 for debugging. For production/staging it will work also, but if you want, you can have the latest version for production/staging and 1.89.1 for debugging,

Please do not follow random advice which tells you to downgrade. You may expose your users to security issues, we don’t support old releases.

Please provide a normal workable chrome debugging solution, then there will be no such advise. For debugging we have to use 1.89.1, but for prod I recommend to use latest. I still do not understand why this library require initial sync operations that is blocking debugging? Please fix it if you can do it or follow practical advise on random comments.

@8BallBomBom you can always have console.log for nothing.

I just created a new react-native project (v0.66.3) and still not Fixed. Downgrading to react-native-webrtc@1.89.1 worked for me. Thank you @Romick2005

This is supposed to be fixed in RN 0.66 https://github.com/facebook/react-native/issues/32197#issuecomment-926869783

We will try to confirm here when we update.