Browse Source

Rename fail macros in Swift.

Matthew Chen 10 months ago
parent
commit
5b50e81b4f
72 changed files with 430 additions and 429 deletions
  1. 2 2
      Signal/src/Jobs/ConversationConfigurationSyncOperation.swift
  2. 2 2
      Signal/src/Jobs/MessageFetcherJob.swift
  3. 3 3
      Signal/src/Jobs/MultiDeviceProfileKeyUpdateJob.swift
  4. 1 1
      Signal/src/UIApplication+OWS.swift
  5. 9 9
      Signal/src/ViewControllers/AddContactShareToExistingContactViewController.swift
  6. 1 1
      Signal/src/ViewControllers/CallViewController.swift
  7. 3 3
      Signal/src/ViewControllers/ColorPickerViewController.swift
  8. 8 8
      Signal/src/ViewControllers/ContactShareViewHelper.swift
  9. 10 10
      Signal/src/ViewControllers/ContactViewController.swift
  10. 1 1
      Signal/src/ViewControllers/ContactsPicker.swift
  11. 1 1
      Signal/src/ViewControllers/CropScaleImageViewController.swift
  12. 3 3
      Signal/src/ViewControllers/DebugUI/DebugUICalling.swift
  13. 14 14
      Signal/src/ViewControllers/DebugUI/DebugUIFileBrowser.swift
  14. 4 4
      Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift
  15. 1 1
      Signal/src/ViewControllers/DebugUI/DebugUIProfile.swift
  16. 9 9
      Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift
  17. 7 7
      Signal/src/ViewControllers/GifPicker/GifPickerCell.swift
  18. 10 10
      Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift
  19. 18 18
      Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift
  20. 1 1
      Signal/src/ViewControllers/InviteFlow.swift
  21. 21 21
      Signal/src/ViewControllers/MediaGalleryViewController.swift
  22. 23 23
      Signal/src/ViewControllers/MediaPageViewController.swift
  23. 32 32
      Signal/src/ViewControllers/MediaTileViewController.swift
  24. 9 9
      Signal/src/ViewControllers/MenuActionsViewController.swift
  25. 8 8
      Signal/src/ViewControllers/MessageDetailViewController.swift
  26. 1 1
      Signal/src/ViewControllers/Utils/MessageRecipientStatusUtils.swift
  27. 7 7
      Signal/src/call/CallAudioService.swift
  28. 25 25
      Signal/src/call/CallService.swift
  29. 9 9
      Signal/src/call/NonCallKitCallUIAdaptee.swift
  30. 1 1
      Signal/src/call/OutboundCallInitiator.swift
  31. 11 11
      Signal/src/call/PeerConnectionClient.swift
  32. 3 3
      Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift
  33. 2 2
      Signal/src/call/UserInterface/CallUIAdapter.swift
  34. 1 1
      Signal/src/environment/ExperienceUpgrades/ExperienceUpgrade.swift
  35. 7 7
      Signal/src/environment/PushRegistrationManager.swift
  36. 20 20
      Signal/src/network/GiphyDownloader.swift
  37. 4 4
      Signal/src/util/AppUpdateNag.swift
  38. 4 4
      Signal/src/util/OWSBackupAPI.swift
  39. 3 3
      Signal/src/views/AttachmentPointerView.swift
  40. 1 1
      Signal/src/views/QuotedReplyPreview.swift
  41. 1 1
      Signal/src/views/ReminderView.swift
  42. 6 6
      Signal/test/util/SearcherTest.swift
  43. 10 10
      SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift
  44. 1 1
      SignalMessaging/ViewControllers/ContactFieldView.swift
  45. 4 4
      SignalMessaging/ViewControllers/ContactShareApprovalViewController.swift
  46. 6 6
      SignalMessaging/ViewControllers/EditContactShareNameViewController.swift
  47. 1 1
      SignalMessaging/ViewControllers/MessageApprovalViewController.swift
  48. 5 5
      SignalMessaging/Views/AvatarImageView.swift
  49. 1 1
      SignalMessaging/Views/OWSAlerts.swift
  50. 2 2
      SignalMessaging/Views/OWSFlatButton.swift
  51. 5 5
      SignalMessaging/Views/VideoPlayerView.swift
  52. 1 1
      SignalMessaging/attachments/OWSVideoPlayer.swift
  53. 21 21
      SignalMessaging/attachments/SignalAttachment.swift
  54. 2 2
      SignalMessaging/categories/String+OWS.swift
  55. 1 1
      SignalMessaging/categories/UIDevice+featureSupport.swift
  56. 8 8
      SignalMessaging/contacts/SystemContactsFetcher.swift
  57. 5 5
      SignalMessaging/environment/NoopCallMessageHandler.swift
  58. 1 1
      SignalMessaging/environment/NoopNotificationsManager.swift
  59. 4 4
      SignalMessaging/environment/OWSAudioSession.swift
  60. 1 1
      SignalMessaging/profiles/ProfileFetcherJob.swift
  61. 2 2
      SignalMessaging/utils/ConversationSearcher.swift
  62. 2 2
      SignalMessaging/utils/ConversationStyle.swift
  63. 1 1
      SignalMessaging/utils/LRUCache.swift
  64. 6 6
      SignalMessaging/utils/OWSScreenLock.swift
  65. 1 1
      SignalMessaging/utils/SwiftSingletons.swift
  66. 5 5
      SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift
  67. 1 1
      SignalServiceKit/src/Network/OutageDetection.swift
  68. 5 5
      SignalServiceKit/src/Storage/FullTextSearchFinder.swift
  69. 13 12
      SignalServiceKit/src/Util/OWSSwiftUtils.swift
  70. 1 1
      SignalShareExtension/SAEFailedViewController.swift
  71. 1 1
      SignalShareExtension/SAELoadViewController.swift
  72. 6 6
      SignalShareExtension/ShareViewController.swift

+ 2 - 2
Signal/src/Jobs/ConversationConfigurationSyncOperation.swift

@@ -67,7 +67,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
         var dataSource: DataSource?
         self.dbConnection.readWrite { transaction in
             guard let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction) else {
-                owsFail("could not serialize sync contacts data")
+                owsFailDebug("could not serialize sync contacts data")
                 return
             }
             dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
@@ -91,7 +91,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
         var dataSource: DataSource?
         self.dbConnection.read { transaction in
             guard let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction) else {
-                owsFail("could not serialize sync groups data")
+                owsFailDebug("could not serialize sync groups data")
                 return
             }
             dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)

+ 2 - 2
Signal/src/Jobs/MessageFetcherJob.swift

@@ -45,7 +45,7 @@ public class MessageFetcherJob: NSObject {
                     let envelopeData = try envelope.serializedData()
                     self.messageReceiver.handleReceivedEnvelopeData(envelopeData)
                 } catch {
-                    owsFail("failed to serialize envelope")
+                    owsFailDebug("failed to serialize envelope")
                 }
                 self.acknowledgeDelivery(envelope: envelope)
             }
@@ -154,7 +154,7 @@ public class MessageFetcherJob: NSObject {
 
             return try builder.build()
         } catch {
-            owsFail("error building envelope: \(error)")
+            owsFailDebug("error building envelope: \(error)")
             return nil
         }
     }

+ 3 - 3
Signal/src/Jobs/MultiDeviceProfileKeyUpdateJob.swift

@@ -36,7 +36,7 @@ import SignalMessaging
 
     func run(retryDelay: TimeInterval = 1) {
         guard let localNumber = TSAccountManager.localNumber() else {
-            owsFail("localNumber was unexpectedly nil")
+            owsFailDebug("localNumber was unexpectedly nil")
             return
         }
 
@@ -49,14 +49,14 @@ import SignalMessaging
         var dataSource: DataSource?
         self.editingDatabaseConnection.readWrite { transaction in
             guard let messageData: Data = syncContactsMessage.buildPlainTextAttachmentData(with: transaction) else {
-                owsFail("could not serialize sync contacts data")
+                owsFailDebug("could not serialize sync contacts data")
                 return
             }
             dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
         }
 
         guard let attachmentDataSource = dataSource else {
-            owsFail("dataSource was unexpectedly nil")
+            owsFailDebug("dataSource was unexpectedly nil")
             return
         }
 

+ 1 - 1
Signal/src/UIApplication+OWS.swift

@@ -20,7 +20,7 @@ import Foundation
         }
         Logger.error("findFrontmostViewController: \(window)")
         guard let viewController = window.rootViewController else {
-            owsFail("Missing root view controller.")
+            owsFailDebug("Missing root view controller.")
             return nil
         }
         return viewController.findFrontmostViewController(ignoringAlerts)

+ 9 - 9
Signal/src/ViewControllers/AddContactShareToExistingContactViewController.swift

@@ -35,10 +35,10 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
     // MARK: - ContactsPickerDelegate
 
     func contactsPicker(_: ContactsPicker, contactFetchDidFail error: NSError) {
-        owsFail("with error: \(error)")
+        owsFailDebug("with error: \(error)")
 
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -48,7 +48,7 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
     func contactsPickerDidCancel(_: ContactsPicker) {
         Logger.debug("")
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -60,11 +60,11 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
 
         let contactsManager = Environment.current().contactsManager
         guard let oldCNContact = contactsManager?.cnContact(withId: oldContact.cnContactId) else {
-            owsFail("could not load old CNContact.")
+            owsFailDebug("could not load old CNContact.")
             return
         }
         guard let newCNContact = OWSContacts.systemContact(for: self.contactShare.dbRecord, imageData: self.contactShare.avatarImageData) else {
-            owsFail("could not load new CNContact.")
+            owsFailDebug("could not load new CNContact.")
             return
         }
         merge(oldCNContact: oldCNContact, newCNContact: newCNContact)
@@ -92,10 +92,10 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
 
     func contactsPicker(_: ContactsPicker, didSelectMultipleContacts contacts: [Contact]) {
         Logger.debug("")
-        owsFail("only supports single contact select")
+        owsFailDebug("only supports single contact select")
 
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -112,7 +112,7 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
         Logger.debug("")
 
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -129,7 +129,7 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
         // Note this happens for *cancel* and for *done*. Unfortunately, I don't know of a way to detect the difference
         // between the two, since both just call this method.
         guard let myIndex = navigationController.viewControllers.index(of: self) else {
-            owsFail("myIndex was unexpectedly nil")
+            owsFailDebug("myIndex was unexpectedly nil")
             navigationController.popViewController(animated: true)
             navigationController.popViewController(animated: true)
             return

+ 1 - 1
Signal/src/ViewControllers/CallViewController.swift

@@ -118,7 +118,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
                     return true
                 } else {
                     guard let portDescription = audioSource.portDescription else {
-                        owsFail("Only built in speaker should be lacking a port description.")
+                        owsFailDebug("Only built in speaker should be lacking a port description.")
                         return false
                     }
 

+ 3 - 3
Signal/src/ViewControllers/ColorPickerViewController.swift

@@ -108,7 +108,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
 
     public func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
         guard let color = colors[safe: row] else {
-            owsFail("color was unexpectedly nil")
+            owsFailDebug("color was unexpectedly nil")
             return ColorView(color: .white)
         }
 
@@ -120,7 +120,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
     var currentColor: UIColor {
         let index = pickerView.selectedRow(inComponent: 0)
         guard let color = self.colors[safe: index] else {
-            owsFail("index was unexpectedly nil")
+            owsFailDebug("index was unexpectedly nil")
             return UIColor.white
         }
 
@@ -130,7 +130,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
     @objc
     public func didTapSave() {
         guard let colorName = UIColor.ows_conversationColorName(color: self.currentColor) else {
-            owsFail("colorName was unexpectedly nil")
+            owsFailDebug("colorName was unexpectedly nil")
             self.delegate?.colorPickerDidCancel(self)
             return
         }

+ 8 - 8
Signal/src/ViewControllers/ContactShareViewHelper.swift

@@ -57,7 +57,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
         // want to let the user select if there's more than one.
         let phoneNumbers = contactShare.systemContactsWithSignalAccountPhoneNumbers(contactsManager)
         guard phoneNumbers.count > 0 else {
-            owsFail("missing Signal recipient id.")
+            owsFailDebug("missing Signal recipient id.")
             return
         }
         guard phoneNumbers.count > 1 else {
@@ -82,7 +82,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
         }
         let phoneNumbers = contactShare.e164PhoneNumbers()
         guard phoneNumbers.count > 0 else {
-            owsFail("no phone numbers.")
+            owsFailDebug("no phone numbers.")
             return
         }
 
@@ -143,12 +143,12 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
 
     private func presentNewContactView(contactShare: ContactShareViewModel, fromViewController: UIViewController) {
         guard contactsManager.supportsContactEditing else {
-            owsFail("Contact editing not supported")
+            owsFailDebug("Contact editing not supported")
             return
         }
 
         guard let systemContact = OWSContacts.systemContact(for: contactShare.dbRecord, imageData: contactShare.avatarImageData) else {
-            owsFail("Could not derive system contact.")
+            owsFailDebug("Could not derive system contact.")
             return
         }
 
@@ -172,7 +172,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
 
     private func presentSelectAddToExistingContactView(contactShare: ContactShareViewModel, fromViewController: UIViewController) {
         guard contactsManager.supportsContactEditing else {
-            owsFail("Contact editing not supported")
+            owsFailDebug("Contact editing not supported")
             return
         }
 
@@ -182,7 +182,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
         }
 
         guard let navigationController = fromViewController.navigationController else {
-            owsFail("missing navigationController")
+            owsFailDebug("missing navigationController")
             return
         }
 
@@ -196,7 +196,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
         Logger.info("")
 
         guard let delegate = delegate else {
-            owsFail("missing delegate")
+            owsFailDebug("missing delegate")
             return
         }
 
@@ -207,7 +207,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
         Logger.info("")
 
         guard let delegate = delegate else {
-            owsFail("missing delegate")
+            owsFailDebug("missing delegate")
             return
         }
 

+ 10 - 10
Signal/src/ViewControllers/ContactViewController.swift

@@ -79,7 +79,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
         super.viewWillAppear(animated)
 
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -103,7 +103,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
             // animation glitch where the navigation bar for this view controller starts to appear while
             // the whole nav stack is about to be obscured by the modal we are presenting.
             guard let postDismissNavigationController = self.postDismissNavigationController else {
-                owsFail("postDismissNavigationController was unexpectedly nil")
+                owsFailDebug("postDismissNavigationController was unexpectedly nil")
                 return
             }
 
@@ -157,7 +157,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
         AssertIsOnMainThread()
 
         guard let rootView = self.view else {
-            owsFail("missing root view.")
+            owsFailDebug("missing root view.")
             return
         }
 
@@ -223,7 +223,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
 
         let backIconName = (CurrentAppContext().isRTL ? "system_disclosure_indicator" : "system_disclosure_indicator_rtl")
         guard let backIconImage = UIImage(named: backIconName) else {
-            owsFail("missing icon.")
+            owsFailDebug("missing icon.")
             return topView
         }
         let backIconView = UIImageView(image: backIconImage.withRenderingMode(.alwaysTemplate))
@@ -438,7 +438,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
         circleView.autoHCenterInSuperview()
 
         guard let image = UIImage(named: imageName) else {
-            owsFail("missing image.")
+            owsFailDebug("missing image.")
             return button
         }
         let imageView = UIImageView(image: image.withRenderingMode(.alwaysTemplate))
@@ -527,7 +527,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
         Logger.info("")
 
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -573,7 +573,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
         Logger.info("")
 
         guard let url = NSURL(string: "tel:\(phoneNumber.phoneNumber)") else {
-            owsFail("could not open phone number.")
+            owsFailDebug("could not open phone number.")
             return
         }
         UIApplication.shared.openURL(url as URL)
@@ -601,7 +601,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
         Logger.info("")
 
         guard let url = NSURL(string: "mailto:\(email.email)") else {
-            owsFail("could not open email.")
+            owsFailDebug("could not open email.")
             return
         }
         UIApplication.shared.openURL(url as URL)
@@ -632,13 +632,13 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
 
         let mapAddress = formatAddressForQuery(address: address)
         guard let escapedMapAddress = mapAddress.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
-            owsFail("could not open address.")
+            owsFailDebug("could not open address.")
             return
         }
         // Note that we use "q" (i.e. query) rather than "address" since we can't assume
         // this is a well-formed address.
         guard let url = URL(string: "http://maps.apple.com/?q=\(escapedMapAddress)") else {
-            owsFail("could not open address.")
+            owsFailDebug("could not open address.")
             return
         }
 

+ 1 - 1
Signal/src/ViewControllers/ContactsPicker.swift

@@ -247,7 +247,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
 
     open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         guard let cell = tableView.dequeueReusableCell(withIdentifier: contactCellReuseIdentifier, for: indexPath) as? ContactCell else {
-            owsFail("cell had unexpected type")
+            owsFailDebug("cell had unexpected type")
             return UITableViewCell()
         }
 

+ 1 - 1
Signal/src/ViewControllers/CropScaleImageViewController.swift

@@ -499,7 +499,7 @@ import SignalMessaging
 
         let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
         if scaledImage == nil {
-            owsFail("could not generate dst image.")
+            owsFailDebug("could not generate dst image.")
         }
         UIGraphicsEndImageContext()
         return scaledImage

+ 3 - 3
Signal/src/ViewControllers/DebugUI/DebugUICalling.swift

@@ -22,7 +22,7 @@ class DebugUICalling: DebugUIPage {
 
     override func section(thread aThread: TSThread?) -> OWSTableSection? {
         guard let thread = aThread as? TSContactThread else {
-            owsFail("Calling is only valid for contact thread, got thread: \(String(describing: aThread))")
+            owsFailDebug("Calling is only valid for contact thread, got thread: \(String(describing: aThread))")
             return nil
         }
 
@@ -37,7 +37,7 @@ class DebugUICalling: DebugUIPage {
                     hangupBuilder.setId(kFakeCallId)
                     hangupMessage = try hangupBuilder.build()
                 } catch {
-                    owsFail("could not build proto")
+                    owsFailDebug("could not build proto")
                     return
                 }
                 let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
@@ -58,7 +58,7 @@ class DebugUICalling: DebugUIPage {
                     busyBuilder.setId(kFakeCallId)
                     busyMessage = try busyBuilder.build()
                 } catch {
-                    owsFail("Couldn't build proto")
+                    owsFailDebug("Couldn't build proto")
                     return
                 }
 

+ 14 - 14
Signal/src/ViewControllers/DebugUI/DebugUIFileBrowser.swift

@@ -65,7 +65,7 @@
                     return try fileManager.contentsOfDirectory(at: fileURL,
                                                                includingPropertiesForKeys: resourceKeys)
                 } catch {
-                    owsFail("contentsOfDirectory(\(fileURL) failed with error: \(error)")
+                    owsFailDebug("contentsOfDirectory(\(fileURL) failed with error: \(error)")
                     return []
                 }
             }()
@@ -74,13 +74,13 @@
                 let fileIcon: String = {
                     do {
                         guard let isDirectory = try fileInDirectory.resourceValues(forKeys: Set(resourceKeys)).isDirectory else {
-                            owsFail("unable to check isDirectory for file: \(fileInDirectory)")
+                            owsFailDebug("unable to check isDirectory for file: \(fileInDirectory)")
                             return ""
                         }
 
                         return isDirectory ? "๐Ÿ“ " : ""
                     } catch {
-                        owsFail("failed to check isDirectory for file: \(fileInDirectory) with error: \(error)")
+                        owsFailDebug("failed to check isDirectory for file: \(fileInDirectory) with error: \(error)")
                         return ""
                     }
                 }()
@@ -107,7 +107,7 @@
                     }
                 }
             } catch {
-                owsFail("failed getting attributes for file at path: \(fileURL)")
+                owsFailDebug("failed getting attributes for file at path: \(fileURL)")
                 return []
             }
         }()
@@ -127,7 +127,7 @@
                 alert.addAction(OWSAlerts.cancelAction)
                 alert.addAction(UIAlertAction(title: "Rename \(strongSelf.fileURL.lastPathComponent)", style: .default) { _ in
                     guard let textField = alert.textFields?.first else {
-                        owsFail("missing text field")
+                        owsFailDebug("missing text field")
                         return
                     }
 
@@ -144,7 +144,7 @@
                         Logger.debug("\(strongSelf) moved \(strongSelf.fileURL) -> \(newURL)")
                         strongSelf.navigationController?.popViewController(animated: true)
                     } catch {
-                        owsFail("\(strongSelf) failed to move \(strongSelf.fileURL) -> \(newURL) with error: \(error)")
+                        owsFailDebug("\(strongSelf) failed to move \(strongSelf.fileURL) -> \(newURL) with error: \(error)")
                     }
                 })
 
@@ -172,7 +172,7 @@
                 alert.addAction(OWSAlerts.cancelAction)
                 alert.addAction(UIAlertAction(title: "Moving \(filename)", style: .default) { _ in
                     guard let textField = alert.textFields?.first else {
-                        owsFail("missing text field")
+                        owsFailDebug("missing text field")
                         return
                     }
 
@@ -189,7 +189,7 @@
                         Logger.debug("\(strongSelf) moved \(fileURL) -> \(newURL)")
                         strongSelf.navigationController?.popViewController(animated: true)
                     } catch {
-                        owsFail("\(strongSelf) failed to move \(fileURL) -> \(newURL) with error: \(error)")
+                        owsFailDebug("\(strongSelf) failed to move \(fileURL) -> \(newURL) with error: \(error)")
                     }
                 })
 
@@ -212,7 +212,7 @@
                         try strongSelf.fileManager.removeItem(atPath: strongSelf.fileURL.path)
                         strongSelf.navigationController?.popViewController(animated: true)
                     } catch {
-                        owsFail("failed to remove item: \(strongSelf.fileURL) with error: \(error)")
+                        owsFailDebug("failed to remove item: \(strongSelf.fileURL) with error: \(error)")
                     }
                 }
             },
@@ -248,7 +248,7 @@
                         let attributes = try strongSelf.fileManager.attributesOfItem(atPath: fileURL.path)
                         return attributes[FileAttributeKey.protectionKey] as? FileProtectionType
                     } catch {
-                        owsFail("failed to get current file protection for file: \(fileURL)")
+                        owsFailDebug("failed to get current file protection for file: \(fileURL)")
                         return nil
                     }
                 }()
@@ -267,7 +267,7 @@
                             Logger.debug("updated file protection at path:\(fileURL.path) to: \(protection.rawValue)")
                             strongSelf.updateContents()
                         } catch {
-                            owsFail("failed to update file protection at path:\(fileURL.path) with error: \(error)")
+                            owsFailDebug("failed to update file protection at path:\(fileURL.path) with error: \(error)")
                         }
                     })
                 }
@@ -290,7 +290,7 @@
                 alert.addAction(OWSAlerts.cancelAction)
                 alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in
                     guard let textField = alert.textFields?.first else {
-                        owsFail("missing text field")
+                        owsFailDebug("missing text field")
                         return
                     }
 
@@ -328,7 +328,7 @@
                 alert.addAction(OWSAlerts.cancelAction)
                 alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in
                     guard let textField = alert.textFields?.first else {
-                        owsFail("missing text field")
+                        owsFailDebug("missing text field")
                         return
                     }
 
@@ -344,7 +344,7 @@
                         try strongSelf.fileManager.createDirectory(atPath: newPath, withIntermediateDirectories: false)
                         strongSelf.updateContents()
                     } catch {
-                        owsFail("Failed to create dir: \(newPath) with error: \(error)")
+                        owsFailDebug("Failed to create dir: \(newPath) with error: \(error)")
                     }
                 })
 

+ 4 - 4
Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift

@@ -31,7 +31,7 @@ class DebugUINotifications: DebugUIPage {
 
     override func section(thread aThread: TSThread?) -> OWSTableSection? {
         guard let thread = aThread else {
-            owsFail("Notifications must specify thread.")
+            owsFailDebug("Notifications must specify thread.")
             return nil
         }
 
@@ -46,17 +46,17 @@ class DebugUINotifications: DebugUIPage {
                     Logger.info("dispatching")
                     OWSPrimaryStorage.shared().newDatabaseConnection().read { (transaction) in
                         guard let viewTransaction = transaction.ext(TSMessageDatabaseViewExtensionName) as? YapDatabaseViewTransaction  else {
-                            owsFail("unable to build view transaction")
+                            owsFailDebug("unable to build view transaction")
                             return
                         }
 
                         guard let threadId = thread.uniqueId else {
-                            owsFail("thread had no uniqueId")
+                            owsFailDebug("thread had no uniqueId")
                             return
                         }
 
                         guard let incomingMessage = viewTransaction.lastObject(inGroup: threadId) as? TSIncomingMessage else {
-                            owsFail("last message was not an incoming message.")
+                            owsFailDebug("last message was not an incoming message.")
                             return
                         }
                         Logger.info("notifying user of incoming message")

+ 1 - 1
Signal/src/ViewControllers/DebugUI/DebugUIProfile.swift

@@ -45,7 +45,7 @@ class DebugUIProfile: DebugUIPage {
                 strongSelf.messageSender.sendPromise(message: message).then {
                     Logger.info("Successfully sent profile key message to thread: \(String(describing: aThread))")
                     }.catch { _ in
-                        owsFail("Failed to send profile key message to thread: \(String(describing: aThread))")
+                        owsFailDebug("Failed to send profile key message to thread: \(String(describing: aThread))")
                 }
             }
         ]

+ 9 - 9
Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift

@@ -45,7 +45,7 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
             // dismiss the modally presented view controller, then proceed.
             self.experienceUpgradesPageViewController.dismiss(animated: true) {
                 guard let fromViewController = UIApplication.shared.frontmostViewController else {
-                    owsFail("frontmostViewController was unexectedly nil")
+                    owsFailDebug("frontmostViewController was unexectedly nil")
                     return
                 }
 
@@ -107,7 +107,7 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
         Logger.debug("")
 
         guard let buttonAction = self.buttonAction else {
-            owsFail("button action was nil")
+            owsFailDebug("button action was nil")
             return
         }
 
@@ -155,7 +155,7 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc
             // dismiss the modally presented view controller, then proceed.
             self.experienceUpgradesPageViewController.dismiss(animated: true) {
                 guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else {
-                    owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
+                    owsFailDebug("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
                     return
                 }
 
@@ -217,7 +217,7 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc
         Logger.debug("")
 
         guard let buttonAction = self.buttonAction else {
-            owsFail("button action was nil")
+            owsFailDebug("button action was nil")
             return
         }
 
@@ -349,7 +349,7 @@ private class IntroductingProfilesExperienceUpgradeViewController: ExperienceUpg
         // dismiss the modally presented view controller, then proceed.
         experienceUpgradesPageViewController.dismiss(animated: true) {
             guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else {
-                owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
+                owsFailDebug("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
                 return
             }
             ProfileViewController.presentForUpgradeOrNag(from: fromViewController)
@@ -515,7 +515,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
 
     @objc public override func viewDidLoad() {
         guard let firstViewController = allViewControllers.first else {
-            owsFail("no pages to show.")
+            owsFailDebug("no pages to show.")
             dismiss(animated: true)
             return
         }
@@ -601,7 +601,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
     public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
         Logger.debug("")
         guard let currentIndex = self.viewControllerIndexes[viewController] else {
-            owsFail("unknown view controller: \(viewController)")
+            owsFailDebug("unknown view controller: \(viewController)")
             return nil
         }
 
@@ -616,7 +616,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
     public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
         Logger.debug("")
         guard let currentIndex = self.viewControllerIndexes[viewController] else {
-            owsFail("unknown view controller: \(viewController)")
+            owsFailDebug("unknown view controller: \(viewController)")
             return nil
         }
 
@@ -653,7 +653,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
             return
         }
         guard let identifier = ExperienceUpgradeId(rawValue: uniqueId) else {
-            owsFail("unknown experience upgrade. skipping")
+            owsFailDebug("unknown experience upgrade. skipping")
             return
         }
 

+ 7 - 7
Signal/src/ViewControllers/GifPicker/GifPickerCell.swift

@@ -141,7 +141,7 @@ class GifPickerCell: UICollectionViewCell {
                                                                                 success: { [weak self] assetRequest, asset in
                                                                                     guard let strongSelf = self else { return }
                                                                                     if assetRequest != nil && assetRequest != strongSelf.stillAssetRequest {
-                                                                                        owsFail("Obsolete request callback.")
+                                                                                        owsFailDebug("Obsolete request callback.")
                                                                                         return
                                                                                     }
                                                                                     strongSelf.clearStillAssetRequest()
@@ -151,7 +151,7 @@ class GifPickerCell: UICollectionViewCell {
                                                                                 failure: { [weak self] assetRequest in
                                                                                     guard let strongSelf = self else { return }
                                                                                     if assetRequest != strongSelf.stillAssetRequest {
-                                                                                        owsFail("Obsolete request callback.")
+                                                                                        owsFailDebug("Obsolete request callback.")
                                                                                         return
                                                                                     }
                                                                                     strongSelf.clearStillAssetRequest()
@@ -167,7 +167,7 @@ class GifPickerCell: UICollectionViewCell {
                                                                                success: { [weak self] assetRequest, asset in
                                                                                 guard let strongSelf = self else { return }
                                                                                 if assetRequest != nil && assetRequest != strongSelf.animatedAssetRequest {
-                                                                                    owsFail("Obsolete request callback.")
+                                                                                    owsFailDebug("Obsolete request callback.")
                                                                                     return
                                                                                 }
                                                                                 // If we have the animated asset, we don't need the still asset.
@@ -178,7 +178,7 @@ class GifPickerCell: UICollectionViewCell {
                                                                                failure: { [weak self] assetRequest in
                                                                                 guard let strongSelf = self else { return }
                                                                                 if assetRequest != strongSelf.animatedAssetRequest {
-                                                                                    owsFail("Obsolete request callback.")
+                                                                                    owsFailDebug("Obsolete request callback.")
                                                                                     return
                                                                                 }
                                                                                 strongSelf.clearAnimatedAssetRequest()
@@ -197,7 +197,7 @@ class GifPickerCell: UICollectionViewCell {
             return
         }
         guard let image = YYImage(contentsOfFile: asset.filePath) else {
-            owsFail("could not load asset.")
+            owsFailDebug("could not load asset.")
             clearViewState()
             return
         }
@@ -208,7 +208,7 @@ class GifPickerCell: UICollectionViewCell {
             imageView.ows_autoPinToSuperviewEdges()
         }
         guard let imageView = imageView else {
-            owsFail("missing imageview.")
+            owsFailDebug("missing imageview.")
             clearViewState()
             return
         }
@@ -240,7 +240,7 @@ class GifPickerCell: UICollectionViewCell {
 
     public func requestRenditionForSending() -> Promise<GiphyAsset> {
         guard let renditionForSending = self.renditionForSending else {
-            owsFail("renditionForSending was unexpectedly nil")
+            owsFailDebug("renditionForSending was unexpectedly nil")
             return Promise(error: GiphyError.assertionError(description: "renditionForSending was unexpectedly nil"))
         }
 

+ 10 - 10
Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift

@@ -99,7 +99,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
     func ensureCellState() {
         for cell in self.collectionView.visibleCells {
             guard let cell = cell as? GifPickerCell else {
-                owsFail("unexpected cell.")
+                owsFailDebug("unexpected cell.")
                 return
             }
             cell.ensureCellState()
@@ -236,15 +236,15 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
 
     private func updateContents() {
         guard let noResultsView = self.noResultsView else {
-            owsFail("Missing noResultsView")
+            owsFailDebug("Missing noResultsView")
             return
         }
         guard let searchErrorView = self.searchErrorView else {
-            owsFail("Missing searchErrorView")
+            owsFailDebug("Missing searchErrorView")
             return
         }
         guard let activityIndicator = self.activityIndicator else {
-            owsFail("Missing activityIndicator")
+            owsFailDebug("Missing activityIndicator")
             return
         }
 
@@ -307,7 +307,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
         let imageInfo = imageInfos[indexPath.row]
 
         guard let gifCell = cell as? GifPickerCell else {
-            owsFail("Unexpected cell type.")
+            owsFailDebug("Unexpected cell type.")
             return cell
         }
         gifCell.imageInfo = imageInfo
@@ -319,7 +319,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
     public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
 
         guard let cell = collectionView.cellForItem(at: indexPath) as? GifPickerCell else {
-            owsFail("unexpected cell.")
+            owsFailDebug("unexpected cell.")
             return
         }
 
@@ -330,7 +330,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
         }
 
         guard self.hasSelectedCell == false else {
-            owsFail("Already selected cell")
+            owsFailDebug("Already selected cell")
             return
         }
         self.hasSelectedCell = true
@@ -370,7 +370,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
             let filePath = asset.filePath
             guard let dataSource = DataSourcePath.dataSource(withFilePath: filePath,
                 shouldDeleteOnDeallocation: false) else {
-                owsFail("couldn't load asset.")
+                owsFailDebug("couldn't load asset.")
                 return
             }
             let attachment = SignalAttachment.attachment(dataSource: dataSource, dataUTI: asset.rendition.utiType, imageQuality: .original)
@@ -402,7 +402,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
 
     public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
         guard let cell = cell as? GifPickerCell else {
-            owsFail("unexpected cell.")
+            owsFailDebug("unexpected cell.")
             return
         }
         // We only want to load the cells which are on-screen.
@@ -411,7 +411,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
 
     public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
         guard let cell = cell as? GifPickerCell else {
-            owsFail("unexpected cell.")
+            owsFailDebug("unexpected cell.")
             return
         }
         cell.isCellVisible = false

+ 18 - 18
Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift

@@ -122,17 +122,17 @@ class ConversationSearchViewController: UITableViewController {
         tableView.deselectRow(at: indexPath, animated: false)
 
         guard let searchSection = SearchSection(rawValue: indexPath.section) else {
-            owsFail("unknown section selected.")
+            owsFailDebug("unknown section selected.")
             return
         }
 
         switch searchSection {
         case .noResults:
-            owsFail("shouldn't be able to tap 'no results' section")
+            owsFailDebug("shouldn't be able to tap 'no results' section")
         case .conversations:
             let sectionResults = searchResultSet.conversations
             guard let searchResult = sectionResults[safe: indexPath.row] else {
-                owsFail("unknown row selected.")
+                owsFailDebug("unknown row selected.")
                 return
             }
 
@@ -142,7 +142,7 @@ class ConversationSearchViewController: UITableViewController {
         case .contacts:
             let sectionResults = searchResultSet.contacts
             guard let searchResult = sectionResults[safe: indexPath.row] else {
-                owsFail("unknown row selected.")
+                owsFailDebug("unknown row selected.")
                 return
             }
 
@@ -151,7 +151,7 @@ class ConversationSearchViewController: UITableViewController {
         case .messages:
             let sectionResults = searchResultSet.messages
             guard let searchResult = sectionResults[safe: indexPath.row] else {
-                owsFail("unknown row selected.")
+                owsFailDebug("unknown row selected.")
                 return
             }
 
@@ -167,7 +167,7 @@ class ConversationSearchViewController: UITableViewController {
 
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         guard let searchSection = SearchSection(rawValue: section) else {
-            owsFail("unknown section: \(section)")
+            owsFailDebug("unknown section: \(section)")
             return 0
         }
 
@@ -192,12 +192,12 @@ class ConversationSearchViewController: UITableViewController {
         switch searchSection {
         case .noResults:
             guard let cell = tableView.dequeueReusableCell(withIdentifier: EmptySearchResultCell.reuseIdentifier) as? EmptySearchResultCell else {
-                owsFail("cell was unexpectedly nil")
+                owsFailDebug("cell was unexpectedly nil")
                 return UITableViewCell()
             }
 
             guard indexPath.row == 0 else {
-                owsFail("searchResult was unexpected index")
+                owsFailDebug("searchResult was unexpected index")
                 return UITableViewCell()
             }
 
@@ -208,36 +208,36 @@ class ConversationSearchViewController: UITableViewController {
             return cell
         case .conversations:
             guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else {
-                owsFail("cell was unexpectedly nil")
+                owsFailDebug("cell was unexpectedly nil")
                 return UITableViewCell()
             }
 
             guard let searchResult = self.searchResultSet.conversations[safe: indexPath.row] else {
-                owsFail("searchResult was unexpectedly nil")
+                owsFailDebug("searchResult was unexpectedly nil")
                 return UITableViewCell()
             }
             cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, blockedPhoneNumber: self.blockedPhoneNumberSet)
             return cell
         case .contacts:
             guard let cell = tableView.dequeueReusableCell(withIdentifier: ContactTableViewCell.reuseIdentifier()) as? ContactTableViewCell else {
-                owsFail("cell was unexpectedly nil")
+                owsFailDebug("cell was unexpectedly nil")
                 return UITableViewCell()
             }
 
             guard let searchResult = self.searchResultSet.contacts[safe: indexPath.row] else {
-                owsFail("searchResult was unexpectedly nil")
+                owsFailDebug("searchResult was unexpectedly nil")
                 return UITableViewCell()
             }
             cell.configure(withRecipientId: searchResult.signalAccount.recipientId, contactsManager: contactsManager)
             return cell
         case .messages:
             guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else {
-                owsFail("cell was unexpectedly nil")
+                owsFailDebug("cell was unexpectedly nil")
                 return UITableViewCell()
             }
 
             guard let searchResult = self.searchResultSet.messages[safe: indexPath.row] else {
-                owsFail("searchResult was unexpectedly nil")
+                owsFailDebug("searchResult was unexpectedly nil")
                 return UITableViewCell()
             }
 
@@ -247,7 +247,7 @@ class ConversationSearchViewController: UITableViewController {
                 if let messageDate = searchResult.messageDate {
                     overrideDate = messageDate
                 } else {
-                    owsFail("message search result is missing message timestamp")
+                    owsFailDebug("message search result is missing message timestamp")
                 }
 
                 // Note that we only use the snippet for message results,
@@ -260,7 +260,7 @@ class ConversationSearchViewController: UITableViewController {
                                                             NSAttributedStringKey.foregroundColor: Theme.secondaryColor
                     ])
                 } else {
-                    owsFail("message search result is missing message snippet")
+                    owsFailDebug("message search result is missing message snippet")
                 }
             }
 
@@ -309,7 +309,7 @@ class ConversationSearchViewController: UITableViewController {
 
     override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
         guard let searchSection = SearchSection(rawValue: section) else {
-            owsFail("unknown section: \(section)")
+            owsFailDebug("unknown section: \(section)")
             return nil
         }
 
@@ -387,7 +387,7 @@ class ConversationSearchViewController: UITableViewController {
                                                 guard let strongSelf = self else { return }
 
                                                 guard let results = searchResults else {
-                                                    owsFail("\(strongSelf.logTag) in \(#function) searchResults was unexpectedly nil")
+                                                    owsFailDebug("\(strongSelf.logTag) in \(#function) searchResults was unexpectedly nil")
                                                     return
                                                 }
 

+ 1 - 1
Signal/src/ViewControllers/InviteFlow.swift

@@ -141,7 +141,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
     }
 
     func contactsPicker(_: ContactsPicker, didSelectContact contact: Contact) {
-        owsFail("InviteFlow only supports multi-select")
+        owsFailDebug("InviteFlow only supports multi-select")
         self.presentingViewController.dismiss(animated: true)
     }
 

+ 21 - 21
Signal/src/ViewControllers/MediaGalleryViewController.swift

@@ -35,7 +35,7 @@ public struct MediaGalleryItem: Equatable, Hashable {
 
     var thumbnailImage: UIImage {
         guard let image = attachmentStream.thumbnailImage() else {
-            owsFail("unexpectedly unable to build attachment thumbnail")
+            owsFailDebug("unexpectedly unable to build attachment thumbnail")
             return UIImage()
         }
 
@@ -44,7 +44,7 @@ public struct MediaGalleryItem: Equatable, Hashable {
 
     var fullSizedImage: UIImage {
         guard let image = attachmentStream.image() else {
-            owsFail("unexpectedly unable to build attachment image")
+            owsFailDebug("unexpectedly unable to build attachment image")
             return UIImage()
         }
 
@@ -282,7 +282,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
         }
 
         guard let initialDetailItem = galleryItem else {
-            owsFail("unexpectedly failed to build initialDetailItem.")
+            owsFailDebug("unexpectedly failed to build initialDetailItem.")
             return
         }
 
@@ -329,7 +329,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
         self.view.alpha = 0.0
 
         guard let detailView = pageViewController.view else {
-            owsFail("detailView was unexpectedly nil")
+            owsFailDebug("detailView was unexpectedly nil")
             return
         }
 
@@ -454,7 +454,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
             //
 
             guard let pageViewController = self.pageViewController else {
-                owsFail("pageViewController was unexpectedly nil")
+                owsFailDebug("pageViewController was unexpectedly nil")
                 self.dismiss(animated: true)
 
                 return
@@ -473,7 +473,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
         UIApplication.shared.isStatusBarHidden = false
 
         guard let detailView = mediaPageViewController.view else {
-            owsFail("detailView was unexpectedly nil")
+            owsFailDebug("detailView was unexpectedly nil")
             self.presentingViewController?.dismiss(animated: false, completion: completion)
             return
         }
@@ -520,7 +520,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
                            options: .curveEaseInOut,
                            animations: {
                             guard let replacingView = self.replacingView else {
-                                owsFail("replacingView was unexpectedly nil")
+                                owsFailDebug("replacingView was unexpectedly nil")
                                 self.presentingViewController?.dismiss(animated: false, completion: completion)
                                 return
                             }
@@ -533,7 +533,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
             })
         } else {
             guard let replacingView = self.replacingView else {
-                owsFail("replacingView was unexpectedly nil")
+                owsFailDebug("replacingView was unexpectedly nil")
                 self.presentingViewController?.dismiss(animated: false, completion: completion)
                 return
             }
@@ -549,12 +549,12 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
         }
 
         guard let originRect = self.originRect else {
-            owsFail("originRect was unexpectedly nil")
+            owsFailDebug("originRect was unexpectedly nil")
             return
         }
 
         guard let presentationSuperview = self.presentationView.superview else {
-            owsFail("presentationView.superview was unexpectedly nil")
+            owsFailDebug("presentationView.superview was unexpectedly nil")
             return
         }
 
@@ -613,7 +613,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
 
     func buildGalleryItem(message: TSMessage, transaction: YapDatabaseReadTransaction) -> MediaGalleryItem? {
         guard let attachmentStream = message.attachment(with: transaction) as? TSAttachmentStream else {
-            owsFail("attachment was unexpectedly empty")
+            owsFailDebug("attachment was unexpectedly empty")
             return nil
         }
 
@@ -696,7 +696,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
                     }
 
                     guard let item: MediaGalleryItem = self.buildGalleryItem(message: message, transaction: transaction) else {
-                        owsFail("unexpectedly failed to buildGalleryItem")
+                        owsFailDebug("unexpectedly failed to buildGalleryItem")
                         return
                     }
 
@@ -795,40 +795,40 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
 
         for item in items {
             guard let itemIndex = galleryItems.index(of: item) else {
-                owsFail("removing unknown item.")
+                owsFailDebug("removing unknown item.")
                 return
             }
 
             self.galleryItems.remove(at: itemIndex)
 
             guard let sectionIndex = sectionDates.index(where: { $0 == item.galleryDate }) else {
-                owsFail("item with unknown date.")
+                owsFailDebug("item with unknown date.")
                 return
             }
 
             guard var sectionItems = self.sections[item.galleryDate] else {
-                owsFail("item with unknown section")
+                owsFailDebug("item with unknown section")
                 return
             }
 
             guard let sectionRowIndex = sectionItems.index(of: item) else {
-                owsFail("item with unknown sectionRowIndex")
+                owsFailDebug("item with unknown sectionRowIndex")
                 return
             }
 
             // We need to calculate the index of the deleted item with respect to it's original position.
             guard let originalSectionIndex = originalSectionDates.index(where: { $0 == item.galleryDate }) else {
-                owsFail("item with unknown date.")
+                owsFailDebug("item with unknown date.")
                 return
             }
 
             guard let originalSectionItems = originalSections[item.galleryDate] else {
-                owsFail("item with unknown section")
+                owsFailDebug("item with unknown section")
                 return
             }
 
             guard let originalSectionRowIndex = originalSectionItems.index(of: item) else {
-                owsFail("item with unknown sectionRowIndex")
+                owsFailDebug("item with unknown sectionRowIndex")
                 return
             }
 
@@ -858,7 +858,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
         self.ensureGalleryItemsLoaded(.after, item: currentItem, amount: kGallerySwipeLoadBatchSize)
 
         guard let currentIndex = galleryItems.index(of: currentItem) else {
-            owsFail("currentIndex was unexpectedly nil")
+            owsFailDebug("currentIndex was unexpectedly nil")
             return nil
         }
 
@@ -882,7 +882,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
         self.ensureGalleryItemsLoaded(.before, item: currentItem, amount: kGallerySwipeLoadBatchSize)
 
         guard let currentIndex = galleryItems.index(of: currentItem) else {
-            owsFail("currentIndex was unexpectedly nil")
+            owsFailDebug("currentIndex was unexpectedly nil")
             return nil
         }
 

+ 23 - 23
Signal/src/ViewControllers/MediaPageViewController.swift

@@ -54,7 +54,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
 
     private func setCurrentItem(_ item: MediaGalleryItem, direction: UIPageViewControllerNavigationDirection, animated isAnimated: Bool) {
         guard let galleryPage = self.buildGalleryPage(galleryItem: item) else {
-            owsFail("unexpetedly unable to build new gallery page")
+            owsFailDebug("unexpetedly unable to build new gallery page")
             return
         }
 
@@ -107,7 +107,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         self.delegate = self
 
         guard let initialPage = self.buildGalleryPage(galleryItem: initialItem) else {
-            owsFail("unexpetedly unable to build initial gallery item")
+            owsFailDebug("unexpetedly unable to build initial gallery item")
             return
         }
         self.initialPage = initialPage
@@ -219,7 +219,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         currentViewController.stopAnyVideo()
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return
         }
         mediaGalleryDataSource.showAllMedia(focusedItem: currentItem)
@@ -258,7 +258,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         // TODO do we still need this? seems like a vestige
         // from when media detail view was used for attachment approval
         if self.footerBar == nil {
-            owsFail("No footer bar visible.")
+            owsFailDebug("No footer bar visible.")
             return
         }
 
@@ -291,7 +291,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
     @objc
     public func didPressShare(_ sender: Any) {
         guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
-            owsFail("currentViewController was unexpectedly nil")
+            owsFailDebug("currentViewController was unexpectedly nil")
             return
         }
         currentViewController.didPressShare(sender)
@@ -300,12 +300,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
     @objc
     public func didPressDelete(_ sender: Any) {
         guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
-            owsFail("currentViewController was unexpectedly nil")
+            owsFailDebug("currentViewController was unexpectedly nil")
             return
         }
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return
         }
 
@@ -327,7 +327,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         Logger.debug("")
 
         guard let currentItem = self.currentItem else {
-              owsFail("currentItem was unexpectedly nil")
+              owsFailDebug("currentItem was unexpectedly nil")
             return
         }
 
@@ -361,7 +361,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
     @objc
     public func didPressPlayBarButton(_ sender: Any) {
         guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
-            owsFail("currentViewController was unexpectedly nil")
+            owsFailDebug("currentViewController was unexpectedly nil")
             return
         }
         currentViewController.didPressPlayBarButton(sender)
@@ -370,7 +370,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
     @objc
     public func didPressPauseBarButton(_ sender: Any) {
         guard let currentViewController = self.viewControllers?[0] as? MediaDetailViewController else {
-            owsFail("currentViewController was unexpectedly nil")
+            owsFailDebug("currentViewController was unexpectedly nil")
             return
         }
         currentViewController.didPressPauseBarButton(sender)
@@ -384,7 +384,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         assert(pendingViewControllers.count == 1)
         pendingViewControllers.forEach { viewController in
             guard let pendingPage = viewController as? MediaDetailViewController else {
-                owsFail("unexpected mediaDetailViewController: \(viewController)")
+                owsFailDebug("unexpected mediaDetailViewController: \(viewController)")
                 return
             }
 
@@ -399,7 +399,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         assert(previousViewControllers.count == 1)
         previousViewControllers.forEach { viewController in
             guard let previousPage = viewController as? MediaDetailViewController else {
-                owsFail("unexpected mediaDetailViewController: \(viewController)")
+                owsFailDebug("unexpected mediaDetailViewController: \(viewController)")
                 return
             }
 
@@ -419,12 +419,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         Logger.debug("")
 
         guard let previousDetailViewController = viewController as? MediaDetailViewController else {
-            owsFail("unexpected viewController: \(viewController)")
+            owsFailDebug("unexpected viewController: \(viewController)")
             return nil
         }
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return nil
         }
 
@@ -444,12 +444,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         Logger.debug("")
 
         guard let previousDetailViewController = viewController as? MediaDetailViewController else {
-            owsFail("unexpected viewController: \(viewController)")
+            owsFailDebug("unexpected viewController: \(viewController)")
             return nil
         }
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return nil
         }
 
@@ -486,7 +486,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         }
 
         guard let viewItem = fetchedItem else {
-            owsFail("viewItem was unexpectedly nil")
+            owsFailDebug("viewItem was unexpectedly nil")
             return nil
         }
 
@@ -504,7 +504,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         currentViewController.stopAnyVideo()
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             self.presentingViewController?.dismiss(animated: true)
 
             return
@@ -524,21 +524,21 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
 
     public func mediaDetailViewController(_ mediaDetailViewController: MediaDetailViewController, requestDelete conversationViewItem: ConversationViewItem) {
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             self.presentingViewController?.dismiss(animated: true)
 
             return
         }
 
         guard let message = conversationViewItem.interaction as? TSMessage else {
-            owsFail("unexpected interaction: \(type(of: conversationViewItem))")
+            owsFailDebug("unexpected interaction: \(type(of: conversationViewItem))")
             self.presentingViewController?.dismiss(animated: true)
 
             return
         }
 
         guard let galleryItem = self.mediaGalleryDataSource?.galleryItems.first(where: { $0.message == message }) else {
-            owsFail("unexpected interaction: \(type(of: conversationViewItem))")
+            owsFailDebug("unexpected interaction: \(type(of: conversationViewItem))")
             self.presentingViewController?.dismiss(animated: true)
 
             return
@@ -572,7 +572,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
         case is TSOutgoingMessage:
             return NSLocalizedString("MEDIA_GALLERY_SENDER_NAME_YOU", comment: "Short sender label for media sent by you")
         default:
-            owsFail("Unknown message type: \(type(of: message))")
+            owsFailDebug("Unknown message type: \(type(of: message))")
             return ""
         }
     }
@@ -609,7 +609,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
 
     private func updateTitle() {
         guard let currentItem = self.currentItem else {
-            owsFail("currentItem was unexpectedly nil")
+            owsFailDebug("currentItem was unexpectedly nil")
             return
         }
         updateTitle(item: currentItem)

+ 32 - 32
Signal/src/ViewControllers/MediaTileViewController.swift

@@ -14,14 +14,14 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
 
     private var galleryItems: [GalleryDate: [MediaGalleryItem]] {
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return [:]
         }
         return mediaGalleryDataSource.sections
     }
     private var galleryDates: [GalleryDate] {
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return []
         }
         return mediaGalleryDataSource.sectionDates
@@ -76,7 +76,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         self.title = MediaStrings.allMedia
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
@@ -131,7 +131,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         }
 
         guard let indexPath = self.indexPath(galleryItem: focusedItem) else {
-            owsFail("unexpectedly unable to find indexPath for focusedItem: \(focusedItem)")
+            owsFailDebug("unexpectedly unable to find indexPath for focusedItem: \(focusedItem)")
             return
         }
 
@@ -207,12 +207,12 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         Logger.debug("")
 
         guard let galleryCell = self.collectionView(collectionView, cellForItemAt: indexPath) as? MediaGalleryCell else {
-            owsFail("galleryCell was unexpectedly nil")
+            owsFailDebug("galleryCell was unexpectedly nil")
             return
         }
 
         guard let galleryItem = galleryCell.item else {
-            owsFail("galleryItem was unexpectedly nil")
+            owsFailDebug("galleryItem was unexpectedly nil")
             return
         }
 
@@ -268,12 +268,12 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         }
 
         guard let sectionDate = self.galleryDates[safe: sectionIdx - 1] else {
-            owsFail("unknown section: \(sectionIdx)")
+            owsFailDebug("unknown section: \(sectionIdx)")
             return 0
         }
 
         guard let section = self.galleryItems[sectionDate] else {
-            owsFail("no section for date: \(sectionDate)")
+            owsFailDebug("no section for date: \(sectionDate)")
             return 0
         }
 
@@ -287,7 +287,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         guard galleryDates.count > 0 else {
             guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryStaticHeader.reuseIdentifier, for: indexPath) as? MediaGalleryStaticHeader else {
 
-                owsFail("unable to build section header for kLoadOlderSectionIdx")
+                owsFailDebug("unable to build section header for kLoadOlderSectionIdx")
                 return defaultView
             }
             let title = NSLocalizedString("GALLERY_TILES_EMPTY_GALLERY", comment: "Label indicating media gallery is empty")
@@ -300,7 +300,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
             case kLoadOlderSectionIdx:
                 guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryStaticHeader.reuseIdentifier, for: indexPath) as? MediaGalleryStaticHeader else {
 
-                    owsFail("unable to build section header for kLoadOlderSectionIdx")
+                    owsFailDebug("unable to build section header for kLoadOlderSectionIdx")
                     return defaultView
                 }
                 let title = NSLocalizedString("GALLERY_TILES_LOADING_OLDER_LABEL", comment: "Label indicating loading is in progress")
@@ -309,7 +309,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
             case loadNewerSectionIdx:
                 guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGalleryStaticHeader.reuseIdentifier, for: indexPath) as? MediaGalleryStaticHeader else {
 
-                    owsFail("unable to build section header for kLoadOlderSectionIdx")
+                    owsFailDebug("unable to build section header for kLoadOlderSectionIdx")
                     return defaultView
                 }
                 let title = NSLocalizedString("GALLERY_TILES_LOADING_MORE_RECENT_LABEL", comment: "Label indicating loading is in progress")
@@ -317,11 +317,11 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
                 return sectionHeader
             default:
                 guard let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: MediaGallerySectionHeader.reuseIdentifier, for: indexPath) as? MediaGallerySectionHeader else {
-                    owsFail("unable to build section header for indexPath: \(indexPath)")
+                    owsFailDebug("unable to build section header for indexPath: \(indexPath)")
                     return defaultView
                 }
                 guard let date = self.galleryDates[safe: indexPath.section - 1] else {
-                    owsFail("unknown section for indexPath: \(indexPath)")
+                    owsFailDebug("unknown section for indexPath: \(indexPath)")
                     return defaultView
                 }
 
@@ -339,25 +339,25 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         let defaultCell = UICollectionViewCell()
 
         guard galleryDates.count > 0 else {
-            owsFail("unexpected cell for loadNewerSectionIdx")
+            owsFailDebug("unexpected cell for loadNewerSectionIdx")
             return defaultCell
         }
 
         switch indexPath.section {
         case kLoadOlderSectionIdx:
-            owsFail("unexpected cell for kLoadOlderSectionIdx")
+            owsFailDebug("unexpected cell for kLoadOlderSectionIdx")
             return defaultCell
         case loadNewerSectionIdx:
-            owsFail("unexpected cell for loadNewerSectionIdx")
+            owsFailDebug("unexpected cell for loadNewerSectionIdx")
             return defaultCell
         default:
             guard let galleryItem = galleryItem(at: indexPath) else {
-                owsFail("no message for path: \(indexPath)")
+                owsFailDebug("no message for path: \(indexPath)")
                 return defaultCell
             }
 
             guard let cell = self.collectionView?.dequeueReusableCell(withReuseIdentifier: MediaGalleryCell.reuseIdentifier, for: indexPath) as? MediaGalleryCell else {
-                owsFail("unexpected cell for indexPath: \(indexPath)")
+                owsFailDebug("unexpected cell for indexPath: \(indexPath)")
                 return defaultCell
             }
 
@@ -369,17 +369,17 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
 
     func galleryItem(at indexPath: IndexPath) -> MediaGalleryItem? {
         guard let sectionDate = self.galleryDates[safe: indexPath.section - 1] else {
-            owsFail("unknown section: \(indexPath.section)")
+            owsFailDebug("unknown section: \(indexPath.section)")
             return nil
         }
 
         guard let sectionItems = self.galleryItems[sectionDate] else {
-            owsFail("no section for date: \(sectionDate)")
+            owsFailDebug("no section for date: \(sectionDate)")
             return nil
         }
 
         guard let galleryItem = sectionItems[safe: indexPath.row] else {
-            owsFail("no message for row: \(indexPath.row)")
+            owsFailDebug("no message for row: \(indexPath.row)")
             return nil
         }
 
@@ -400,7 +400,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         }
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return CGSize.zero
         }
 
@@ -428,7 +428,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
 
     func updateDeleteButton() {
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
@@ -455,7 +455,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         isInBatchSelectMode = true
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
@@ -487,7 +487,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         isInBatchSelectMode = false
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
@@ -512,19 +512,19 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         Logger.debug("")
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
         guard let indexPaths = collectionView.indexPathsForSelectedItems else {
-            owsFail("indexPaths was unexpectedly nil")
+            owsFailDebug("indexPaths was unexpectedly nil")
             return
         }
 
         let items: [MediaGalleryItem] = indexPaths.compactMap { return self.galleryItem(at: $0) }
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return
         }
 
@@ -560,7 +560,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         Logger.debug("")
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
@@ -573,7 +573,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         Logger.debug("with deletedSections: \(deletedSections) deletedItems: \(deletedItems)")
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpetedly nil")
+            owsFailDebug("collectionView was unexpetedly nil")
             return
         }
 
@@ -625,12 +625,12 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
         }
 
         guard let collectionView = self.collectionView else {
-            owsFail("collectionView was unexpectedly nil")
+            owsFailDebug("collectionView was unexpectedly nil")
             return
         }
 
         guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
-            owsFail("mediaGalleryDataSource was unexpectedly nil")
+            owsFailDebug("mediaGalleryDataSource was unexpectedly nil")
             return
         }
 

+ 9 - 9
Signal/src/ViewControllers/MenuActionsViewController.swift

@@ -97,13 +97,13 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
 
     private func addSnapshotFocusedView() -> UIView? {
         guard let snapshotView = self.focusedView.snapshotView(afterScreenUpdates: false) else {
-            owsFail("snapshotView was unexpectedly nil")
+            owsFailDebug("snapshotView was unexpectedly nil")
             return nil
         }
         view.addSubview(snapshotView)
 
         guard let focusedViewSuperview = focusedView.superview else {
-            owsFail("focusedViewSuperview was unexpectedly nil")
+            owsFailDebug("focusedViewSuperview was unexpectedly nil")
             return nil
         }
 
@@ -115,18 +115,18 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
 
     private func animatePresentation() {
         guard let actionSheetViewVerticalConstraint = self.actionSheetViewVerticalConstraint else {
-            owsFail("actionSheetViewVerticalConstraint was unexpectedly nil")
+            owsFailDebug("actionSheetViewVerticalConstraint was unexpectedly nil")
             return
         }
 
         guard let focusedViewSuperview = focusedView.superview else {
-            owsFail("focusedViewSuperview was unexpectedly nil")
+            owsFailDebug("focusedViewSuperview was unexpectedly nil")
             return
         }
 
         // darken background
         guard let snapshotView = addSnapshotFocusedView() else {
-            owsFail("snapshotView was unexpectedly nil")
+            owsFailDebug("snapshotView was unexpectedly nil")
             return
         }
 
@@ -169,19 +169,19 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
 
     private func animateDismiss(action: MenuAction?) {
         guard let actionSheetViewVerticalConstraint = self.actionSheetViewVerticalConstraint else {
-            owsFail("actionSheetVerticalConstraint was unexpectedly nil")
+            owsFailDebug("actionSheetVerticalConstraint was unexpectedly nil")
             self.delegate?.menuActionsDidHide(self)
             return
         }
 
         guard let snapshotView = self.snapshotView else {
-            owsFail("snapshotView was unexpectedly nil")
+            owsFailDebug("snapshotView was unexpectedly nil")
             self.delegate?.menuActionsDidHide(self)
             return
         }
 
         guard let presentationFocusOffset = self.presentationFocusOffset else {
-            owsFail("presentationFocusOffset was unexpectedly nil")
+            owsFailDebug("presentationFocusOffset was unexpectedly nil")
             self.delegate?.menuActionsDidHide(self)
             return
         }
@@ -231,7 +231,7 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
         didInformDelegateOfDismissalAnimation = true
 
         guard let presentationFocusOffset = self.presentationFocusOffset else {
-            owsFail("presentationFocusOffset was unexpectedly nil")
+            owsFailDebug("presentationFocusOffset was unexpectedly nil")
             self.delegate?.menuActionsDidHide(self)
             return
         }

+ 8 - 8
Signal/src/ViewControllers/MessageDetailViewController.swift

@@ -181,7 +181,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
 
     private func updateContent() {
         guard let contentView = contentView else {
-            owsFail("Missing contentView")
+            owsFailDebug("Missing contentView")
             return
         }
 
@@ -234,7 +234,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
 
                 for recipientId in messageRecipientIds {
                     guard let recipientState = outgoingMessage.recipientState(forRecipientId: recipientId) else {
-                        owsFail("no message status for recipient: \(recipientId).")
+                        owsFailDebug("no message status for recipient: \(recipientId).")
                         continue
                     }
 
@@ -370,7 +370,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
 
         if rows.isEmpty {
             // Neither attachment nor body.
-            owsFail("Message has neither attachment nor body.")
+            owsFailDebug("Message has neither attachment nor body.")
             rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_NO_ATTACHMENT_OR_BODY",
                                                          comment: "Label for messages without a body or attachment in the 'message metadata' view."),
                                  value: ""))
@@ -627,7 +627,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
 
     func didTapContactShare(_ viewItem: ConversationViewItem) {
         guard let contactShare = viewItem.contactShare else {
-            owsFail("missing contact.")
+            owsFailDebug("missing contact.")
             return
         }
         let contactViewController = ContactViewController(contactShare: contactShare)
@@ -652,12 +652,12 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
         AssertIsOnMainThread()
 
         guard let mediaURL = attachmentStream.mediaURL() else {
-            owsFail("mediaURL was unexpectedly nil for attachment: \(attachmentStream)")
+            owsFailDebug("mediaURL was unexpectedly nil for attachment: \(attachmentStream)")
             return
         }
 
         guard FileManager.default.fileExists(atPath: mediaURL.path) else {
-            owsFail("audio file missing at path: \(mediaURL)")
+            owsFailDebug("audio file missing at path: \(mediaURL)")
             return
         }
 
@@ -682,7 +682,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
 
     func didTapTruncatedTextMessage(_ conversationItem: ConversationViewItem) {
         guard let navigationController = self.navigationController else {
-            owsFail("navigationController was unexpectedly nil")
+            owsFailDebug("navigationController was unexpectedly nil")
             return
         }
 
@@ -721,7 +721,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
 
         guard (items.map({ $0.message }) == [self.message]) else {
             // Should only be one message we can delete when viewing message details
-            owsFail("Unexpectedly informed of irrelevant message deletion")
+            owsFailDebug("Unexpectedly informed of irrelevant message deletion")
             return
         }
 

+ 1 - 1
Signal/src/ViewControllers/Utils/MessageRecipientStatusUtils.swift

@@ -127,7 +127,7 @@ public class MessageRecipientStatusUtils: NSObject {
             return (.sent, NSLocalizedString("MESSAGE_STATUS_SENT",
                                      comment: "status message for sent messages"))
         default:
-            owsFail("Message has unexpected status: \(outgoingMessage.messageState).")
+            owsFailDebug("Message has unexpected status: \(outgoingMessage.messageState).")
             return (.sent, NSLocalizedString("MESSAGE_STATUS_SENT",
                                      comment: "status message for sent messages"))
         }

+ 7 - 7
Signal/src/call/CallAudioService.swift

@@ -65,12 +65,12 @@ struct AudioSource: Hashable {
         }
 
         guard let lhsPortDescription = lhs.portDescription else {
-            owsFail("only the built in speaker should lack a port description")
+            owsFailDebug("only the built in speaker should lack a port description")
             return false
         }
 
         guard let rhsPortDescription = rhs.portDescription else {
-            owsFail("only the built in speaker should lack a port description")
+            owsFailDebug("only the built in speaker should lack a port description")
             return false
         }
 
@@ -193,7 +193,7 @@ protocol CallAudioServiceDelegate: class {
             do {
                 try self.avAudioSession.overrideOutputAudioPort( isEnabled ? .speaker : .none )
             } catch {
-                owsFail("failed to set \(#function) = \(isEnabled) with error: \(error)")
+                owsFailDebug("failed to set \(#function) = \(isEnabled) with error: \(error)")
             }
         }
     }
@@ -260,7 +260,7 @@ protocol CallAudioServiceDelegate: class {
             }
 
         } catch {
-            owsFail("failed setting audio source with error: \(error) isSpeakerPhoneEnabled: \(call.isSpeakerphoneEnabled)")
+            owsFailDebug("failed setting audio source with error: \(error) isSpeakerPhoneEnabled: \(call.isSpeakerphoneEnabled)")
         }
     }
 
@@ -397,7 +397,7 @@ protocol CallAudioServiceDelegate: class {
 
     private func play(sound: OWSSound) {
         guard let newPlayer = OWSSounds.audioPlayer(for: sound) else {
-            owsFail("unable to build player for sound: \(OWSSounds.displayName(for: sound))")
+            owsFailDebug("unable to build player for sound: \(OWSSounds.displayName(for: sound))")
             return
         }
         Logger.info("playing sound: \(OWSSounds.displayName(for: sound))")
@@ -461,7 +461,7 @@ protocol CallAudioServiceDelegate: class {
     var availableInputs: [AudioSource] {
         guard let availableInputs = avAudioSession.availableInputs else {
             // I'm not sure why this would happen, but it may indicate an error.
-            owsFail("No available inputs or inputs not ready")
+            owsFailDebug("No available inputs or inputs not ready")
             return [AudioSource.builtInSpeaker]
         }
 
@@ -538,7 +538,7 @@ protocol CallAudioServiceDelegate: class {
             }
         } catch {
             let message = "failed to set category: \(category) mode: \(String(describing: mode)), options: \(options) with error: \(error)"
-            owsFail(message)
+            owsFailDebug(message)
         }
 
         if audioSessionChanged {

+ 25 - 25
Signal/src/call/CallService.swift

@@ -403,7 +403,7 @@ private class SignalCallData: NSObject {
                 throw CallError.obsoleteCall(description: "obsolete call")
             }
             guard let peerConnectionClient = self.peerConnectionClient else {
-                owsFail("Missing peerConnectionClient")
+                owsFailDebug("Missing peerConnectionClient")
                 throw CallError.obsoleteCall(description: "Missing peerConnectionClient")
             }
 
@@ -414,7 +414,7 @@ private class SignalCallData: NSObject {
                     let callMessage = OWSOutgoingCallMessage(thread: call.thread, offerMessage: try offerBuilder.build())
                     return self.messageSender.sendPromise(message: callMessage)
                 } catch {
-                    owsFail("Couldn't build proto")
+                    owsFailDebug("Couldn't build proto")
                     throw CallError.fatalError(description: "Couldn't build proto")
                 }
             }
@@ -552,7 +552,7 @@ private class SignalCallData: NSObject {
 
             handleMissedCall(call)
         } catch {
-            owsFail("Couldn't build proto")
+            owsFailDebug("Couldn't build proto")
         }
     }
 
@@ -603,7 +603,7 @@ private class SignalCallData: NSObject {
 
             switch untrustedIdentity!.verificationState {
             case .verified:
-                owsFail("shouldn't have missed a call due to untrusted identity if the identity is verified")
+                owsFailDebug("shouldn't have missed a call due to untrusted identity if the identity is verified")
                 self.notificationsAdapter.presentMissedCall(newCall, callerName: callerName)
             case .default:
                 self.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: newCall, callerName: callerName)
@@ -721,7 +721,7 @@ private class SignalCallData: NSObject {
 
                 return self.messageSender.sendPromise(message: callAnswerMessage)
             } catch {
-                owsFail("Couldn't build proto")
+                owsFailDebug("Couldn't build proto")
                 throw CallError.fatalError(description: "Couldn't build proto")
             }
         }.then {
@@ -842,12 +842,12 @@ private class SignalCallData: NSObject {
             }
 
             guard let sdpMid = iceCandidate.sdpMid else {
-                owsFail("Missing sdpMid")
+                owsFailDebug("Missing sdpMid")
                 throw CallError.fatalError(description: "Missing sdpMid")
             }
 
             guard iceCandidate.sdpMLineIndex < UINT32_MAX else {
-                owsFail("Invalid sdpMLineIndex")
+                owsFailDebug("Invalid sdpMLineIndex")
                 throw CallError.fatalError(description: "Invalid sdpMLineIndex")
             }
 
@@ -867,7 +867,7 @@ private class SignalCallData: NSObject {
                 let sendPromise = self.messageSender.sendPromise(message: callMessage)
                 sendPromise.retainUntilComplete()
             } catch {
-                owsFail("Couldn't build proto")
+                owsFailDebug("Couldn't build proto")
                 throw CallError.fatalError(description: "Couldn't build proto")
             }
         }.catch { error in
@@ -908,7 +908,7 @@ private class SignalCallData: NSObject {
         case .reconnecting:
             call.state = .connected
         case .idle, .localRinging, .localFailure, .localHangup, .remoteHangup, .remoteBusy:
-            owsFail("unexpected call state: \(call.state): \(call.identifiersForLogs).")
+            owsFailDebug("unexpected call state: \(call.state): \(call.identifiersForLogs).")
         }
     }
 
@@ -931,7 +931,7 @@ private class SignalCallData: NSObject {
         case .connected:
             call.state = .reconnecting
         default:
-            owsFail("unexpected call state: \(call.state): \(call.identifiersForLogs).")
+            owsFailDebug("unexpected call state: \(call.state): \(call.identifiersForLogs).")
         }
     }
 
@@ -987,7 +987,7 @@ private class SignalCallData: NSObject {
 
         guard let call = self.call else {
             // This should never happen; return to a known good state.
-            owsFail("call was unexpectedly nil")
+            owsFailDebug("call was unexpectedly nil")
             OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
             handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) call was unexpectedly nil"))
             return
@@ -995,7 +995,7 @@ private class SignalCallData: NSObject {
 
         guard call.localId == localId else {
             // This should never happen; return to a known good state.
-            owsFail("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
+            owsFailDebug("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
             OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
             handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
             return
@@ -1091,7 +1091,7 @@ private class SignalCallData: NSObject {
 
         guard let call = self.call else {
             // This should never happen; return to a known good state.
-            owsFail("call was unexpectedly nil")
+            owsFailDebug("call was unexpectedly nil")
             OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
             handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) call was unexpectedly nil"))
             return
@@ -1099,7 +1099,7 @@ private class SignalCallData: NSObject {
 
         guard call.localId == localId else {
             // This should never happen; return to a known good state.
-            owsFail("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
+            owsFailDebug("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
             OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
             handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
             return
@@ -1119,7 +1119,7 @@ private class SignalCallData: NSObject {
         Logger.info("\(call.identifiersForLogs).")
 
         if let callRecord = call.callRecord {
-            owsFail("Not expecting callrecord to already be set")
+            owsFailDebug("Not expecting callrecord to already be set")
             callRecord.updateCallType(RPRecentCallTypeIncomingDeclined)
         } else {
             let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingDeclined, in: call.thread)
@@ -1162,7 +1162,7 @@ private class SignalCallData: NSObject {
                 callRecord.updateCallType(RPRecentCallTypeOutgoingMissed)
             }
         } else {
-            owsFail("missing call record")
+            owsFailDebug("missing call record")
         }
 
         // TODO something like this lifted from Signal-Android.
@@ -1281,7 +1281,7 @@ private class SignalCallData: NSObject {
         AssertIsOnMainThread()
 
         guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
-            owsFail("could not identify frontmostViewController")
+            owsFailDebug("could not identify frontmostViewController")
             return
         }
 
@@ -1359,7 +1359,7 @@ private class SignalCallData: NSObject {
 
         guard let callData = self.callData else {
             // This should never happen; return to a known good state.
-            owsFail("received data message, but there is no current call. Ignoring.")
+            owsFailDebug("received data message, but there is no current call. Ignoring.")
             OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
             handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) received data message, but there is no current call. Ignoring."))
             return
@@ -1371,7 +1371,7 @@ private class SignalCallData: NSObject {
 
             guard connected.id == call.signalingId else {
                 // This should never happen; return to a known good state.
-                owsFail("received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
+                owsFailDebug("received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
                 OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
                 handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)"))
                 return
@@ -1385,7 +1385,7 @@ private class SignalCallData: NSObject {
 
             guard hangup.id == call.signalingId else {
                 // This should never happen; return to a known good state.
-                owsFail("received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
+                owsFailDebug("received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
                 OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
                 handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)"))
                 return
@@ -1558,7 +1558,7 @@ private class SignalCallData: NSObject {
         AssertIsOnMainThread()
 
         if case CallError.assertionError(description: let description) = error {
-            owsFail(description)
+            owsFailDebug(description)
         }
 
         if let failedCall = failedCall {
@@ -1748,7 +1748,7 @@ private class SignalCallData: NSObject {
             }
 
             guard let call = strongSelf.call else {
-                owsFail("call has since ended. Timer should have been invalidated.")
+                owsFailDebug("call has since ended. Timer should have been invalidated.")
                 timer.invalidate()
                 return
             }
@@ -1759,11 +1759,11 @@ private class SignalCallData: NSObject {
 
     func ensureCallScreenPresented(call: SignalCall) {
         guard let currentCall = self.call else {
-            owsFail("obsolete call: \(call.identifiersForLogs)")
+            owsFailDebug("obsolete call: \(call.identifiersForLogs)")
             return
         }
         guard currentCall == call else {
-            owsFail("obsolete call: \(call.identifiersForLogs)")
+            owsFailDebug("obsolete call: \(call.identifiersForLogs)")
             return
         }
 
@@ -1789,7 +1789,7 @@ private class SignalCallData: NSObject {
 
         if !OWSWindowManager.shared().hasCall() {
             OWSProdError(OWSAnalyticsEvents.callServiceCallViewCouldNotPresent(), file: #file, function: #function, line: #line)
-            owsFail("Call terminated due to missing call view.")
+            owsFailDebug("Call terminated due to missing call view.")
             self.handleFailedCall(failedCall: call, error: CallError.assertionError(description: "Call view didn't present after \(kMaxViewPresentationDelay) seconds"))
             return
         }

+ 9 - 9
Signal/src/call/NonCallKitCallUIAdaptee.swift

@@ -68,12 +68,12 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard let call = self.callService.call else {
-            owsFail("No current call.")
+            owsFailDebug("No current call.")
             return
         }
 
         guard call.localId == localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 
@@ -84,7 +84,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard call.localId == self.callService.call?.localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 
@@ -96,12 +96,12 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard let call = self.callService.call else {
-            owsFail("No current call.")
+            owsFailDebug("No current call.")
             return
         }
 
         guard call.localId == localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 
@@ -112,7 +112,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard call.localId == self.callService.call?.localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 
@@ -131,7 +131,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         // If both parties hang up at the same moment,
         // call might already be nil.
         guard self.callService.call == nil || call.localId == self.callService.call?.localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 
@@ -160,7 +160,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard call.localId == self.callService.call?.localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 
@@ -171,7 +171,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard call.localId == self.callService.call?.localId else {
-            owsFail("localId does not match current call")
+            owsFailDebug("localId does not match current call")
             return
         }
 

+ 1 - 1
Signal/src/call/OutboundCallInitiator.swift

@@ -46,7 +46,7 @@ import SignalMessaging
         // because it can change after app launch due to user settings
         let callUIAdapter = SignalApp.shared().callUIAdapter
         guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
-            owsFail("could not identify frontmostViewController")
+            owsFailDebug("could not identify frontmostViewController")
             return false
         }
 

+ 11 - 11
Signal/src/call/PeerConnectionClient.swift

@@ -311,7 +311,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
                                                            configuration: configuration) else {
 
                                                             // TODO fail outgoing call?
-                                                            owsFail("dataChannel was unexpectedly nil")
+                                                            owsFailDebug("dataChannel was unexpectedly nil")
                                                             return
         }
         dataChannel.delegate = proxy
@@ -362,7 +362,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
             guard let strongSelf = proxyCopy.get() else { return }
 
             guard let captureController = strongSelf.videoCaptureController else {
-                owsFail("captureController was unexpectedly nil")
+                owsFailDebug("captureController was unexpectedly nil")
                 return
             }
 
@@ -383,7 +383,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
                 }
 
                 guard let captureController = strongSelf.videoCaptureController else {
-                    owsFail("videoCaptureController was unexpectedly nil")
+                    owsFailDebug("videoCaptureController was unexpectedly nil")
                     return nil
                 }
 
@@ -889,11 +889,11 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
                 return
             }
             guard peerConnection == peerConnectionParam else {
-                owsFail("mismatched peerConnection callback.")
+                owsFailDebug("mismatched peerConnection callback.")
                 return
             }
             guard stream.videoTracks.count > 0 else {
-                owsFail("didAdd stream missing stream.")
+                owsFailDebug("didAdd stream missing stream.")
                 return
             }
             let remoteVideoTrack = stream.videoTracks[0]
@@ -946,7 +946,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
                 return
             }
             guard peerConnection == peerConnectionParam else {
-                owsFail("mismatched peerConnection callback.")
+                owsFailDebug("mismatched peerConnection callback.")
                 return
             }
 
@@ -988,7 +988,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
                 return
             }
             guard peerConnection == peerConnectionParam else {
-                owsFail("mismatched peerConnection callback.")
+                owsFailDebug("mismatched peerConnection callback.")
                 return
             }
             Logger.info("adding local ICE candidate:\(candidate.sdp)")
@@ -1021,12 +1021,12 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
                 return
             }
             guard peerConnection == peerConnectionParam else {
-                owsFail("mismatched peerConnection callback.")
+                owsFailDebug("mismatched peerConnection callback.")
                 return
             }
             Logger.info("didOpen dataChannel:\(dataChannel)")
             if strongSelf.dataChannel != nil {
-                owsFail("dataChannel unexpectedly set twice.")
+                owsFailDebug("dataChannel unexpectedly set twice.")
             }
             strongSelf.dataChannel = dataChannel
             dataChannel.delegate = strongSelf.proxy
@@ -1174,12 +1174,12 @@ class VideoCaptureController {
 
         let position: AVCaptureDevice.Position = isUsingFrontCamera ? .front : .back
         guard let device: AVCaptureDevice = self.device(position: position) else {
-            owsFail("unable to find captureDevice")
+            owsFailDebug("unable to find captureDevice")
             return
         }
 
         guard let format: AVCaptureDevice.Format = self.format(device: device) else {
-            owsFail("unable to find captureDevice")
+            owsFailDebug("unable to find captureDevice")
             return
         }
 

+ 3 - 3
Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift

@@ -172,7 +172,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
         AssertIsOnMainThread()
         Logger.info("")
 
-        owsFail("CallKit should answer calls via system call screen, not via notifications.")
+        owsFailDebug("CallKit should answer calls via system call screen, not via notifications.")
     }
 
     func answerCall(_ call: SignalCall) {
@@ -185,7 +185,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
     func declineCall(localId: UUID) {
         AssertIsOnMainThread()
 
-        owsFail("CallKit should decline calls via system call screen, not via notifications.")
+        owsFailDebug("CallKit should decline calls via system call screen, not via notifications.")
     }
 
     func declineCall(_ call: SignalCall) {
@@ -370,7 +370,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
     func provider(_ provider: CXProvider, timedOutPerforming action: CXAction) {
         AssertIsOnMainThread()
 
-        owsFail("Timed out while performing \(action)")
+        owsFailDebug("Timed out while performing \(action)")
 
         // React to the action timeout if necessary, such as showing an error UI.
     }

+ 2 - 2
Signal/src/call/UserInterface/CallUIAdapter.swift

@@ -43,7 +43,7 @@ extension CallUIAdaptee {
             OWSWindowManager.shared().startCall(callViewController)
         } else {
             guard let presentingViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts else {
-                owsFail("view controller unexpectedly nil")
+                owsFailDebug("view controller unexpectedly nil")
                 return
             }
 
@@ -67,7 +67,7 @@ extension CallUIAdaptee {
         AssertIsOnMainThread()
 
         guard self.callService.call == nil else {
-            owsFail("unexpectedly found an existing call when trying to start outgoing call: \(recipientId)")
+            owsFailDebug("unexpectedly found an existing call when trying to start outgoing call: \(recipientId)")
             return
         }
 

+ 1 - 1
Signal/src/environment/ExperienceUpgrades/ExperienceUpgrade.swift

@@ -58,7 +58,7 @@ import SignalMessaging
             return super.storageBehaviorForProperty(withKey: propertyKey)
         } else {
             // Being conservative here in case we rename a property.
-            owsFail("unknown property \(propertyKey)")
+            owsFailDebug("unknown property \(propertyKey)")
             return super.storageBehaviorForProperty(withKey: propertyKey)
         }
     }

+ 7 - 7
Signal/src/environment/PushRegistrationManager.swift

@@ -72,7 +72,7 @@ public enum PushRegistrationError: Error {
     @objc
     public func didRegisterUserNotificationSettings() {
         guard let fulfillUserNotificationSettingsPromise = self.fulfillUserNotificationSettingsPromise else {
-            owsFail("promise completion in \(#function) unexpectedly nil")
+            owsFailDebug("promise completion in \(#function) unexpectedly nil")
             return
         }
 
@@ -85,7 +85,7 @@ public enum PushRegistrationError: Error {
     @objc
     public func didReceiveVanillaPushToken(_ tokenData: Data) {
         guard let fulfillVanillaTokenPromise = self.fulfillVanillaTokenPromise else {
-            owsFail("promise completion in \(#function) unexpectedly nil")
+            owsFailDebug("promise completion in \(#function) unexpectedly nil")
             return
         }
 
@@ -96,7 +96,7 @@ public enum PushRegistrationError: Error {
     @objc
     public func didFailToReceiveVanillaPushToken(error: Error) {
         guard let rejectVanillaTokenPromise = self.rejectVanillaTokenPromise else {
-            owsFail("promise completion in \(#function) unexpectedly nil")
+            owsFailDebug("promise completion in \(#function) unexpectedly nil")
             return
         }
 
@@ -116,7 +116,7 @@ public enum PushRegistrationError: Error {
         assert(type == .voIP)
         assert(credentials.type == .voIP)
         guard let fulfillVoipTokenPromise = self.fulfillVoipTokenPromise else {
-            owsFail("fulfillVoipTokenPromise was unexpectedly nil")
+            owsFailDebug("fulfillVoipTokenPromise was unexpectedly nil")
             return
         }
 
@@ -126,7 +126,7 @@ public enum PushRegistrationError: Error {
     public func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
         // It's not clear when this would happen. We've never previously handled it, but we should at
         // least start learning if it happens.
-        owsFail("Invalid state")
+        owsFailDebug("Invalid state")
     }
 
     // MARK: helpers
@@ -222,7 +222,7 @@ public enum PushRegistrationError: Error {
         }.then { (pushTokenData: Data) -> String in
             if self.isSusceptibleToFailedPushRegistration {
                 // Sentinal in case this bug is fixed.
-                owsFail("Device was unexpectedly able to complete push registration even though it was susceptible to failure.")
+                owsFailDebug("Device was unexpectedly able to complete push registration even though it was susceptible to failure.")
             }
 
             Logger.info("successfully registered for vanilla push notifications")
@@ -257,7 +257,7 @@ public enum PushRegistrationError: Error {
         }
 
         guard let voipRegistry = self.voipRegistry else {
-            owsFail("failed to initialize voipRegistry")
+            owsFailDebug("failed to initialize voipRegistry")
             reject(PushRegistrationError.assertionError(description: "\(self.logTag) failed to initialize voipRegistry"))
             return promise.then { _ in
                 // coerce expected type of returned promise - we don't really care about the value,

+ 20 - 20
Signal/src/network/GiphyDownloader.swift

@@ -60,7 +60,7 @@ class GiphyAssetSegment: NSObject {
 
     public func append(data: Data) {
         guard state == .downloading else {
-            owsFail("appending data in invalid state: \(state)")
+            owsFailDebug("appending data in invalid state: \(state)")
             return
         }
 
@@ -69,11 +69,11 @@ class GiphyAssetSegment: NSObject {
 
     public func mergeData(assetData: inout Data) -> Bool {
         guard state == .complete else {
-            owsFail("merging data in invalid state: \(state)")
+            owsFailDebug("merging data in invalid state: \(state)")
             return false
         }
         guard UInt(segmentData.count) == segmentLength else {
-            owsFail("segment data length: \(segmentData.count) doesn't match expected length: \(segmentLength)")
+            owsFailDebug("segment data length: \(segmentData.count) doesn't match expected length: \(segmentLength)")
             return false
         }
 
@@ -152,7 +152,7 @@ enum GiphyAssetRequestState: UInt {
 
         let contentLength = UInt(self.contentLength)
         guard contentLength > 0 else {
-            owsFail("rendition missing contentLength")
+            owsFailDebug("rendition missing contentLength")
             requestDidFail()
             return 0
         }
@@ -206,7 +206,7 @@ enum GiphyAssetRequestState: UInt {
 
         for segment in segments {
             guard segment.state != .failed else {
-                owsFail("unexpected failed segment.")
+                owsFailDebug("unexpected failed segment.")
                 continue
             }
             if segment.state == state {
@@ -228,7 +228,7 @@ enum GiphyAssetRequestState: UInt {
         var result: UInt = 0
         for segment in segments {
             guard segment.state != .failed else {
-                owsFail("unexpected failed segment.")
+                owsFailDebug("unexpected failed segment.")
                 continue
             }
             if segment.state == .downloading {
@@ -254,26 +254,26 @@ enum GiphyAssetRequestState: UInt {
         var assetData = Data()
         for segment in segments {
             guard segment.state == .complete else {
-                owsFail("unexpected incomplete segment.")
+                owsFailDebug("unexpected incomplete segment.")
                 return nil
             }
             guard segment.totalDataSize() > 0 else {
-                owsFail("could not merge empty segment.")
+                owsFailDebug("could not merge empty segment.")
                 return nil
             }
             guard segment.mergeData(assetData: &assetData) else {
-                owsFail("failed to merge segment data.")
+                owsFailDebug("failed to merge segment data.")
                 return nil
             }
         }
 
         guard assetData.count == contentLength else {
-            owsFail("asset data has unexpected length.")
+            owsFailDebug("asset data has unexpected length.")
             return nil
         }
 
         guard assetData.count > 0 else {
-            owsFail("could not write empty asset to disk.")
+            owsFailDebug("could not write empty asset to disk.")
             return nil
         }
 
@@ -288,7 +288,7 @@ enum GiphyAssetRequestState: UInt {
             let asset = GiphyAsset(rendition: rendition, filePath: filePath)
             return asset
         } catch let error as NSError {
-            owsFail("file write failed: \(filePath), \(error)")
+            owsFailDebug("file write failed: \(filePath), \(error)")
             return nil
         }
     }
@@ -358,7 +358,7 @@ enum GiphyAssetRequestState: UInt {
                 let fileManager = FileManager.default
                 try fileManager.removeItem(atPath: filePathCopy)
             } catch let error as NSError {
-                owsFail("file cleanup failed: \(filePathCopy), \(error)")
+                owsFailDebug("file cleanup failed: \(filePathCopy), \(error)")
             }
         }
     }
@@ -592,7 +592,7 @@ extension URLSessionTask {
 
             let task = giphyDownloadSession.dataTask(with: request, completionHandler: { data, response, error -> Void in
                 if let data = data, data.count > 0 {
-                    owsFail("HEAD request has unexpecte