Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OTSubscriberView, OTPublishderView layout issue on iOS #530

Open
wants to merge 2 commits into
base: 0.18.1
Choose a base branch
from

Conversation

DmitryTop
Copy link

@DmitryTop DmitryTop commented Jul 23, 2021

OTSubscriberView and OTPublisherView fail to layout properly on iOS. In my case layoutSubviews is called only once when the view has incorrect bounds (which are managed by React Native) with height = 0.

@abdulajet
Copy link
Contributor

Can you share screenshots? Not sure what you mean by doesn't layout properly

@DmitryTop
Copy link
Author

There is nothing on the screen since the subscriber view height is 0. layoutSubviews is called only once in my case when React Native hadn't applied correct sizes yet.
I've made a fix to autoresize publisher and subscriber views so it will always match the view which is managed by React Native. With this fix everything works fine in my case.

@abdulajet
Copy link
Contributor

There is nothing on the screen since the subscriber view height is 0.

I haven't seen this behavior before. The sample apps work fine, can you share your React Native code?

@enricop89
Copy link
Contributor

@abdulajet using BasicVideoChat example, I am able to reproduce the issue by setting style={StyleSheet.absoluteFill} on the OTSubscriber object.

import {View, StyleSheet} from 'react-native';

render() {
    return (
      <View
        style={{
          flex: 1,
          flexDirection: 'column',
          paddingHorizontal: 100,
          paddingVertical: 50,
        }}>
        <OTSession
          apiKey={this.apiKey}
          sessionId={this.sessionId}
          token={this.token}>
          <OTSubscriber style={StyleSheet.absoluteFill} />
        </OTSession>
      </View>
    );
  }

@DmitryTop for the Android issue, can you try by setting:

const sessionOptions = {
    androidOnTop: 'publisher',
    androidZOrder: 'onTop',
    useTextureViews: true,
  };

Documentation here: https://github.com/opentok/opentok-react-native/blob/main/docs/OTSession.md#setting-session-options

@DmitryTop
Copy link
Author

Setting sessionOptions on Android didn't help (with and without texture views). There is a similar problem as on iOS - OTSubscriberLayout has zero height:

Parent ReactViewGroup
width: 1080 (WRAP_CONTENT)
height: 2296 (WRAP_CONTENT)

OTSubscriberLayout
width: 1080 (WRAP_CONTENT)
height: 0 (WRAP_CONTENT)

FrameLayout
width: 1080 (MATCH_PARENT)
height: 0 (MATCH_PARENT)

GLSurfaceView
width: 1080 (MATCH_PARENT)
height: 0 (MATCH_PARENT)

@abdulajet
Copy link
Contributor

I am not too knowledgable with JS/React but wouldnt you provide the size in JS? <OTPublisher style={{ width: 200, height: 200 }} />

@DmitryTop
Copy link
Author

Setting style={{ width: 200, height: 200 }} does not work in my case. I have a complex view hierarchy in the project. On the other hand I can reproduce the issue in the opentok-sample by setting style={StyleSheet.absoluteFill}. Can you please fix this ASAP?

BTW I am using the same view structure for Twilio and for Vonage. Twlio works, Vonage does not. You can check Twlio plugin implementation here https://github.com/actio-tech/react-native-twilio-video-webrtc (it's a fork of https://github.com/blackuy/react-native-twilio-video-webrtc)

@enricop89 enricop89 changed the base branch from main to 0.18.1 August 9, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants