Fix post call crash on iOS8

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 39e5875a36
commit f837a46245

@ -3,16 +3,67 @@
//
#import "RemoteVideoView.h"
#import "UIFont+OWS.h"
#import "UIView+OWS.h"
#import <MetalKit/MetalKit.h>
#import <PureLayout/PureLayout.h>
#import <WebRTC/RTCEAGLVideoView.h>
#import <WebRTC/RTCMTLVideoView.h>
#import <WebRTC/RTCVideoRenderer.h>
@interface RTCMTLVideoView (MakePrivatePublic)
+ (BOOL)isMetalAvailable;
NS_ASSUME_NONNULL_BEGIN
// As of RTC M61, iOS8 crashes when ending call while de-alloc'ing the EAGLVideoView
// WebRTC doesn't seem to support iOS8 - e.g. their Podfile requires iOS9+
// Until WebRTC supports iOS8, we show a "upgrade iOS to see remote video" view
// to our few remaining iOS8 users
@interface NullVideoRenderer : UIView <RTCVideoRenderer>
@end
@implementation NullVideoRenderer
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (!self) {
return self;
}
self.backgroundColor = UIColor.blackColor;
UILabel *label = [UILabel new];
label.numberOfLines = 0;
label.text
= NSLocalizedString(@"CALL_REMOTE_VIDEO_DISABLED", @"Text shown on call screen in place of remote video");
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont ows_boldFontWithSize:ScaleFromIPhone5(20)];
label.textColor = UIColor.whiteColor;
[self addSubview:label];
[label autoVCenterInSuperview];
[label autoPinWidthToSuperviewWithMargin:ScaleFromIPhone5(16)];
return self;
}
#pragma mark - RTCVideoRenderer
/** The size of the frame. */
- (void)setSize:(CGSize)size
{
// Do nothing.
}
/** The frame to be displayed. */
- (void)renderFrame:(nullable RTCVideoFrame *)frame
{
// Do nothing.
}
@end
@interface RemoteVideoView () <RTCEAGLVideoViewDelegate>
@property (nonatomic, readonly) __kindof UIView<RTCVideoRenderer> *videoRenderer;
@ -28,6 +79,11 @@
return self;
}
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) {
_videoRenderer = [NullVideoRenderer new];
}
if (_videoRenderer == nil) {
// This class is defined in objc in order to access this compile time macro
// Currently RTC only supports metal on 64bit machines
#if defined(RTC_SUPPORTS_METAL)
@ -36,6 +92,8 @@
_videoRenderer = [[RTCMTLVideoView alloc] initWithFrame:CGRectZero];
}
#endif
}
if (_videoRenderer == nil) {
RTCEAGLVideoView *eaglVideoView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectZero];
eaglVideoView.delegate = self;
@ -86,3 +144,5 @@
}
@end
NS_ASSUME_NONNULL_END

@ -208,6 +208,9 @@
/* Accessibilty label for placing call button */
"CALL_LABEL" = "Call";
/* Text shown on call screen in place of remote video */
"CALL_REMOTE_VIDEO_DISABLED" = "Please upgrade to iOS 9 or newer to see remote video.";
/* Call setup status label after outgoing call times out */
"CALL_SCREEN_STATUS_NO_ANSWER" = "No Answer.";
@ -601,7 +604,7 @@
/* A label for generic attachments. */
"GENERIC_ATTACHMENT_LABEL" = "Attachment";
/* Please enter your search. */
/* Alert message shown when user tries to search for GIFs without entering any search terms. */
"GIF_PICKER_VIEW_MISSING_QUERY" = "Please enter your search.";
/* Title for the 'gif picker' dialog. */

Loading…
Cancel
Save