react-native-twilio-video-webrtc icon indicating copy to clipboard operation
react-native-twilio-video-webrtc copied to clipboard

TWVideoModule broken in RN Bridgeless mode

Open jjPlusPlus opened this issue 8 months ago • 9 comments

Issue Description

Using new React Native architecture breaks underlying Twilio video module. I am able to run this package for now by disabling the new architecture in my React Native project.

Steps to reproduce

  • Spin up a new Expo / React Native project. Expo v52+ and React Native v74+.
  • Install react-native-twilio-video-webrtc lib
  • follow configuration docs for Expo (add/configure expo-build-properties, run prebuild + development build, OR set up EAS.)
  • Configure example component from this repo (also get valid token from Twilio)
  • Run application

Expected behaviour

Example application should run; more specifically, twilioRef.current.connect({ accessToken: token}) should run without issue.

This should work with the "new architecture" for React Native enabled.

Actual behaviour

(NOBRIDGE) LOG [Error: TWVideoModule.connect(): Error while converting JavaScript argument 2 to Objective C type BOOL. Objective C type BOOL is unsupported.]

Environment

Node.js version: v20.0.0 React Native (version 0.76.7) built with Expo (version ^52.0.37) Prebuild + development build using Expo App Services

jjPlusPlus avatar Mar 30 '25 21:03 jjPlusPlus

Any solution for this yet ?

kdarwishTCE avatar Apr 10 '25 18:04 kdarwishTCE

I'm getting this as well.

gsbernstein avatar Apr 24 '25 05:04 gsbernstein

I'm also getting the same issue. Has anyone found a solution yet

avirageorge31 avatar Apr 24 '25 10:04 avirageorge31

Based off of this similar issue on a different package, I made a patch file for patch-package that seems to work.

react-native-twilio-video-webrtc+3.2.1.patch

I'll raise a PR as well.

gsbernstein avatar Apr 24 '25 19:04 gsbernstein

same issue

george-eucare avatar Jun 05 '25 02:06 george-eucare

twilio is also breaking on my end with the new architecture, but on android.

you guys are also facing the same issue?

Warning: Error: Expected ref to be a function, an object returned by React.createRef(), or undefined/null.

it had been working for months until I upgraded RN to 0.79.3 and new arch enabled.

if anyone found a solution / patch, that would be a life saver :)

pierroo avatar Jun 10 '25 10:06 pierroo

twilio is also breaking on my end with the new architecture, but on android.

you guys are also facing the same issue?

Warning: Error: Expected ref to be a function, an object returned by React.createRef(), or undefined/null.

it had been working for months until I upgraded RN to 0.79.3 and new arch enabled.

if anyone found a solution / patch, that would be a life saver :)

same error message on android, but it succeeded after I accepted camera and microphone permissions.

george-eucare avatar Jun 12 '25 07:06 george-eucare

Based off of this similar issue on a different package, I made a patch file for patch-package that seems to work.

react-native-twilio-video-webrtc+3.2.1.patch

I'll raise a PR as well.

This worked!

VasantHugar avatar Jun 17 '25 11:06 VasantHugar

Here's the Android Fix for the error Expected ref to be a function, an object returned by React.createRef(), or undefined/null

In file node_modules/react-native-twilio-video-webrtc/src/TwilioVideo.android.js Replace String Ref with React.createRef()

Here’s final code:

class CustomTwilioVideoView extends Component {
  constructor(props) {
    super(props);
    this.videoViewRef = React.createRef(); // Create a ref using React.createRef()
  }

  runCommand(event, args) {
    switch (Platform.OS) {
      case "android":
        if (this.videoViewRef.current) {
          UIManager.dispatchViewManagerCommand(
            findNodeHandle(this.videoViewRef.current),
            event,
            args
          );
        } else {
          console.error("VideoView ref is null");
        }
        break;
      default:
        break;
    }
  }

  render() {
    return (
      <NativeCustomTwilioVideoView
        ref={this.videoViewRef} // Assign the ref object
        {...this.props}
        {...this.buildNativeEventWrappers()}
      />
    );
  }
}

VasantHugar avatar Jun 17 '25 12:06 VasantHugar

Here's the Android Fix for the error Expected ref to be a function, an object returned by React.createRef(), or undefined/null

In file node_modules/react-native-twilio-video-webrtc/src/TwilioVideo.android.js Replace String Ref with React.createRef()

Here’s final code:

class CustomTwilioVideoView extends Component { constructor(props) { super(props); this.videoViewRef = React.createRef(); // Create a ref using React.createRef() }

runCommand(event, args) { switch (Platform.OS) { case "android": if (this.videoViewRef.current) { UIManager.dispatchViewManagerCommand( findNodeHandle(this.videoViewRef.current), event, args ); } else { console.error("VideoView ref is null"); } break; default: break; } }

render() { return ( <NativeCustomTwilioVideoView ref={this.videoViewRef} // Assign the ref object {...this.props} {...this.buildNativeEventWrappers()} /> ); } }

This works for Android perfectly.

WarraichUmer95 avatar Jul 31 '25 12:07 WarraichUmer95