UIViewcontroller.present crashing iOS 14.4

Hi there. I'm getting a weird crash that only happens on offline mode and the crash it self does not provide useful information in order to fix it . It appears that is crashing on the UIViewController.present it self.

Also the viewdidload from the controller that I am trying to open is not being called , so it's not a problem with the target controller. Also I don't have any init(coder) for the target controller .

Any help would be great
What I get on the console is this :
  • First throw call stack:

(0x18d44186c 0x1a245cc50 0x18d33a4a4 0x196747f30 0x1966d0f3c 0x18fa06300 0x196747ee0 0x1967480f8 0x1966d0f3c 0x18fa00f50 0x18fa03a28 0x18f6d28c0 0x18f6d2c7c 0x18f6d3334 0x18f5c05c0 0x18f5b3798 0x18f6e5750 0x18f6e6b94 0x190336638 0x18f6e6aec 0x18f6e6dcc 0x18f6e69b8 0x18f6e6ea8 0x100b594fc 0x100883238 0x1008833f4 0x18fdfde78 0x18f734ef0 0x18f735244 0x18f733aa8 0x18f93784c 0x18f9359e0 0x18fe3de30 0x18fe171d4 0x18fea10ec 0x18fea40a4 0x18fe9b550 0x18d3bd76c 0x18d3bd668 0x18d3bc960 0x18d3b6a8c 0x18d3b621c 0x1a4f82784 0x18fdf6ee8 0x18fdfc75c 0x1a171d2e4 0x100bfb70c 0x100bfb684 0x100c0d680 0x18d0766b0)

libc++abi.dylib: terminating with uncaught exception of type NSException

* Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'

Here are the crash logs:

Incident Identifier: 56549E5A-9FE8-4498-9EF5-8A46652F44F8
CrashReporter Key: fbf846903ffb1bb67daa7e7e087f5bd81e943d03
Hardware Model: iPhone10,6
Process: Beacon [8191]
Path: /private/var/containers/Bundle/Application/C4E24A54-664A-4B61-AF2F-79806BE2EA30/Beacon.app/Beacon
Identifier: com.brightcove.beacon
Version: 147 (1.0)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.brightcove.beacon [2372]


Date/Time: 2021-03-04 15:19:50.7784 +0000
Launch Time: 2021-03-04 15:19:46.7191 +0000
OS Version: iPhone OS 14.4 (18D52)
Release Type: User
Baseband Version: 4.02.01
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0

Application Specific Information:
abort() called

Last Exception Backtrace:
0 CoreFoundation 0x192d0d9d8 __exceptionPreprocess + 216
1 libobjc.A.dylib 0x1a7093b54 objc_exception_throw + 55
2 CoreFoundation 0x192c104d0 +[NSException raise:format:] + 107
3 UIFoundation 0x19b8e6f2c UINibDecoderDecodeObjectForValue + 775
4 UIFoundation 0x19b873854 -[UINibDecoder decodeObjectForKey:] + 307
5 UIKitCore 0x1951bd570 -[UIRuntimeConnection initWithCoder:] + 171
6 UIFoundation 0x19b8e6edc UINibDecoderDecodeObjectForValue + 695
7 UIFoundation 0x19b8e70f4 UINibDecoderDecodeObjectForValue + 1231
8 UIFoundation 0x19b873854 -[UINibDecoder decodeObjectForKey:] + 307
9 UIKitCore 0x1951b84fc -[NSCoder+ 7791868 (UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 487
10 UIKitCore 0x1951baed4 -[UINib instantiateWithOwner:options:] + 1063
11 UIKitCore 0x194eb6d88 -[UIViewController loadView] + 587
12 UIKitCore 0x194eb7114 -[UIViewController loadViewIfRequired] + 171
13 UIKitCore 0x194eb77e8 -[UIViewController view] + 27
14 UIKitCore 0x194db1b10 -[_UIFullscreenPresentationController _setPresentedViewController:] + 79
15 UIKitCore 0x194da5580 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 179
16 UIKitCore 0x194ec8fbc -[UIViewController _presentViewController:withAnimationController:completion:] + 3527
17 UIKitCore 0x194eca240 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 103
18 UIKitCore 0x194eca550 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 503
19 UIKitCore 0x194eca190 -[UIViewController _presentViewController:animated:completion:] + 187
20 UIKitCore 0x194eca614 -[UIViewController presentViewController:animated:completion:] + 163
21 Beacon 0x1028580fc 0x1020b0000 + 8028412
22 Beacon 0x102581dd0 0x1020b0000 + 5053904
23 Beacon 0x102581f8c 0x1020b0000 + 5054348
24 UIKitCore 0x19557ef38 -[UIApplication sendAction:to:from:forEvent:] + 95
25 UIKitCore 0x194f14184 -[UIControl sendAction:to:forEvent:] + 239
26 UIKitCore 0x194f144c8 -[UIControl _sendActionsForEvents:withEvent:] + 351
27 UIKitCore 0x194f12e00 -[UIControl touchesEnded:withEvent:] + 531
28 UIKitCore 0x1950f9350 _UIGestureEnvironmentUpdate + 6675
29 UIKitCore 0x1950f74e0 -[UIGestureEnvironment _updateForEvent:window:] + 727
30 UIKitCore 0x1955bb4cc -[UIWindow sendEvent:] + 3795
31 UIKitCore 0x195596b0c -[UIApplication sendEvent:] + 743
32 Beacon 0x1028ccef8 0x1020b0000 + 8507128
33 Beacon 0x1028cd198 0x1020b0000 + 8507800
34 UIKitCore 0x195619078 __dispatchPreprocessedEventFromEventQueue + 1031
35 UIKitCore 0x19561d818 __processEventQueue + 6439
36 UIKitCore 0x195614afc __eventFetcherSourceCallback + 155
37 CoreFoundation 0x192c8dbf0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 23
38 CoreFoundation 0x192c8daf0 __CFRunLoopDoSource0 + 203
39 CoreFoundation 0x192c8ce38 __CFRunLoopDoSources0 + 255
40 CoreFoundation 0x192c873e0 __CFRunLoopRun + 775
41 CoreFoundation 0x192c86ba0 CFRunLoopRunSpecific + 571
42 GraphicsServices 0x1a99ef598 GSEventRunModal + 159
43 UIKitCore 0x1955782f4 -[UIApplication run] + 1051
44 UIKitCore 0x19557d874 UIApplicationMain + 163
45 libswiftUIKit.dylib 0x1a6407b54 UIApplicationMain+ 80724 (
:::_:) + 99
46 Beacon 0x10224fe30 0x1020b0000 + 1703472
47 libdyld.dylib 0x192965568 start + 3



Answered by Dadofkill123 in 665501022
UPDATE : Finally I found the issue. It was related with a chromecast button that for whatever reason was making the xib to crash . removing it from the xib , made the crash disappear . So my advice is never trust google on iOS . Thank you all for your help on this !
Any information about the Nib ?

Is the controller defined in Storyboard ?

Have you checked the segue that leads to this VC as well ?
Please provide code dealing with the transition to the VC.
Hello, I don't use the storyboard for this specific screen . We are doing the everything programmatically. We have a xib for the screen with the same name of the view controller . So when we do

let playerVC = PlayerViewController()
self.present(playerVC, animated:true, completion: nil)

Basically we have not touch on the XIB since October 2020, and back then everything worked perfectly fine.

Also I did start doing some crazy test and if I run this code (below) with internet connection it works fine. The moment I turn of the internet connection and launch the app , it crashes.

let nav1 = UINavigationController()
nav1.navigationBar.barTintColor = UIColor.black
nav1.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
nav1.viewControllers = [PlayerViewController()]
self.window!.rootViewController = nav1
self.window?.makeKeyAndVisible()

if I run this code (below) with internet connection it works fine.

Do you launch on device or simulator ?

When it crashes, where exactly does it crash ?
When you write PlayerViewController(), iOS tries to instantiate the view controller using PlayerViewController.xib, which uses init(coder:) internally.

Whether you have touched or not is not important. The crash is happening while iOS is trying to instantiate PlayerViewController.xib.

Have you tried replacing it to something new created with the latest Xcode?
iOS may fail to instantiate a view controller when some old version of xib is given.
So responding the questions. I always try to have all the code and xibs updated.

this is the start of the xib document xml

<?xml version="1.0" encoding="UTF-8"?>

<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">

    <device id="retina6_1" orientation="landscape" appearance="light"/>

    <dependencies>

        <deployment identifier="iOS"/>

        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18092"/>

        <capability name="Safe area layout guides" minToolsVersion="9.0"/>

        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>

    </dependencies>

    <objects>


When you say replacing with something new created with the latest Xcode, are u saying to create a new xib from scratch and build the views to mimic the previous xib? if this is the case , no I haven't tried that yet .

This crash on the device not on the simulator.
And according to Xcode the error is triggered here :

self.present(playerVC, animated:true, completion: {

        })

i understand that may be something related with the .init inside the xib. but I can't access those functions in order to debug it ( I think).

If the worst case scenario is to rebuild the new using a newly created xib file , I will give it a try .

But the most annoying thing regarding this issue , is that if is launch with a internet connection it works properly , without internet does not . This is because we have the downloads features for content (movies, series, etc) . I agree that this may be a problem with the xib , but I want to understand exactly what could be causing this, and my suspicion is that something change on Xcode that break this for some reason . already tried the new Xcode beta and it happens. Really annoying this kind of random ambiguous crashes

When you say replacing with something new created with the latest Xcode, are u saying to create a new xib from scratch and build the views to mimic the previous xib? if this is the case , no I haven't tried that yet . 

Better try it as soon as possible. You have no need to mimic the previous xib, just need enough definitions to test if it causes the same crash or not.
Accepted Answer
UPDATE : Finally I found the issue. It was related with a chromecast button that for whatever reason was making the xib to crash . removing it from the xib , made the crash disappear . So my advice is never trust google on iOS . Thank you all for your help on this !

So my advice is never trust google on iOS .

In some cases, Apple on iOS is being hard to trust. So, your experience would benefit many developers. Thanks for sharing.
UIViewcontroller.present crashing iOS 14.4
 
 
Q