Skip to content

Commit

Permalink
Prep release 2.21.2 (#1792)
Browse files Browse the repository at this point in the history
* Merge Preflight and PlanB removal feature branch (#1702)

* VIDEO-7728 | Better Preflight Errors (#1689)

* Adding better errors on preflight

* lint

* Update docs

* Changelog

* Update docs

* Convert error to string

* Adding timestamp to progress events

* Properly raising signaling errors

* lint

* Update tests

* Mak's feedback

* Update test

* Feature/remove plan b (#1697)

* VIDEO-6587 | Remove Plan B in SDK (#1656)

* Initial implementation.

* Fixing integration tests

* Updating unit tests

* Adding back unit test job

* Removing unneeded case

* Fix build

* Adding rename suggestion

Co-authored-by: Manjesh Malavalli <[email protected]>

* Adding changelog

* Update CHANGELOG.md

Co-authored-by: Manjesh Malavalli <[email protected]>

* Adding ticket number

Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: Manjesh Malavalli <[email protected]>

* Move changelog to 2.20.0 section

* 2.20.0-rc1

* 2.20.0-dev

Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: twilio-ci <[email protected]>

* Fix unit test from merge

* 2.20.0-rc2

* 2.20.0-dev

* Update doc

* Update changelog

Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: twilio-ci <[email protected]>

* Removing framework tests (#1700)

* Convert createLocalTracks to TS (#1694)

* VIDEO-7714 - Convert createLocalTracks to TypeScript

Co-authored-by: joma <[email protected]>
Co-authored-by: charliesantos <[email protected]>

* Update @twilio/webrtc to 4.6.0-rc1 (#1705)

* Update @twilio-webrtc to RC

Co-authored-by: joma <[email protected]>

* 2.21.0-rc1

* 2.21.0-dev

* merge from master

* VIDEO-8791 - Adding extra information into CHANGELOG (#1716)

* Adding extra information into CHANGELOG

* 2.21.0-rc2

* 2.21.0-dev

* VIDEO-8647 - Fixing Chrome Docker Image (#1718)

* VIDEO-8647 Fixing docker images build for Chrome

* VIDEO-8954: Adding in extra links and details to the CHANGELOG entry (#1722)

* VIDEO-8954 - Adding in extra links and details to the CHANGELOG entry

* VIDEO-8647 - Fixing Chrome Docker Image (#1718) (#1721) (#1728)

* VIDEO-8647 Fixing docker images build for Chrome

* VIDEO-8939 - Migrating twilio/webrtc (#1731)

* VIDEO-8939 - Folding twilio/webrtc into SDK, installing util and events packages.

* Prep for 2.21.1 RC (#1739)

* Adding CHANGELOG entry for 2.21.1 RC

* 2.21.1-rc1

* 2.21.1-dev

* Marking unstable integration tests (#1740)

* Marking unstable integration tests

* merge from master (#1745)

* VIDEO-9511 - do not configure encodings for stopped tracks (#1768)

* do not update encodings for stopped tracks

* Emit dimensionsChanged event on videoTrack start

* Add test for videoTrack _start method

* Add changelog entry for VIDEO-3576

* VIDEO-9282 - Migrate SDK from using node.js util. (#1752)

* VIDEO-9282 - Removing all references to node dependencies.

Co-authored-by: Makarand Patwardhan <[email protected]>

* 2.21.2-rc1

* 2.21.2-dev

* VIDEO-8282 - Adding iPad Detection (#1779)

* VIDEO-8282 - Adding iPad and iPhone detection logic

* 2.21.2-rc2

* 2.21.2-dev

* Prep for 2.21.2 release, updating changelog

Co-authored-by: Charlemagne Santos <[email protected]>
Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: Manjesh Malavalli <[email protected]>
Co-authored-by: twilio-ci <[email protected]>
Co-authored-by: Makarand Patwardhan <[email protected]>
Co-authored-by: Tim Mendoza <[email protected]>
Co-authored-by: timmydoza <[email protected]>
  • Loading branch information
8 people authored Jun 1, 2022
1 parent 352ebf3 commit ad2cede
Show file tree
Hide file tree
Showing 31 changed files with 688 additions and 162 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
"SharedArrayBuffer": "readonly",
"globalThis": false
},
"parserOptions": {
"ecmaVersion": 2018,
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ The Twilio Programmable Video SDKs use [Semantic Versioning](http://www.semver.o

**Version 1.x reached End of Life on September 8th, 2021.** See the changelog entry [here](https://www.twilio.com/changelog/end-of-life-complete-for-unsupported-versions-of-the-programmable-video-sdk). Support for the 1.x version ended on December 4th, 2020.

2.21.2 (June 1, 2022)
=====================

Bug Fixes
---------

- Fixed an issue where some extraneous errors were logged to console when a video track was stopped. (VIDEO-9511)
- Fixed an issue where the `dimensionsChanged` event was not firing when the track dimensions first became available. (VIDEO-3576)
- Removed references to node dependencies that causes build errors on Angular and Vue. (VIDEO-9282)
- Fixed an issue where incorrect device was detected when using iPad in Desktop Website mode. (VIDEO-8282)

2.21.1 (March 22, 2022)
=======================

Expand Down
3 changes: 1 addition & 2 deletions lib/media/track/es5/localaudiotrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// only in place so that we can support ES6 classes without requiring `new`.
'use strict';

const { inherits } = require('util');

const inherits = require('../../../vendor/inherits');
const LocalAudioTrackClass = require('../localaudiotrack');

function LocalAudioTrack(mediaStreamTrack, options) {
Expand Down
2 changes: 1 addition & 1 deletion lib/media/track/es5/localdatatrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// only in place so that we can support ES6 classes without requiring `new`.
'use strict';

const { inherits } = require('util');
const inherits = require('../../../vendor/inherits');

const LocalDataTrackClass = require('../localdatatrack');

Expand Down
2 changes: 1 addition & 1 deletion lib/media/track/es5/localvideotrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// only in place so that we can support ES6 classes without requiring `new`.
'use strict';

const { inherits } = require('util');
const inherits = require('../../../vendor/inherits');

const LocalVideoTrackClass = require('../localvideotrack');

Expand Down
1 change: 1 addition & 0 deletions lib/media/track/videotrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class VideoTrack extends MediaTrack {
this.dimensions.height = dummyEl.videoHeight;

this._log.debug('Dimensions:', this.dimensions);
this.emit(VideoTrack.DIMENSIONS_CHANGED, this);
return super._start.call(this, dummyEl);
}

Expand Down
12 changes: 6 additions & 6 deletions lib/signaling/v2/peerconnection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const DefaultBackoff = require('backoff');

const DefaultBackoff = require('../../util/backoff');
const {
RTCIceCandidate: DefaultRTCIceCandidate,
RTCPeerConnection: DefaultRTCPeerConnection,
Expand Down Expand Up @@ -191,7 +190,8 @@ class PeerConnectionV2 extends StateMachine {
false)
},
_iceRestartBackoff: {
value: options.Backoff.exponential(iceRestartBackoffConfig)
// eslint-disable-next-line new-cap
value: new options.Backoff(iceRestartBackoffConfig)
},
_instanceId: {
value: ++nInstances
Expand Down Expand Up @@ -377,7 +377,6 @@ class PeerConnectionV2 extends StateMachine {
peerConnection.addEventListener('icegatheringstatechange', this._handleIceGatheringStateChange.bind(this));
peerConnection.addEventListener('signalingstatechange', this._handleSignalingStateChange.bind(this));
peerConnection.addEventListener('track', this._handleTrackEvent.bind(this));
this._iceRestartBackoff.on('ready', () => this._initiateIceRestart());

const self = this;
this.on('stateChanged', function stateChanged(state) {
Expand Down Expand Up @@ -469,9 +468,10 @@ class PeerConnectionV2 extends StateMachine {
* @returns {boolean} true if encodings were updated.
*/
_maybeUpdateEncodings(track, encodings, trackReplaced = false) {
if (track.kind !== 'video') {
if (track.kind !== 'video' || track.readyState === 'ended') {
return false;
}

const browser = util.guessBrowser();

// Note(mpatwardhan): always configure encodings for safari.
Expand Down Expand Up @@ -959,7 +959,7 @@ class PeerConnectionV2 extends StateMachine {
}
this._log.warn('An ICE restart has been scheduled');
this._isIceRestartBackoffInProgress = true;
this._iceRestartBackoff.backoff();
this._iceRestartBackoff.backoff(() => this._initiateIceRestart());
}

/**
Expand Down
8 changes: 3 additions & 5 deletions lib/signaling/v2/twilioconnectiontransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const StateMachine = require('../../statemachine');
const TwilioConnection = require('../../twilioconnection');
const DefaultBackoff = require('backoff');
const DefaultBackoff = require('../../util/backoff');
const { reconnectBackoffConfig } = require('../../util/constants');
const Timeout = require('../../util/timeout');
const { SDK_NAME, SDK_VERSION, SDP_FORMAT } = require('../../util/constants');
Expand Down Expand Up @@ -147,7 +147,7 @@ class TwilioConnectionTransport extends StateMachine {
writable: true
},
_reconnectBackoff: {
value: options.Backoff.exponential(reconnectBackoffConfig)
value: new options.Backoff(reconnectBackoffConfig)
},
_session: {
value: null,
Expand Down Expand Up @@ -179,7 +179,6 @@ class TwilioConnectionTransport extends StateMachine {


setupTransport(this);

}

/**
Expand Down Expand Up @@ -377,8 +376,7 @@ class TwilioConnectionTransport extends StateMachine {

// return promise that waits with exponential backoff.
return new Promise(resolve => {
this._reconnectBackoff.once('ready', resolve);
this._reconnectBackoff.backoff();
this._reconnectBackoff.backoff(resolve);
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/twilioconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const WS_CLOSE_BUSY_WAIT = 3005;
const WS_CLOSE_SERVER_BUSY = 3006;
const WS_CLOSE_OPEN_TIMEOUT = 3007;

const toplevel = global.window || global;
const toplevel = globalThis;
const WebSocket = toplevel.WebSocket ? toplevel.WebSocket : require('ws');

const CloseReason = {
Expand Down
85 changes: 85 additions & 0 deletions lib/util/backoff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

/**
* Expose `Backoff`.
*/

class Backoff {
/**
* Construct a {@link Backoff}.
* @param {object} options
* @property {number} min - Initial timeout in milliseconds [100]
* @property {number} max - Max timeout [10000]
* @property {boolean} jitter - Apply jitter [0]
* @property {number} factor - Multiplication factor for Backoff operation [2]
*/
constructor(options) {
Object.defineProperties(this, {
_min: {
value: options.min || 100
},
_max: {
value: options.max || 10000
},
_jitter: {
value: options.jitter > 0 && options.jitter <= 1 ? options.jitter : 0
},
_factor: {
value: options.factor || 2
},
_attempts: {
value: 0,
writable: true
},
_duration: {
enumerable: false,
get() {
let ms = this._min * Math.pow(this._factor, this._attempts);
if (this._jitter) {
const rand = Math.random();
const deviation = Math.floor(rand * this._jitter * ms);
ms = (Math.floor(rand * 10) & 1) === 0 ? ms - deviation : ms + deviation;
}
return Math.min(ms, this._max) | 0;
}
},
_timeoutID: {
value: null,
writable: true
}
});
}

/**
* Start the backoff operation.
* @param {function} fn - Function to call
* @return {void}
* @api public
*/
backoff(fn) {
let duration = this._duration;
if (this._timeoutID) {
clearTimeout(this._timeoutID);
this._timeoutID = null;
}
this._timeoutID = setTimeout(() => {
this._attempts++;
fn();
}, duration);
}

/**
* Reset the number of attempts and clear the timer.
*
* @return {void}
* @api public
*/
reset() {
this._attempts = 0;
if (this._timeoutID) {
clearTimeout(this._timeoutID);
this._timeoutID = null;
}
}
}

module.exports = Backoff;
29 changes: 29 additions & 0 deletions lib/util/browserdetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ function isIOS() {
return /iPad|iPhone|iPod/.test(navigator.userAgent);
}

/**
* Detects whether or not a device is an Apple touch screen device.
* @returns {boolean}
*/
function hasTouchScreen() {
return navigator && navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2;
}

/**
* Detects whether or not a device is an iPad
* @returns {boolean}
*/
function isIpad() {
return hasTouchScreen() && window.screen.width >= 744 &&
(/Macintosh/i.test(navigator.userAgent) || /iPad/.test(navigator.userAgent) || /iPad/.test(navigator.platform));
}

/**
* Detects whether or not a device is an iPhone
* @returns {boolean}
*/
function isIphone() {
return hasTouchScreen() && window.screen.width <= 476 &&
(/Macintosh/i.test(navigator.userAgent) || /iPhone/.test(navigator.userAgent) || /iPhone/.test(navigator.platform));
}

/**
* Check whether the current browser is a mobile browser
* @returns {boolean}
Expand Down Expand Up @@ -123,6 +150,8 @@ function getParenthesizedSubstrings(string) {
module.exports = {
isAndroid,
isIOS,
isIpad,
isIphone,
isMobile,
isNonChromiumEdge,
mobileWebKitBrowser,
Expand Down
22 changes: 17 additions & 5 deletions lib/util/constants.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
'use strict';
/* eslint-disable camelcase */
const packageInfo = require('../../package.json');
module.exports.SDK_NAME = `${packageInfo.name}.js`;
module.exports.SDK_VERSION = packageInfo.version;
module.exports.SDP_FORMAT = 'unified';
module.exports.hardwareDevicePublisheriPad = {
hwDeviceManufacturer: 'Apple',
hwDeviceModel: 'iPad',
hwDeviceType: 'Tablet'
};

module.exports.hardwareDevicePublisheriPhone = {
hwDeviceManufacturer: 'Apple',
hwDeviceModel: 'iPhone',
hwDeviceType: 'Mobile'
};

module.exports.DEFAULT_ENVIRONMENT = 'prod';
module.exports.DEFAULT_REALM = 'us1';
Expand Down Expand Up @@ -61,15 +73,15 @@ module.exports.ICE_INACTIVITY_THRESHOLD_MS = 3000;

module.exports.iceRestartBackoffConfig = {
factor: 1.1,
initialDelay: 1,
maxDelay: module.exports.DEFAULT_SESSION_TIMEOUT_SEC * 1000,
randomisationFactor: 0.5
min: 1,
max: module.exports.DEFAULT_SESSION_TIMEOUT_SEC * 1000,
jitter: 1
};

module.exports.reconnectBackoffConfig = {
factor: 1.5,
initialDelay: 80,
randomisationFactor: 0.5
min: 80,
jitter: 1
};

module.exports.subscriptionMode = {
Expand Down
13 changes: 11 additions & 2 deletions lib/util/insightspublisher/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable camelcase */
'use strict';

const EventEmitter = require('events').EventEmitter;
Expand All @@ -8,9 +9,11 @@ const MAX_RECONNECT_ATTEMPTS = 5;
const RECONNECT_INTERVAL_MS = 50;
const WS_CLOSE_NORMAL = 1000;

const toplevel = global.window || global;
const toplevel = globalThis;
const WebSocket = toplevel.WebSocket ? toplevel.WebSocket : require('ws');
const { hardwareDevicePublisheriPad, hardwareDevicePublisheriPhone } = require('../constants');
const util = require('../../util');
const browserdetection = require('../browserdetection');

/**
* Publish events to the Insights gateway.
Expand All @@ -36,7 +39,7 @@ class InsightsPublisher extends EventEmitter {
maxReconnectAttempts: MAX_RECONNECT_ATTEMPTS,
reconnectIntervalMs: RECONNECT_INTERVAL_MS,
userAgent: getUserAgent(),
WebSocket
WebSocket,
}, options);

Object.defineProperties(this, {
Expand Down Expand Up @@ -197,6 +200,12 @@ function connect(publisher, token, sdkName, sdkVersion, roomSid, participantSid,
roomSid: roomSid,
};

if (browserdetection.isIpad()) {
connectRequest.publisher = { ...connectRequest.publisher, ...hardwareDevicePublisheriPad };
} else if (browserdetection.isIphone()) {
connectRequest.publisher = { ...connectRequest.publisher, ...hardwareDevicePublisheriPhone };
}

ws.send(JSON.stringify(connectRequest));
});
}
Expand Down
31 changes: 31 additions & 0 deletions lib/vendor/inherits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2011-2022 Isaac Z. Schlueter
* Licensed under the ISC License.
*
* Copied from https://github.com/isaacs/inherits (2.0.4)
*/

module.exports = function inherits(ctor, superCtor) {
if (ctor && superCtor) {
ctor.super_ = superCtor;
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
} else {
// old school shim for old browsers
class TempCtor {
constructor() { }
}
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
}
};
Loading

0 comments on commit ad2cede

Please sign in to comment.