Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoView initializes twice causing app to crash (since iOS 18) #280

Open
PZoff opened this issue Nov 26, 2024 · 15 comments
Open

VideoView initializes twice causing app to crash (since iOS 18) #280

PZoff opened this issue Nov 26, 2024 · 15 comments

Comments

@PZoff
Copy link

PZoff commented Nov 26, 2024

Description

Our chat app that has a video call feature. Since iOS 18 the app crashes if one tries to start the call, apparently because the VideoView from SDK is initializing twice for unknown reasons. There are no crashes on devices which run on older iOS versions.

Steps to Reproduce

  1. Create UIView that uses VideoView as its subview.
  2. Create a VideoView from SDK programatically. The app crashes.

Code

import TwilioVideo

class CallParticipantView: UIView {
   ...
    let videoView: VideoView = VideoView(frame: CGRect(x: 0, y: 0, width: 99, height: 122), delegate: nil) // this is what throws the error
   ...

 init(name: String, pictureUrl: String) {
          super.init(frame: CGRect(x: 0, y: 0, width: 99, height: 122))
          ...
          addSubview(videoView)
          ...
 }
...
}

Expected Behavior

VideoView should only initialize once per its initializer call.

Actual Behavior

VideoView apparently initializes twice which causes the app to crash.

Reproduces How Often

On iOS 18 it happens always.
On iOS < 18 we have no records of it happening.

Logs

*** Assertion failure in -[TVIVideoView _populateInitialTraitCollection:], UIView.m:4611
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View was already initialized: <TVIVideoView: 0x10715d800; frame = (0 0; 99 122); autoresize = RM+BM; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x303f3aa80>>'
*** First throw call stack:
(0x18e8947cc 0x18bb672e4 0x18dc648d8 0x19101b790 0x19101a400 0x19101c1fc 0x109b69500 0x109b68ffc 0x199fa4918 0x199fa44f0 0x19137b1b8 0x199fa489c 0x199fa4a28 0x199fa44f0 0x19137e81c 0x19145f324 0x19117b384 0x19104bd80 0x19104bcc4 0x191a63880 0x191226440 0x191521f50 0x191521e6c 0x191520f48 0x19152311c 0x19151d248 0x19151ceb4 0x19151ccc0 0x1922a1a94 0x1922ac4f0 0x1922ac410 0x191afe08c 0x1077edc34 0x107760dec 0x10776193c 0x1b220006c 0x1b21cc224 0x1053c0a30 0x1053c271c 0x1053d2de8 0x1053d29a4 0x18e868204 0x18e865440 0x18e864830 0x1da8441c4 0x1913caeb0 0x1914795b4 0x1917b3fa8 0x1077a5380 0x1077a52f8 0x1077a53fc 0x1b4252ec8)
libc++abi: terminating due to uncaught exception of type NSException

Versions

Video iOS SDK

5.8.3 via Swift Package Manager

Xcode

16.0

iOS Version

18.1

iOS Device

iPhone 13

@bobiechen-twilio
Copy link

Hi @PZoff

Thanks for reaching out. Any chance you are running the Video app on a simulator? We also observed this exception on iOS 18 but only on the simulators. The TVIVideoView is able to initialize when running on a physical iOS 18 device. We've create a ticket for tracking. Sorry for the inconvenience.

@PZoff
Copy link
Author

PZoff commented Nov 27, 2024

Hi @bobiechen-twilio, we have not tried this on a simulator - this is happening on physical devices, even in the app installed via app store. I have built the app from XCode locally in order to provide the error logs above. Thank you for looking into it!

@bobiechen-twilio
Copy link

@PZoff Thanks for the update. My apologies - I was actually running on an iOS 17 device and thought it was the simulator architecture issue but then I ran into the same exception when running on the iOS 18 device. We will keep you posted.

@PZoff
Copy link
Author

PZoff commented Dec 3, 2024

@bobiechen-twilio are there any updates regarding this?

@rokgregoric
Copy link

Same issue, tried on iPad & iPhone running iOS 18. Crashes every single time. This is not new, I noticed that in version 4.4.0.

@sherwinstar
Copy link

Same issue. Any updates?

@vinnypatel
Copy link

vinnypatel commented Dec 12, 2024

I faced the same issue and found a solution. Follow the steps below to resolve the crashes:

Remove TVIVideoView

  1. Go to the Identity Inspector and remove TVIVideoView from the class.
  2. Declare a Variable
    Declare a variable for your video view:
    var tvView: TVIVideoView
  3. Add the Video View
    Add tvView to the desired view where you want to capture the remote video view.
  4. Repeat for Local Video View
    Follow the same process for your localVideoView.

Let me know if you need any further assistance!

@vinnypatel
Copy link

Same issue. Any updates?

Hi @sherwinstar, please follow the steps I mentioned.

@vinnypatel
Copy link

Description

Our chat app that has a video call feature. Since iOS 18 the app crashes if one tries to start the call, apparently because the VideoView from SDK is initializing twice for unknown reasons. There are no crashes on devices which run on older iOS versions.

Steps to Reproduce

  1. Create UIView that uses VideoView as its subview.
  2. Create a VideoView from SDK programatically. The app crashes.

Code

import TwilioVideo

class CallParticipantView: UIView {
   ...
    let videoView: VideoView = VideoView(frame: CGRect(x: 0, y: 0, width: 99, height: 122), delegate: nil) // this is what throws the error
   ...

 init(name: String, pictureUrl: String) {
          super.init(frame: CGRect(x: 0, y: 0, width: 99, height: 122))
          ...
          addSubview(videoView)
          ...
 }
...
}

Expected Behavior

VideoView should only initialize once per its initializer call.

Actual Behavior

VideoView apparently initializes twice which causes the app to crash.

Reproduces How Often

On iOS 18 it happens always. On iOS < 18 we have no records of it happening.

Logs

*** Assertion failure in -[TVIVideoView _populateInitialTraitCollection:], UIView.m:4611
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View was already initialized: <TVIVideoView: 0x10715d800; frame = (0 0; 99 122); autoresize = RM+BM; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x303f3aa80>>'
*** First throw call stack:
(0x18e8947cc 0x18bb672e4 0x18dc648d8 0x19101b790 0x19101a400 0x19101c1fc 0x109b69500 0x109b68ffc 0x199fa4918 0x199fa44f0 0x19137b1b8 0x199fa489c 0x199fa4a28 0x199fa44f0 0x19137e81c 0x19145f324 0x19117b384 0x19104bd80 0x19104bcc4 0x191a63880 0x191226440 0x191521f50 0x191521e6c 0x191520f48 0x19152311c 0x19151d248 0x19151ceb4 0x19151ccc0 0x1922a1a94 0x1922ac4f0 0x1922ac410 0x191afe08c 0x1077edc34 0x107760dec 0x10776193c 0x1b220006c 0x1b21cc224 0x1053c0a30 0x1053c271c 0x1053d2de8 0x1053d29a4 0x18e868204 0x18e865440 0x18e864830 0x1da8441c4 0x1913caeb0 0x1914795b4 0x1917b3fa8 0x1077a5380 0x1077a52f8 0x1077a53fc 0x1b4252ec8)
libc++abi: terminating due to uncaught exception of type NSException

Versions

Video iOS SDK

5.8.3 via Swift Package Manager

Xcode

16.0

iOS Version

18.1

iOS Device

iPhone 13

@PZoff

I got the solution, Please follow steps, I mentioned.

@rokgregoric
Copy link

If you build using Xcode 15.x the crash doesn't happen. Even on devices running iOS 18.

@PZoff
Copy link
Author

PZoff commented Dec 13, 2024

@vinnypatel Unfortunately, the solution you outlined does not work. This is because in our case, the TVIVideoView is already initialized programatically as per the code snippet provided earlier.

@zxnaresh
Copy link

I am facing the same issue for the app built using Xcode 16.0 . The app does not crash when built using Xcode 15.x.
Any updates?

@sherwinstar
Copy link

sherwinstar commented Dec 18, 2024

Same issue. Any updates?

Hi @sherwinstar, please follow the steps I mentioned.

@vinnypatel Thanks so much. Your solution saves me.

@gnickm
Copy link

gnickm commented Dec 20, 2024

Same issue here, immediate crash when the video call view loads in iOS 18 and Xcode 16. Only came up because iOS 18 broke another part of our app... 🙄

Anyway, can confirm @vinnypatel solution works -- essentially remove the TVIVideoView elements from the designer and add them programmatically. I added them in viewDidLoad of our video call controller. For the Objective-C people this is what it looks like:

    self.previewView = [[TVIVideoView alloc]initWithFrame:CGRectMake(0, 0, 200, 200) delegate:self];
    [self.view addSubview:self.previewView];
    
    self.remoteView = [[TVIVideoView alloc]initWithFrame:self.view.bounds delegate:self];
    self.remoteView.hidden = YES;
    self.remoteView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.view addSubview:self.remoteView];

Basically replacing IBOutlet references previewView and remoteView. Got some other resizing stuff in there, not really relevant to the solution tho.

@PZoff you might try allocating your VideoView instances in viewDidLoad instead of in init, seems like it works once the parent view gets loaded and initialized.

@asemivragovs
Copy link
Collaborator

Video iOS 5.8.4 has been released that addresses this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants