Merge branch 'charlesmchen/callViewDelay' into hotfix/2.15.2

pull/1/head
Matthew Chen 7 years ago
commit 96faa080c0

@ -728,6 +728,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
keyboardOnViewAppearing:(BOOL)keyboardOnViewAppearing
callOnViewAppearing:(BOOL)callOnViewAppearing
{
// TODO: Do this synchronously if we're already on the main thread.
dispatch_async(dispatch_get_main_queue(), ^{
MessagesViewController *mvc = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController"
bundle:nil];
@ -736,11 +737,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
callOnViewAppearing:callOnViewAppearing];
self.lastThread = thread;
if (self.presentedViewController) {
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
[self.navigationController popToRootViewControllerAnimated:YES];
[self.navigationController pushViewController:mvc animated:YES];
[self pushTopLevelViewController:mvc animateDismissal:YES animatePresentation:YES];
});
}
@ -799,6 +796,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
// Perform the first step.
if (self.presentedViewController) {
if ([self.presentedViewController isKindOfClass:[CallViewController class]]) {
OWSProdInfo([OWSAnalyticsEvents errorCouldNotPresentViewDueToCall]);
return;
}
[self.presentedViewController dismissViewControllerAnimated:animateDismissal completion:dismissNavigationBlock];
} else {
dismissNavigationBlock();

@ -144,8 +144,10 @@ protocol CallServiceObserver: class {
if let oldValue = oldValue {
DeviceSleepManager.sharedInstance.removeBlock(blockObject: oldValue)
}
stopAnyCallTimer()
if let call = call {
DeviceSleepManager.sharedInstance.addBlock(blockObject: call)
self.startCallTimer()
}
}
@ -911,8 +913,6 @@ protocol CallServiceObserver: class {
call.state = .connected
self.startActiveCallTimer(call: call)
// We don't risk transmitting any media until the remote client has admitted to being connected.
peerConnectionClient.setAudioEnabled(enabled: !call.isMuted)
peerConnectionClient.setLocalVideoEnabled(enabled: shouldHaveLocalVideoTrack())
@ -1432,7 +1432,6 @@ protocol CallServiceObserver: class {
self.call?.removeAllObservers()
self.call = nil
self.stopAnyActiveCallTimer()
self.sendIceUpdatesImmediately = true
Logger.info("\(TAG) clearing pendingIceUpdateMessages")
self.pendingIceUpdateMessages = []
@ -1574,9 +1573,8 @@ protocol CallServiceObserver: class {
// MARK: CallViewController Timer
var activeCallTimer: Timer?
func startActiveCallTimer(call: SignalCall) {
func startCallTimer() {
AssertIsOnMainThread()
assert(call.state == .connected)
if self.activeCallTimer != nil {
owsFail("\(TAG) activeCallTimer should only be set once per call")
@ -1589,29 +1587,38 @@ protocol CallServiceObserver: class {
return
}
guard call == strongSelf.call else {
guard let call = strongSelf.call else {
owsFail("\(strongSelf.TAG) call has since ended. Timer should have been invalidated.")
timer.invalidate()
return
}
strongSelf.ensureCallScreenVisible(call: call)
strongSelf.ensureCallScreenPresented(call: call)
}
}
func ensureCallScreenVisible(call: SignalCall) {
guard nil != UIApplication.shared.frontmostViewController as? CallViewController else {
owsFail("\(TAG) in \(#function) CallViewController should already be visible.")
self.callUIAdapter.showCall(call)
func ensureCallScreenPresented(call: SignalCall) {
guard let connectedDate = call.connectedDate else {
// Ignore; call hasn't connected yet.
return
}
let kMaxViewPresentationDelay = 2.5
guard fabs(connectedDate.timeIntervalSinceNow) > kMaxViewPresentationDelay else {
// Ignore; call connected recently.
return
}
Logger.debug("\(TAG) in \(#function) already visible.")
guard nil != UIApplication.shared.frontmostViewController as? CallViewController else {
OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file:#file, function:#function, line:#line)
owsFail("\(TAG) in \(#function) Call terminated due to call view presentation delay.")
self.terminateCall()
return
}
}
func stopAnyActiveCallTimer() {
func stopAnyCallTimer() {
AssertIsOnMainThread()
assert(self.call == nil)
self.activeCallTimer?.invalidate()
self.activeCallTimer = nil

@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)callServiceCallUnexpectedlyIdle;
+ (NSString *)callServiceCallViewCouldNotPresent;
+ (NSString *)callServiceCouldNotCreatePeerConnectionClientPromise;
+ (NSString *)callServiceCouldNotCreateReadyToSendIceUpdatesPromise;
@ -72,6 +74,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)errorAttachmentRequestFailed;
+ (NSString *)errorCouldNotPresentViewDueToCall;
+ (NSString *)errorEnableVideoCallingRequestFailed;
+ (NSString *)errorGetDevicesFailed;

@ -72,6 +72,11 @@ NS_ASSUME_NONNULL_BEGIN
return @"call_service_call_unexpectedly_idle";
}
+ (NSString *)callServiceCallViewCouldNotPresent
{
return @"call_service_call_view_could_not_present";
}
+ (NSString *)callServiceCouldNotCreatePeerConnectionClientPromise
{
return @"call_service_could_not_create_peer_connection_client_promise";
@ -162,6 +167,11 @@ NS_ASSUME_NONNULL_BEGIN
return @"error_attachment_request_failed";
}
+ (NSString *)errorCouldNotPresentViewDueToCall
{
return @"error_could_not_present_view_due_to_call";
}
+ (NSString *)errorEnableVideoCallingRequestFailed
{
return @"error_enable_video_calling_request_failed";

Loading…
Cancel
Save