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

VIDEO-4517: Add Client Track Switch Off Control Support #156

Merged

Conversation

ceaglest
Copy link
Contributor

@ceaglest ceaglest commented Apr 28, 2021

This PR adds support for Client Track Switch Off Control to the iOS Video App.

  • Client track switch off control is unset by default (resolves to auto)
  • Added feature to settings UI / settings store
  • The app does not implement any specific manual controls. Selecting manual is effectively the legacy behavior without a maxTracks limit
  • Removed the deprecated maxTracks property.
  • Removed extra UICollectionView padding on the leading edge.
  • CollectionView logic was updated to add and remove renderers at cell display time rather than cell dequeue time (thanks @timrozum)

Note: While testing this feature I ran into a background CPU usage crash which was resolved in #155.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

* Subscribed track switch off is enabled by default
* The app does not implement any specific manual controls, this is effectively the legacy behavior without maxTracks
* Comment out usage of deprecated maxTracks property for now
* No modifications to collection view cells yet
* [skip ci]
@timrozum timrozum self-requested a review April 28, 2021 17:46
@ceaglest ceaglest changed the title VIDEO-4517: Add subscribed track switch-off to VideoApp. VIDEO-4517: Add Subscribed Track Switch Off Support Apr 28, 2021
Copy link
Contributor

@timrozum timrozum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good so far.

I wouldn't really be concerned about tests at this point because most of this is settings which we don't have tests for and I expect will be replaced by InAppSettingsKit before long.

When the time comes we could consider unit tests for ConnectOptionsFactory but I can take care of that.

UI tests are probably not practical right now for this feature.

Happy to help if the cell reuse stuff needs work.

@@ -528,7 +528,7 @@
</constraints>
</view>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="wU6-sZ-Ash">
<rect key="frame" x="10" y="690" width="404" height="172"/>
<rect key="frame" x="0.0" y="690" width="414" height="172"/>
Copy link
Contributor Author

@ceaglest ceaglest Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UICollectionView had a gap of 10 points on the leading edge but was flush to the trailing edge. I think this was just an unintended bug (it's not obvious until you have more than a screen full of cells).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I set this gap intentionally but not sure what desired UX really is to be honest. I'm good with this adjustment.

Probably how it should really work someday is the collection view has no gaps on either side and instead we use spacing inside of the collection view content at start and end. This way it looks good at start/end position and when scrolling (cells are not clipped before the edge of the display).

But I think the team wants to completely redo UX of this screen someday so best to tackle then.

@ceaglest
Copy link
Contributor Author

Hi @timrozum,

I continued to test this PR yesterday. What I noticed was that UICollectionViewDataSource prefetching is preventing some of the subscribed track switch off optimizations. Specifically, the behavior where cells can be opportunistically dequeued by UIKit before they come onscreen and are not recycled immediately after they go offscreen.

I think the best way to manage rendering in the UICollectionView is to implement the delegate methods for cell display. I was wondering if you would be interested in taking a shot at it?

  • func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
  • func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath)

We should make sure that video starts / stops rendering within these methods. To me it is okay to keep the existing dequeue logic (cellForItemAtIndexPath) as an optimization to have a better chance that video will be ready by the time the cell is drawn to screen.

@timrozum
Copy link
Contributor

@ceaglest yeah I had looked at didEndDisplaying yesterday and also thought that would be useful for this.

I guess willDisplay may also be necessary if it is possible for a cell to be in use but not visible from collection view perspective. But haven't looked into that.

@ceaglest
Copy link
Contributor Author

I guess willDisplay may also be necessary if it is possible for a cell to be in use but not visible from collection view perspective. But haven't looked into that.

Yes it is needed as well. To replicate, try scrolling a cell just offscreen and then back on. Typically the cell does not go through the reuse queue during this action but your delegate receives a didEndDisplaying followed by a willDisplay.

@timrozum
Copy link
Contributor

Thanks great to know.

@ceaglest ceaglest changed the title VIDEO-4517: Add Subscribed Track Switch Off Support VIDEO-4517: Add Client Track Switch Off Control Support Apr 29, 2021
Podfile Show resolved Hide resolved
@ceaglest ceaglest marked this pull request as ready for review May 4, 2021 20:08
@ceaglest
Copy link
Contributor Author

ceaglest commented May 4, 2021

I am curious if we would cut a feature branch for media optimizations in advance of the 4.5.0 release? This app should also be updated for VideoContentPreferences, which I think deserves a separate PR.

@timrozum timrozum changed the base branch from master to feature/media-optimization May 28, 2021 20:14
Copy link
Contributor Author

@ceaglest ceaglest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't run the changes locally but it looks like they will resolve the flickering issue. Thank you @timrozum. 👍

@ceaglest ceaglest merged commit 581824e into feature/media-optimization May 28, 2021
@ceaglest ceaglest deleted the task/video-4517-subscribed-track-switch-off branch May 28, 2021 20:25
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.

2 participants