In our custom React Native app, we noticed that our app is not able to connect to our Custom Receiver. Our implementation on our dev website with Bitmovin works well with the custom receiver so the receiver itself appears to be fully functional.
To test this further I downloaded and bundled the example app, firstly with no changes. I was able to cast to my Chromecast with no issues - and the description “CAF Receiver v3 - Stable” appears.
After modifying the code, rebundling and deploying the app, and doing a reset of the Chromecast for good measure, the casted video still only can access the default Bitmovin receiver.
** Reproduction Steps **
Create a clean build of the example app (tested hash is 55c2f5bd0488843aee587c4ca89f25cd57e8eff5)
Hi @ben1,
looking into the lifecycle of the react native wrapper it appears to have an issue around the cast manager initialization timing - it might be too late to call it where it is currently being called.
in the MainApplication.kt native code and see if that works around the issue? Your may have to change the gradle dependency of the com.bitmovin.player:player to api in the bitmovin-player-react-native/android/build.gradle
Thanks for the quick reply. This is a bit beyond my current capabilities. I can’t resolve BitmovinCastManager in the kotlin code - it appears to be in the com.bitmovin.player.casting package but I can’t find any references to that, is there a particular import that I’m not seeing?
Given your feedback, it sounds like the initalize() method is timed poorly in the Casting.tsx sample file. I can see how if that method does not complete, the custom receiver cannot be used.
Theoretically, can’t this be solved by adding an await to the initialize() call? Sure, it will affect performance a little bit, but if it is needed for a custom receiver, I’m ok with that.
However, doing this as a test (and not changing anything else, the application crashes with the following error:
ERROR Error: Objects are not valid as a React child (found: object with keys {_h, _i, _j, _k}). If you meant to render a collection of children, use an array instead.
This error is located at:
in Casting (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by SceneView)
in RCTView (created by View)
in View (created by DebugContainer)
in DebugContainer (created by MaybeNestedStack)
in MaybeNestedStack (created by SceneView)
in RCTView (created by View)
in View (created by SceneView)
in RNSScreen
in Unknown (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by SceneView)
in SceneView (created by NativeStackViewInner)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by ScreenStack)
in RNSScreenStack (created by ScreenStack)
in ScreenStack (created by NativeStackViewInner)
in NativeStackViewInner (created by NativeStackView)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by NativeStackView)
in NativeStackView (created by NativeStackNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by NativeStackNavigator)
in NativeStackNavigator (created by App)
in EnsureSingleNavigator
in BaseNavigationContainer
in ThemeProvider
in NavigationContainerInner (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in BitmovinPlayerReactNativeExample(RootComponent), js engine: hermes
What are your thoughts? Could this error potentially also be the reason why the async call isn’t working?
This seems like a relatively serious issue for anyone hoping to use a custom receiver from the React Native app.
That’s great news, thank you for the update. I tested your workaround on the example app and it worked, which is great. I suspect you are already on top of the issue, but if it’s helpful I also conducted my own investigation looking at the debug logs and it appears that the Chromecast code already starts looking for the receiver with the default ID before reaching the React code which defines the initialization step with the custom receiver id.
I’ll go ahead and push this workaround into my real application and give it a shot. Please do feel free to reach out when the library has the bug fix applied.