{"action":"closed","issue":{"url":"https://api.github.com/repos/twilio/video-quickstart-swift/issues/266","repository_url":"https://api.github.com/repos/twilio/video-quickstart-swift","labels_url":"https://api.github.com/repos/twilio/video-quickstart-swift/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/twilio/video-quickstart-swift/issues/266/comments","events_url":"https://api.github.com/repos/twilio/video-quickstart-swift/issues/266/events","html_url":"https://github.com/twilio/video-quickstart-swift/issues/266","id":323904066,"node_id":"MDU6SXNzdWUzMjM5MDQwNjY=","number":266,"title":"2.0.1 - Aspect Ratio gets messed up using Metal rendering.","user":{"login":"dineshflock","id":31689038,"node_id":"MDQ6VXNlcjMxNjg5MDM4","avatar_url":"https://avatars3.githubusercontent.com/u/31689038?v=4","gravatar_id":"","url":"https://api.github.com/users/dineshflock","html_url":"https://github.com/dineshflock","followers_url":"https://api.github.com/users/dineshflock/followers","following_url":"https://api.github.com/users/dineshflock/following{/other_user}","gists_url":"https://api.github.com/users/dineshflock/gists{/gist_id}","starred_url":"https://api.github.com/users/dineshflock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dineshflock/subscriptions","organizations_url":"https://api.github.com/users/dineshflock/orgs","repos_url":"https://api.github.com/users/dineshflock/repos","events_url":"https://api.github.com/users/dineshflock/events{/privacy}","received_events_url":"https://api.github.com/users/dineshflock/received_events","type":"User","site_admin":false},"labels":[{"id":300092057,"node_id":"MDU6TGFiZWwzMDAwOTIwNTc=","url":"https://api.github.com/repos/twilio/video-quickstart-swift/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":{"login":"ceaglest","id":1302577,"node_id":"MDQ6VXNlcjEzMDI1Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1302577?v=4","gravatar_id":"","url":"https://api.github.com/users/ceaglest","html_url":"https://github.com/ceaglest","followers_url":"https://api.github.com/users/ceaglest/followers","following_url":"https://api.github.com/users/ceaglest/following{/other_user}","gists_url":"https://api.github.com/users/ceaglest/gists{/gist_id}","starred_url":"https://api.github.com/users/ceaglest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceaglest/subscriptions","organizations_url":"https://api.github.com/users/ceaglest/orgs","repos_url":"https://api.github.com/users/ceaglest/repos","events_url":"https://api.github.com/users/ceaglest/events{/privacy}","received_events_url":"https://api.github.com/users/ceaglest/received_events","type":"User","site_admin":false},"assignees":[{"login":"ceaglest","id":1302577,"node_id":"MDQ6VXNlcjEzMDI1Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1302577?v=4","gravatar_id":"","url":"https://api.github.com/users/ceaglest","html_url":"https://github.com/ceaglest","followers_url":"https://api.github.com/users/ceaglest/followers","following_url":"https://api.github.com/users/ceaglest/following{/other_user}","gists_url":"https://api.github.com/users/ceaglest/gists{/gist_id}","starred_url":"https://api.github.com/users/ceaglest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceaglest/subscriptions","organizations_url":"https://api.github.com/users/ceaglest/orgs","repos_url":"https://api.github.com/users/ceaglest/repos","events_url":"https://api.github.com/users/ceaglest/events{/privacy}","received_events_url":"https://api.github.com/users/ceaglest/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2018-05-17T07:33:25Z","updated_at":"2018-05-31T01:29:06Z","closed_at":"2018-05-31T01:29:06Z","author_association":"NONE","body":"### Description\r\n\r\n> Related to help desk request (1360773)\r\n\r\n**Problem**\r\nWith the the reusability change in the TVIVideoView (2.0.0) \r\n1. Some times on scrolling the cells the aspect ratio gets messed up.\r\n2. Say I have just the local participant in the room and its video track is being rendered in a collection view cell (code below). When I go in background and and then in foreground, the mirroring gets reset along with above problem.\r\n\r\n[Reference image](https://imgur.com/a/RaaEP1x)\r\n\r\n**Questions**\r\nOn the help desk we got this response\r\n\r\n> The videoDimensions, videoOrientation, viewShouldRotateContent and mirror properties are reset to their respective default values.\r\n> \r\n> Can you verify that you're explicitly setting the values?\r\n\r\n1. When do these properties gets reset? On adding this view as renderer to a track?\r\n2. Apart from `mirror`, how do we exactly set these properties?\r\n3. A sample code snippet how to approach this would really help us.\r\n#### Code\r\n\r\n```\r\n@interface VideoCollectionViewCell() <TVIVideoViewDelegate>\r\n\r\n@property (nonatomic) NSString *uniqueIdentifier;\r\n\r\n@property (nonatomic, weak) IBOutlet UIView *borderView;\r\n@property (nonatomic, weak) IBOutlet TVIVideoView *videoView;\r\n@property (nonatomic, weak) IBOutlet UIImageView *profileImageView;\r\n@property (nonatomic, weak) IBOutlet UIImageView *muteIndicatorImageView;\r\n\r\n@property (nonatomic, weak) TVIVideoTrack *videoTrackBeingRendered;\r\n\r\n@end\r\n\r\n@implementation VideoCollectionViewCell\r\n\r\n- (void)awakeFromNib {\r\n  [super awakeFromNib];\r\n  [self configureBorderView];\r\n  self.videoView.delegate = self;\r\n  self.muteIndicatorImageView.layer.masksToBounds = YES;\r\n  self.muteIndicatorImageView.layer.cornerRadius = CGRectGetHeight(self.muteIndicatorImageView.frame) / 2;\r\n  [self setDefaults];\r\n}\r\n\r\n- (void)setVideoSelected:(BOOL)videoSelected {\r\n  _videoSelected = videoSelected;\r\n  self.borderView.hidden = !_videoSelected;\r\n}\r\n\r\n- (void)configureBorderView {\r\n  self.borderView.layer.borderWidth = BorderWidth;\r\n  self.borderView.layer.borderColor = [UIColor colorWithIntegerValue:BorderColor alpha:1.0].CGColor;\r\n}\r\n\r\n- (void)prepareForReuse {\r\n  [super prepareForReuse];\r\n  [self setDefaults];\r\n}\r\n\r\n- (void)setDefaults {\r\n  [self stopRenderingTrack];\r\n  [self setVideoSelected:NO];\r\n  [self setUniqueIdentifier:nil];\r\n  [self setMuted:NO];\r\n  [self setAvatar:nil];\r\n  [self setVideoViewMirroring:NO];\r\n  [self showAvatar];\r\n}\r\n\r\n- (void)setAvatar:(UIImage *)image {\r\n  [self.profileImageView setImage:image];\r\n}\r\n\r\n- (void)setMuted:(BOOL)isMuted {\r\n  self.muteIndicatorImageView.hidden = !isMuted;\r\n}\r\n\r\n- (void)setVideoViewMirroring:(BOOL)mirror {\r\n  self.videoView.mirror = mirror;\r\n}\r\n\r\n- (void)showAvatar {\r\n  [self.videoView setHidden:YES];\r\n}\r\n\r\n- (void)showVideoViewIfAvailable {\r\n  if (self.videoView.hasVideoData) {\r\n    self.videoView.contentMode = UIViewContentModeScaleAspectFill;\r\n    [self.videoView setHidden:NO];\r\n  }\r\n}\r\n\r\n- (void)renderTrack:(TVIVideoTrack *)track {\r\n  [self stopRenderingTrack];\r\n  [track.renderers containsObject:self.videoView] ?: [track addRenderer:self.videoView];\r\n  self.videoTrackBeingRendered = track;\r\n}\r\n\r\n-(void)stopRenderingTrack {\r\n  [self.videoTrackBeingRendered removeRenderer:self.videoView];\r\n}\r\n\r\n#pragma mark - Convinience methods for setting up cell\r\n\r\n- (void)setupForParticipant:(VideoCallParticipant *)participant {\r\n  ParameterAssert(participant);\r\n  [self setUniqueIdentifier:participant.uniqueIdentifier];\r\n  [self setMuted:participant.isMuted];\r\n  [self setVideoViewMirroring:participant.shouldMirrorVideoWhenDisplaying];\r\n  __weak typeof(self) weakSelf = self;\r\n  [participant avatarWithCompletionBlock:^(UIImage *image, NSError *error) {\r\n    __strong typeof(self) strongSelf = weakSelf;\r\n    if ([strongSelf.uniqueIdentifier isEqualToString:participant.uniqueIdentifier]) {\r\n      [strongSelf setAvatar:image];\r\n    }\r\n  }];\r\n  [self renderTrack:participant.videoTrack];\r\n  if (participant.videoEnabled) {\r\n    [self showVideoViewIfAvailable];\r\n  } else {\r\n    [self showAvatar];\r\n  }\r\n}\r\n\r\n- (void)unhideVideoViewIfNeeded {\r\n  if (self.videoView.hidden && self.videoTrackBeingRendered.enabled) {\r\n    self.videoView.contentMode = UIViewContentModeScaleAspectFill;\r\n    self.videoView.hidden = NO;\r\n  }\r\n}\r\n\r\n- (void)updateForMuteStateChangeForParticipant:(VideoCallParticipant *)participant {\r\n  ParameterAssert(participant);\r\n  [self setMuted:participant.isMuted];\r\n}\r\n\r\n- (void)updateForVideoStateChangeForParticipant:(VideoCallParticipant *)participant\r\n                            shouldReRenderTrack:(BOOL)shouldReRenderTrack {\r\n  ParameterAssert(participant);\r\n  shouldReRenderTrack ? [self renderTrack:participant.videoTrack] : nil;\r\n  participant.isVideoEnabled ? [self showVideoViewIfAvailable] : [self showAvatar];\r\n}\r\n\r\n#pragma mark - TVIVideoView delegate methods\r\n\r\n- (void)videoViewDidReceiveData:(TVIVideoView *)view {\r\n  [self unhideVideoViewIfNeeded];\r\n}\r\n\r\n@end\r\n```\r\n\r\n#### Reproduces How Often\r\n\r\n50%\r\n\r\n### Versions\r\n\r\nAll relevant version information for the issue.\r\n\r\n#### Video iOS SDK\r\n\r\n2.0.1 via CocoaPods\r\n\r\n#### Xcode\r\n\r\n9.2\r\n\r\nThanks\r\nDinesh"}}
{"actor":{"display_login":"ceaglest"}}