OpenVidu / openvidu

OpenVidu Platform main repository
https://openvidu.io
Apache License 2.0
1.86k stars 464 forks source link

openvidu-browser: streamPropertyChanged for reason 'deviceRotated' not emitted on iOS #802

Closed semmel closed 1 year ago

semmel commented 1 year ago

Describe the bug When publishing my own video stream, no streamPropertyChanged events are emitted when the iOS device is rotated.

Expected behavior When changing the orientation of the iOS device a streamPropertyChanged event with reason='deviceRotated' and property='videoDimensions' should be emitted.

Wrong current behavior The onOrientationChanged handler calls the method Publisher.getVideoDimensions() which throws in the line document.body.removeChild(this.videoReference). Thus, OpenVidu.sendNewVideoDimensionsIfRequired() cannot continue to call OpenVidu.sendVideoDimensionsChangedEvent().

OpenVidu tutorial where to replicate the error

  1. Any HTML page with a button, a video element and openvidu-browser v2.21–v2.27:
    <video autoplay playsinline muted></video>
    <button type="button">Get Cam</button>
    <script src="../node_modules/openvidu-browser/static/js/openvidu-browser-2.27.0.js"></script>
  2. Create your own MediaStreamTrack with kind = 'video' and attach to <video>
    button.addEventListener('click', () => {
    navigator.mediaDevices.getUserMedia({video: true})
    .then(mediaStream => {
         videoElement.srcObject = mediaStream;
         localVideoTrack = mediaStream.getVideoTracks()[0];
    })
    })
  3. Connect Safari Developer Tools
  4. Acquire MediaStream from the webcam by tapping <button>
  5. Execute the usual workflow to publish the video
    1. var OV = new OpenVidu();
    2. var session = OV.initSession();
    3. var publisher = await OV.initPublisherAsync(null, {audioSource: false, videoSource: localVideoTrack});
    4. var token = await getAccessToken(); // <-- fetch from your server
    5. await session.connect(token);
    6. session.publish(publisher);
  6. Rotate the device
  7. Observe the exception "Unhandled Promise Rejection: NotFoundError: The object can not be found here." - Publisher.ts line 723 in the DevTools console

OpenVidu deployment info

Client device info (if applicable)

Additional context

795 might be a related issue