opentok/opentok-react-native

OTPublisher videoTrack: false crashes the app on Android

EdShel opened this issue · 1 comments

Bug Report

Current behavior
After upgrading from v0.20.0 to 0.21.2 (the latest version by now) our app started crashing due to a Java exception when disabling video subsystem using the following prop of OTPublisher:

properties={{ videoTrack: false }} 

The exception message says

Content hint can only be set after constructing the Publisher and Capturer.

The issue is probably related to this new code

if (mPublisher.getCapturer() != null) {
mPublisher.getCapturer().setVideoContentHint(Utils.convertVideoContentHint(properties.getString("videoContentHint")));
}

By now, the workaround for us is to check for videoTrack being true before setting video hint:

if (mPublisher.getCapturer() != null && videoTrack) {
   mPublisher.getCapturer().setVideoContentHint(Utils.convertVideoContentHint(properties.getString("videoContentHint")));
}

Steps to reproduce

  1. Clone sample apps Github repository
  2. Go to BasicVideoChat project
  3. Inside App.js provide API key, session id, token
  4. Add properties={{ videoTrack: false }} to OTPublisher. The element should look like this:
<OTPublisher style={{ width: 200, height: 200 }} properties={{ videoTrack: false }} />
  1. Launch the app on Android
yarn && yarn android
  1. You'll immediately get crash (see the screenshot below).

Example Project
Reproduced in the sample apps

What is the current bug behavior?
videoTrack property is basically useless now and breaks old code.

What is the expected correct behavior?
The app shouldn't crash when setting videoTrack to false.

Relevant logs and/or screenshots
Screenshot_1677580460