opentok / opentok-react-native

OpenTok React Native - a library for OpenTok iOS and Android SDKs
https://tokbox.com/
MIT License
210 stars 155 forks source link

OTPublisher videoTrack: false crashes the app on Android #652

Closed EdShel closed 6 months ago

EdShel commented 1 year ago

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

https://github.com/opentok/opentok-react-native/blob/9ff44bc8b4d050c00f3c460cec9564f62f476875/android/src/main/java/com/opentokreactnative/OTSessionManager.java#L179-L181

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 }} />
  5. Launch the app on Android
    yarn && yarn android
  6. 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

pietgk commented 12 months ago

Any feedback regarding this issue?